-
Notifications
You must be signed in to change notification settings - Fork 41
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
Feature/#22 open api 3 spec #63
Conversation
@mpashkovskiy Security check is failing 😕. All tests passing on my local. Would you double check? |
I think execution of |
@@ -141,14 +145,19 @@ function serveApiDocs() { | |||
spec.definitions = mongooseModelsSpecs || {}; | |||
updateSpecFromPackage(); | |||
spec = patchSpec(predefinedSpec); | |||
app.use(packageInfo.baseUrlPath + '/api-spec', (req, res, next) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to have next line like specV3 = convertOpenApiVersionToV3(spec);
and then serve it separately as described in the comment in the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
Yes, in the meanwhile I've installed the ajv 5x peer dependency. |
Made a PR yesterday, it was dupe: |
If there is no rush I would wait for |
Shouldn't we add some extra assertions in existing tests fo make sure that v3 spec is generated along with v2? |
fyi, I've been using yarn (v1) over npm for over a year now for a reason. Apart from being overall better, it can solve this issue with module resolutions. |
Frankly speaking I doubt that yarn can solve major version dependency upgrade or an actual removal of a dependency as it requires source code changes. Otherwise I heard positive feedback about yarn. |
While adding the test to check that v3 was generated I noted a really nice bug 😅 |
Yeah, in my experience yarn has plenty of issues with Ubuntu. Now on macOS I can give it another chance! |
true - it's not magic afterall:D
Strange - I've been using windows, linux (arch linux) for over 2 years and now macos for 1 year, and never had any issues with yarn, it's been great:D |
.gitignore
Outdated
api-spec.json | ||
api-spec_v3.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just add test_spec*.json
once instead. Same with api-spec*.json
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
|
||
const apiSpecBasePath = packageInfo.baseUrlPath.concat('/api-spec'); | ||
const baseSwaggerServePath = packageInfo.baseUrlPath.concat('/' + swaggerUiServePath); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if the packageInfo
will always be defined - above [1] it's being checked before getting accessed - make sure everything's fine:D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it is! Before initializing the middlewares prepareSpec
is called, which is using updateSpecFromPackage
.
/** | ||
* @description Applies spec middlewares | ||
*/ | ||
function applySpecMiddlewares(version = '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd document the type of the version
variable perhaps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done on the method signature 👍
expect(JSON.parse(specV3res.body)).toEqual(specV3); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider using beforeEach(async (done) => {
to avoid unrelated nesting / promise hell (esp. if we ever wanted to do anything further:D)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider using
beforeEach(async (done) => {
to avoid unrelated nesting / promise hell (esp. if we ever wanted to do anything further:D)
Yeah, for now request
is using callbacks everywhere. I'll take some time to promisify and use async/await everywhere (maybe when rewriting the tests by deprecating init).
Just to clarify: accordingly to a comment in oas-kit we are waiting for schemesafe v1.0.0. Right? |
Yeah, correct. I'll upgrade |
@mpashkovskiy Just bumped swagger2openapi to 7.0.0 but there's still a security/snyk test failing. Would you please review? Thanks! |
@mpashkovskiy @kiprasmel Sorry, there was an unnecessary |
Excellent job, @maxiejbe and @kiprasmel let's test it locally and if no problems found I will publih new version to npm. |
same behavior for all pages: |
Good catch. Was it working previous to this PR? |
@mpashkovskiy Yep, the Current issue Possible fix Another possibility What do you think? |
done, please review #68 |
and I found that there is already |
Done! Just a few details. Haven't tried it locally but looking good.
Yeah, that was only if we needed to include only the corresponding |
swagger2openapi
packageapi-docs/v3
andapi-spec/v3
). Preserving default routes withv2
.