-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Including swagger2openapi package * predefinedSpec with OpenAPIV3 interface * Ignoring test open api v3 spec files * Creating openapi util * Generating open api v3 spec file + converting pre-serve (not enabled) * Adding back eslint and typescript local validations * Installing missing ajv peer dependency * Splitting api-docs and api-spec routes into v2, v3 and default * Testing with updated ajv unmet peer dependency * Back to previous ajv peer dependency version * Reverting conditions for better coverage * Removing old comment about basic server * Fixing same spec v3 generated every time * .gitignore wildcard for test_spec*.json and api-spec*.json * Using top spec declaration instead of argument for middlewares * Documenting version params for middlewares * Checking res.headersSent in basic and advanced examples * Bumps swagger2openapi to 6.2.3 * Bumps swagger2openapi to 7.0.0 * Removing unnecessary ajv dependency
- Loading branch information
Showing
10 changed files
with
629 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ node_modules | |
build | ||
.idea | ||
*.iml | ||
test_spec.json | ||
api-spec.json | ||
test_spec*.json | ||
api-spec*.json |
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,25 @@ | ||
const openApiVersionConverter = require('swagger2openapi'); | ||
|
||
module.exports.versions = { | ||
OPEN_API_V2:'v2', | ||
OPEN_API_V3:'v3' | ||
}; | ||
|
||
module.exports.getSpecByVersion = (specV2, version, callback) => { | ||
const defaultSpec = (specV2, callback) => callback(null, specV2); | ||
const availableSpecs = { | ||
[this.versions.OPEN_API_V2]: defaultSpec, | ||
[this.versions.OPEN_API_V3]: this.convertOpenApiVersionToV3, | ||
}; | ||
const specByVersion = availableSpecs[version] || defaultSpec; | ||
|
||
return specByVersion(specV2, callback); | ||
}; | ||
|
||
module.exports.convertOpenApiVersionToV3 = (specV2, callback) => { | ||
const options = {patch: true, warnOnly: true}; | ||
|
||
openApiVersionConverter.convertObj(specV2, options, function(err, results) { | ||
callback(err, results && results.openapi); | ||
}); | ||
}; |
Oops, something went wrong.