Closed HEM42 closed 4 years ago
Thanks for reporting in!
...A few i would be able to submit a PR on
Yes, please do submit a PR, with updated/new tests. (Please note that the PR should also be run through perltidy)
Definitions belongs under ./components/schemas, not ./responses.
Could you please provide a reference to the documentation? It seems very random that I would place it under "responses". Or would you happen to know if the spec has changed? If so, I should probably update the bundled spec in JSON::Validator
extra basePath and host in the spec
Aiai. Not cool. Please fix that in the PR as well.
The default responses, ..., Its still rendered as following, under definitions:, which dont belong in
v3 spec Is "definitions" not allowed in the v3 spec? This is an issue with how JSON::Validator works, so it probably needs fixing in both modules.
I'm sorry I haven't paid much attention to the v3 spec. The reason is simply that I don't use it myself. Any contribution to make it work better is greatly appreciated!
Thanks for reporting in!
...A few i would be able to submit a PR on
Yes, please do submit a PR, with updated/new tests. (Please note that the PR should also be run through perltidy)
extra basePath and host in the spec
Aiai. Not cool. Please fix that in the PR as well.
Will work on that
Definitions belongs under ./components/schemas, not ./responses.
Could you please provide a reference to the documentation? It seems very random that I would place it under "responses". Or would you happen to know if the spec has changed? If so, I should probably update the bundled spec in JSON::Validator
You are right in this, I should have read the spec (I simply converted my v2 spec, and I didn't pay attention.
So reponses is actual the correct placement, so no real issue here, now that I look at it, it complains about the structure, which I will try to fix as well.
The default responses, ..., Its still rendered as following, under definitions:, which dont belong in v3 spec Is "definitions" not allowed in the v3 spec? This is an issue with how JSON::Validator works, so it probably needs fixing in both modules.
I'm sorry I haven't paid much attention to the v3 spec. The reason is simply that I don't use it myself. Any contribution to make it work better is greatly appreciated!
Not sure that is not allowed. But its not a part fixed fields in the spec : https://swagger.io/specification/#oasObject
Since the responses is actually build in Mojolicious::Plugin::OpenAPI, but not used, since JSON::Validator creates the "definitions".
Since you mentioned JSON::Validator, I looked at it, and found this passage in the doc for bundle()
Used to create a new schema, where there are no "$ref" pointing to
external resources. This means that all the "$ref" that are found, will be
moved into the "definitions" key, in the returning $schema.
I guess its here the problem lies, that JSON::Validator also creates the "definitions", even if the $ref is #/components/responses/DefaultResponse
Im uncertain on how to fix that, but will have a look there as well. If you have a good idea on where exactly I could look
it comes in as
\ {
$ref "#/components/responses/DefaultResponse"
} (tied to JSON::Validator::Ref)
but comes out as
\ {
$ref "#/definitions/__components_responses_DefaultResponse"
} (tied to JSON::Validator::Ref)
I guess one difference from v2 to v3 is that the it went from simple structured hash (definitions names as keys), to a more complex structure with components, type, and then the actual "definition" as keys
Definitions belongs under ./components/schemas, not ./responses.
Could you please provide a reference to the documentation? It seems very random that I would place it under "responses". Or would you happen to know if the spec has changed? If so, I should probably update the bundled spec in JSON::Validator
You are right in this, I should have read the spec (I simply converted my v2 spec, and I didn't pay attention.
So reponses is actual the correct placement, so no real issue here, now that I look at it, it complains about the structure, which I will try to fix as well.
Worth mentioning, my initial assumption was right on this (wrong placement). The type of object you create for the response, is in fact a Schema object, have a look at
https://swagger.io/specification/#componentsObject
There is a Response object defined, but has a different structure.
Doesn't look like the spec has changed for this
So for a final change to make the ref paths generated correctly for v3, which the latest J::V release makes possible by overriding generate_definitions_path() in JSON::Validator::OpenAPI::Mojolicious
Im not quite what the right approach could be, both works for all tests; first one takes version into account, so no changes for version 2:
https://gist.github.com/HEM42/2f4d9cfbc67d451d0c543bb95a0bacc0
Second approach, handles both v2 and v3 in a similar fashion:
https://gist.github.com/HEM42/986d0ce0bf81a879c4e1cf3120b2c3ff
If one of these approaches can be agreed upon, Ill happy make the PR for it :)
Hi,
I noticed that the generated spec generates validation errors on editor.swagger.io, using your own example converted to OpenAPIv3, see code at the end
There is multiple problems, A few i would be able to submit a PR on :
Definitions belongs under {components}{schemas}, not responses. Also swagger.io complains about the extra basePath and host in the spec
But the last issue here, I was not able to fix, and I hope you can assist on this.
The default responses, even if the ref is added correctly at line 83 in lib/Mojolicious/Plugin/OpenAPI.pm
tie %schema, 'JSON::Validator::Ref', $ref, $schema{'$ref'}, $schema{'$ref'};
Its still rendered as following, under definitions:, which dont belong in v3 spec
Following is the code used