-
Notifications
You must be signed in to change notification settings - Fork 71
Python3 support #11
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
Python3 support #11
Conversation
83a4152
to
1373f65
Compare
I believe I've fixed the bug in jsonschema, I'm going to submit a PR |
Opened python-jsonschema/jsonschema#201, let's see if we get a response. For now we could just mark these failing tests as "broken on py3" so they get skipped |
resolver = RefResolver( | ||
'file://{0}'.format(schema_path), | ||
schema, | ||
store={'http://swagger.io/v2/schema.json': schema}) |
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.
How will the store mapping help? Also, the schema
could either be 1.2
or a 2.0
.
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.
Oops, this should be store=schema['id']
I believe it should avoid a network call. The way refs are looked up, they use urljoin(current_scope, json_pointer)
where json_pointer is some #/path/to/
ref. If anything uses the absolute path to the schema, it would cause a network call.
I guess this might not happen very often in practice. It might have been triggered by the bug that is being fixed in jsonschema
under python 3.
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.
But the key id
is not always present in the schema (it is present in 2.0 schema but not in api_declaration
and resource_listing
schema of 1.2).
Also, from signature of RefResolver
, store
takes a dict
(id
would be a str
).
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.
sorry, I meant store={schema['id']: schema}
This should already be covered by tests. I'll double check that it works with 1.2.
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.
Thinking about this again api_declaration
and resource_listing
aren't valid jsonschema, which is why they don't have id
. They're being used as the "json object" being validated against the swagger spec schema.
I can change this to schema.get('id')
just to be safe.
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'll just revert this part of it. It's not really important. We can revisit it if we ever hit this case (of things using absolute urls).
lgtm. Ship it may be after the python-jsonschema/jsonschema#203 merge? |
swagger_spec_validator. This commit only covers validation of swagger 2.0 spec and in no way handles serving of 2.0 compatible endpoint. It currently breaks py33 and py34 tests. This should be rectified with the merge of Yelp/swagger_spec_validator#11.
swagger_spec_validator. This commit only covers validation of swagger 2.0 spec and in no way handles serving of 2.0 compatible endpoint. It currently breaks py33 and py34 tests. This should be rectified with the merge of Yelp/swagger_spec_validator#11.
…python3 Conflicts: swagger_spec_validator/__about__.py
A new release of |
Ya, we can try that. Right now we're just installing any unpinned version. I don't think We'll have to pin the same version in the pyramid_swagger testsuite if we want to use it there as well. |
Ok, tests pass with pinned version of jsonschema. Look good? |
yeah lgtm. |
Related to #10
There are definition still some test flakes here, but they magically stopped happening locally so I decided to open this PR for now.
The error was:
which is strange because
simpleTypes
doesn't appear anywhere in this repo, but it does exist injsonschema/schemas/draft4.json
.