Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#22 open api 3 spec #63

Merged
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reverting conditions for better coverage
maxiejbe committed Aug 6, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 5f356d8f7240f5914da35a16636c067f36bedd00
31 changes: 14 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
@@ -185,14 +185,12 @@ function serveApiDocs() {
applySpecMiddlewares(spec, OPEN_API_V2_SUFFIX);

convertOpenApiVersionToV3(spec, (err, specV3) => {
if (err) {
/** TODO - Log that open api v3 could not be generated. Failing with basic server setup time. */
return;
if (!err) {
applySpecMiddlewares(specV3, OPEN_API_V3_SUFFIX);
// Base path middleware should be applied after specific versions
applySpecMiddlewares(spec);
}

applySpecMiddlewares(specV3, OPEN_API_V3_SUFFIX);
// Base path middleware should be applied after specific versions
applySpecMiddlewares(spec);
/** TODO - Log that open api v3 could not be generated. Failing with basic server setup time. */
});
}

@@ -336,17 +334,16 @@ function handleResponses(expressApp,
fs.writeFileSync(specOutputPath, JSON.stringify(spec, null, 2), 'utf8');

convertOpenApiVersionToV3(spec, (err, specV3) => {
if (err) {
/** TODO - Log that open api v3 could not be generated. Failing with basic server setup time. */
return;
if (!err) {
const parsedSpecOutputPath = path.parse(specOutputPath);
const {name, ext} = parsedSpecOutputPath;
parsedSpecOutputPath.base = name.concat('_').concat(OPEN_API_V3_SUFFIX).concat(ext);

const v3Path = path.format(parsedSpecOutputPath);

fs.writeFileSync(v3Path, JSON.stringify(specV3), 'utf8');
}
const parsedSpecOutputPath = path.parse(specOutputPath);
const {name, ext} = parsedSpecOutputPath;
parsedSpecOutputPath.base = name.concat('_').concat(OPEN_API_V3_SUFFIX).concat(ext);

const v3Path = path.format(parsedSpecOutputPath);

fs.writeFileSync(v3Path, JSON.stringify(specV3), 'utf8');
/** TODO - Log that open api v3 could not be generated. Failing with basic server setup time. */
});

}