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