Skip to content
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

p1c2u/openapi-core#296: Implements OpenAPI 3.1 spec validator #128

Closed
wants to merge 0 commits into from

Conversation

nezhar
Copy link
Contributor

@nezhar nezhar commented Aug 13, 2021

As mentioned in python-openapi/openapi-schema-validator#18 this is the extension for OpenAPI 3.1.

It is created as draft as it install jsonschema and openapi-schema-validator via GitHub in order to use the latest changes for Draft 2020-12.

The test cases provided in https://github.com/OAI/OpenAPI-Specification/tree/main/tests/v3.1 are used for the implementation.

Python 2.7 and 3.5 have been removed from the test matrix as they are end of life.

I'm open for sugestions if any changes are required in the PR.

@codecov
Copy link

codecov bot commented Aug 16, 2021

Codecov Report

Merging #128 (f9b3ba1) into master (f8645de) will increase coverage by 0.34%.
The diff coverage is 100.00%.

❗ Current head f9b3ba1 differs from pull request most recent head fb0c8ce. Consider uploading reports for the commit fb0c8ce to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #128      +/-   ##
==========================================
+ Coverage   98.14%   98.49%   +0.34%     
==========================================
  Files          19       19              
  Lines         538      530       -8     
==========================================
- Hits          528      522       -6     
+ Misses         10        8       -2     
Impacted Files Coverage Δ
openapi_spec_validator/__init__.py 100.00% <100.00%> (ø)
openapi_spec_validator/factories.py 100.00% <100.00%> (ø)
openapi_spec_validator/readers.py 100.00% <100.00%> (ø)
openapi_spec_validator/validators.py 99.08% <100.00%> (+<0.01%) ⬆️
openapi_spec_validator/__main__.py 97.05% <0.00%> (+2.82%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 766732b...fb0c8ce. Read the comment docs.

@nezhar
Copy link
Contributor Author

nezhar commented Aug 30, 2021

The PR has been updated to also use the 4.0.0a6 release of jsonschema and support for python 3.6 has been dropped.

@p1c2u
Copy link
Collaborator

p1c2u commented Aug 31, 2021

One thing I noticed it's ValueValidator uses OAS30Validator and oas30_format_checker

@nezhar
Copy link
Contributor Author

nezhar commented Sep 1, 2021

One thing I noticed it's ValueValidator uses OAS30Validator and oas30_format_checker

Fixed 🙂

@tschmidtb51
Copy link

@nezhar What is the current status?

@nezhar
Copy link
Contributor Author

nezhar commented Oct 23, 2021

@nezhar What is the current status?

This PR is currently waiting for python-openapi/openapi-schema-validator#18 to be resolved

requirements.txt Outdated Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
@nezhar nezhar marked this pull request as ready for review November 3, 2021 16:35
@warmwaffles
Copy link

@p1c2u any chance of getting this merged?

@tschmidtb51
Copy link

@p1c2u Could you please add your review?

@nezhar nezhar force-pushed the master branch 3 times, most recently from ed6a750 to e905ee0 Compare January 11, 2022 15:57
@tschmidtb51
Copy link

@p1c2u This is now based on openapi-schema-validator>=0.3.0a1. Could you please add your review?

@p1c2u
Copy link
Collaborator

p1c2u commented Jan 19, 2022

Version 3.1 is missing as an option in command line parser (see __main__.py)

@p1c2u
Copy link
Collaborator

p1c2u commented Jan 19, 2022

Also need to add information about versions to the README file

@p1c2u
Copy link
Collaborator

p1c2u commented Jan 19, 2022

Python 2.7 and 3.5 support drop can be extracted to separate commit/PR (which is #137)

@nezhar
Copy link
Contributor Author

nezhar commented Jan 25, 2022

This PR needs to be rebased after #137 is resolved

@nezhar nezhar force-pushed the master branch 3 times, most recently from 9727d9f to fb0c8ce Compare January 25, 2022 13:56
pyproject.toml Outdated Show resolved Hide resolved
@p1c2u
Copy link
Collaborator

p1c2u commented Jan 28, 2022

@nezhar
Couldn't push rebased changes to your branch so I created new branch #143

@@ -339,10 +341,10 @@ def __init__(self, dereferencer):

@wraps_errors
def iter_errors(self, schema, value):
validator = OAS30Validator(
validator = OAS31Validator(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be dependent of which spec we use? Otherwise we will use OAS31Validator for all specs? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I will look into this, create a test case and cover it in a dedicated PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't really have any information about the spec at this step. I would sugest that we add The validator class and the format checker instance as two additional configuration parameters to the SpecValidator

openapi_v30_spec_validator = SpecValidator(
    openapi_v30_validator_factory,
    resolver_handlers=default_handlers,
    validator_class=OAS30Validator,
    format_checker=oas30_format_checker
)

This also means they need to be propagated on each new validator class. What are your thoughts about this or do you have any other suggestions?

schema,
resolver=self.dereferencer.resolver_manager.resolver,
format_checker=oas30_format_checker,
format_checker=oas31_format_checker,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Shouldn't this be dependent of which spec we use? Otherwise we will use OAS31Validator for all specs? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants