-
-
Notifications
You must be signed in to change notification settings - Fork 762
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
Drop openapi-spec-validator for custom ref handler #1455
Conversation
3310da9
to
38afecc
Compare
Pull Request Test Coverage Report for Build 1877457959
💛 - Coveralls |
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.
Thanks, Robbe! Think we just need to adjust the tests for this?
|
||
from .utils import deep_get | ||
|
||
|
||
class ExtendedSafeLoader(yaml.SafeLoader): | ||
"""Extends the yaml SafeLoader to coerce all keys to string so the result is valid 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.
Why do we need to do this? Shouldn't the loaded file be json as well if it adheres to OpenAPI? Perhaps I'm simply overlooking something.
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.
The loaded file can be a yaml
file as well, which allows integer keys. According to the OpenAPI spec, keys should indeed be strings so the yaml
is a representation of valid json
, and we shouldn't need this. However openapi-spec-validator
allowed this, and I tried to provide a drop-in replacement so kept the same behavior.
We could mark this for deprecation in the next major version though.
@@ -42,7 +42,8 @@ paths: | |||
content: | |||
application/json: | |||
schema: | |||
$ref: "#/components/schemas/Pet" | |||
$ref: "file:///home/robbe/workspace/oss/connexion/examples/openapi3/methodresolver/openapi/test.json#/components/schemas/Pet" | |||
# $ref: "http://0.0.0.0:8000/test.yaml#/components/schemas/Pet" |
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.
Can we add a separate test for this and change this back to the original value?
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.
Woops, this is leftover from my local testing.
I'll remove this and add a separate test.
Strange that this doesn't fail in the Github pipeline though.
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.
Ok, so this didn't break because this is an example, not a test 😅
It's unfortunately not straightforward to add a test, sine only absolute paths are supported (#254). So I would propose to merge without unless you have an idea on how to do it?
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.
Agreed, I don't see a good way of adding a test for this, so I would merge without it.
38afecc
to
20b396c
Compare
20b396c
to
b762a9a
Compare
Fixes #930
Continues on #936
This PR completely removes the dependency on
openapi-spec-validator
. There's multiple reasons to do this:openapi-spec-validator
for it's main purpose, but for utility functionality