Skip to content

Commit

Permalink
feat: Only deploy swagger on specified stages (completecoding#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
jochem committed Feb 22, 2022
1 parent 5ab25dc commit 94c6ca9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ServerlessAutoSwagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ class ServerlessAutoSwagger {
};

predeploy = async () => {
const stage = this.serverless.service.provider.stage;
const specifiedStages = this.serverless.service.custom?.autoswagger?.stages;
if(specifiedStages && specifiedStages.indexOf(stage) === -1) {
console.log(`Not deploying for stage: ${stage} due to custom.autoswagger.stages configuration.`);
return;
}
const generateSwaggerOnDeploy =
this.serverless.service.custom?.autoswagger?.generateSwaggerOnDeploy;
if (generateSwaggerOnDeploy === undefined || generateSwaggerOnDeploy) {
Expand Down
1 change: 1 addition & 0 deletions src/serverlessPlugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface AutoSwaggerCustomConfig {
swaggerPath?: string
basePath?: string
schemes?: SwaggerScheme[]
stages?: string[]
}
}

Expand Down

0 comments on commit 94c6ca9

Please sign in to comment.