Closed le-garff-yoann closed 6 years ago
Is this still an issue? I can't seem to reproduce it myself with...
Unfortunately, it's still the case even with the latest version of JSON::Validator
.
The whole thing run on the official Vagrant image of Debian 8.1 with perlbrew perl 5.26.1. The directory of my testing app (https://github.com/le-garff-yoann/mojolicious-plugin-openapi-issue-62) is located on /tmp
. I start it as root.
I could test it with a different Vagrant image but because i use perlbrew i doubt that it will change anything.
How does the $app->plugin(OpenAPI => ...)
line look like?
It's the same with another image (centos 7).
I use this app (https://github.com/le-garff-yoann/mojolicious-plugin-openapi-issue-62) for the testing relative to this issue. So the line for $app->plugin(OpenAPI => ...)
is https://github.com/le-garff-yoann/mojolicious-plugin-openapi-issue-62/blob/master/lib/TApp.pm#L12.
This is now fixed in JSON::Validator 2.03.
https://github.com/jhthorsen/json-validator/commit/990bce645604a2ea9f4a43f3eb419bcdbbd58b3f
The commit message is pretty bad, since the commit also contains moving bundled refs into the "x-bundled" key, instead of using "definitions".
I gather from @jhthorsen that the problem described here is connected to https://github.com/jhthorsen/json-validator/issues/98, in that the solution in the above-mentioned commit also solves this. I put this here for a link since it took me 15 minutes to find this again!
Also, I do not see in that commit any test that reproduces the problem reported here, which is that bundle
can return a spec that fails to validate
. I will add such a test since that seems important.
I think the reason the commit mentioned above "worked" is because the following is what was happening:
responses
definition of errors
default
entry that $ref
to thatdefinitions
- hence the long, funky definition name. This is fixed properly in https://github.com/jhthorsen/json-validator/pull/100 since the reason this failed was @le-garff-yoann 's app->home->child('share', 't-app.json')
will have had the same recognition problem, that there was a ..
in the path which was normalised but that normalised version was not used for recognition.responses
spec is different from what is valid for a definitions
specx-bundled
masked this problem by effectively sidestepping all validation, though maybe the entities will get validated when referred to?The test that links to this issue I first checked failed before the above commit, and should avoid any recurrence going forwards.
With the last version of this plugin /
JSON::Validator
.For exemple, this spec (https://github.com/le-garff-yoann/mojolicious-plugin-openapi-issue-62/blob/master/share/t-app.json) is rendered on the
basePath
as:This rendered spec isn't valid if you try to load it with
OpenAPI::Client
- http://editor.swagger.io -http://bigstickcarpet.com/swagger-parser/www/index.html (while the original one is).N.B:
definitions
object in the original spec.response
object and the reference to it seems valid to me (allow_invalid_ref
set to true generate a valid spec but... https://stackoverflow.com/a/31252530).JSON::Validator
(cpanm JSON::Validator@1.00 Mojolicious::Plugin::OpenAPI@1.21
).response
object is removed and replaced with adefinition
equivalent).I cannot tell if:
JSON::Validator
.