|
@@ -12,6 +12,7 @@ class SwaggerDoc {
|
|
|
private requestBody?: SwaggerRequestBody;
|
|
|
private parameters: SwaggerParameter[] = [];
|
|
|
private responses: SwaggerResponse[] = [];
|
|
|
+ private security: string[] = [];
|
|
|
|
|
|
public static get(route: string): SwaggerDoc {
|
|
|
return new SwaggerDoc(HttpMethod.GET).setRoute(route);
|
|
@@ -55,6 +56,11 @@ class SwaggerDoc {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ public addSecurityScheme(scheme: string): SwaggerDoc {
|
|
|
+ this.security.push(scheme);
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
public toAnnotation(): string {
|
|
|
let annotation = '/**\n';
|
|
|
annotation += ' *\t@swagger\n';
|
|
@@ -66,6 +72,13 @@ class SwaggerDoc {
|
|
|
|
|
|
if(this.description)
|
|
|
annotation += ` *\t\t\tdescription: ${this.description}\n`;
|
|
|
+
|
|
|
+ if(this.security.length > 0) {
|
|
|
+ annotation += ' *\t\t\tsecurity:\n';
|
|
|
+ for(const scheme of this.security) {
|
|
|
+ annotation += ` *\t\t\t\t- ${scheme}: []\n`;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if(this.parameters.length > 0) {
|
|
|
annotation += ' *\t\t\tparameters:\n';
|