-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#390): Add swagger middleware logic and required env variables
- Loading branch information
Showing
5 changed files
with
39 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const path = require('path'); | ||
const yaml = require('yamljs'); | ||
|
||
const contractDocumentPath = path.resolve(__dirname, '../api-docs/swagger-service.yaml'); | ||
|
||
// Serve the Swagger UI | ||
module.exports = (env) => { | ||
const contractDocument = yaml.load(contractDocumentPath); | ||
contractDocument && (contractDocument.info.termsOfService = env.TERM_OF_SERVICE ?? ''); | ||
contractDocument && (contractDocument.info.contact.name = env.SWAGGER_CONTACT_NAME ?? ''); | ||
contractDocument && (contractDocument.info.contact.email = env.SWAGGER_CONTACT_EMAIL ?? ''); | ||
contractDocument && (contractDocument.servers = [ | ||
{ url: env.DEV_ENDPOINT ?? '' }, | ||
{ | ||
url: env.QA_SERVER_ENDPOINT ?? undefined, | ||
description: 'Staging server' | ||
}, | ||
{ | ||
url: env.PROD_SERVER_ENDPOINT ?? undefined, | ||
description: 'Production server' | ||
} | ||
].filter((service) => !!service.url && service)); | ||
return contractDocument; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters