-
Notifications
You must be signed in to change notification settings - Fork 71
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
did validate_spec swagger schema agnostic #62
Conversation
@@ -57,7 +57,9 @@ def validate_spec_url(spec_url): | |||
return validate_spec(load_json(spec_url), spec_url) | |||
|
|||
|
|||
def validate_spec(spec_dict, spec_url='', http_handlers=None): | |||
def validate_spec(spec_dict, spec_url='', http_handlers=None, |
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.
Maybe it makes more sense to provide a higher-level abstraction? Several possibilities come to mind, e.g. either passing in an arbitrary filesystem path, a file object from which we read or just the schema as JSON string. I wouldn't expose the internal python package
+ relative_path
way of loading it as our API.
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 think this makes much more sense, please fix the small docstring issues and we can merge this in!
@@ -69,6 +70,8 @@ def validate_spec(spec_dict, spec_url='', http_handlers=None): | |||
http client built into jsonschema's RefResolver is used. This | |||
is a mapping from uri scheme to a callable that takes a | |||
uri. | |||
:param schema_pkg: package of the json schema file. | |||
:param schema_path: package relative path of the json schema file. |
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.
These don't exist anymore. Please instead add a line documenting what schema_dict
is supposed to be.
"""Validate a json document against a json schema. | ||
|
||
:param spec_dict: json document in the form of a list or dict. | ||
:param schema_pkg: package of the json schema file. |
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.
This is obsolete as well.
1 similar comment
I have my own Swagger Schema Extension (with oneOf and anyOf support) and I need this changes to use my schema to validate under yours API.
@sjaensch Can you take a look in my PR? I had rebased it with the base branch. |
19c7d4f
to
6f13288
Compare
- did 'validate_apis' and 'validate_definitions' overwritable on 'validate_spec' function - renamed the parameter 'http_handlers' to 'custom_handlers' (it can be used for non-http handlers as well) and added a deprecation message on docs - added the 'apis_getter' and 'definitions_getter' parameters to 'validate_spec' function. These parameters can be used to customize how the apis and definitions objects are got
@sjaensch Can you take a look on my PR? |
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.
While this does seem to broaden the scope of swagger_spec_validator quite a bit, the additions seem constrained enough that I'm not too worried about it. But you didn't add any tests for the new API, are you sure you want me to merge it in like this? People might break your API, and we won't know / can't prevent it.
@sjaensch I tried to not broke the old api and tried to do it compatible. I just moved some functions to the args, so I can override this functions with another one. The functionally remains the same, because of this no extra tests are needed. I will check again for api breaks, but I think it is ok to merge. |
I thought about it and I understood your points better. |
I have my own Swagger Schema Extension (with oneOf and anyOf support) and I need this changes to use my schema to validate under yours API.