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

Detect swagger vs openapi and auto-select appropriate backend #133

Open
jayvdb opened this issue Sep 5, 2022 · 0 comments
Open

Detect swagger vs openapi and auto-select appropriate backend #133

jayvdb opened this issue Sep 5, 2022 · 0 comments

Comments

@jayvdb
Copy link

jayvdb commented Sep 5, 2022

Expected Behaviour

When flex is installed, it should not be the default unless the input document is swagger.

Minimal Example Spec

n/a

Actual Behaviour

When flex is installed, prance validate my_openapi3.yaml will emit

prance validate my_openapi3.yaml 
Processing "my_openapi3.yaml"...
 -> Resolving external references.
ERROR in "my_openapi3.yaml" [ValidationError]: ErrorDict(<class 'flex.exceptions.ErrorList'>, {'required': [ErrorDict(<class 'flex.exceptions.ErrorList'>, {'swagger': ['This value is required']})]})

The {'swagger': ['This value is required']} in there is reasonably informative if you know/remember what flex is looking for.
But it isnt a great UX for people using openapi3, which is going to be an increasing percentage of users as openapi v3 replaces swagger.

The easiest approach is to re-organise the imports in

def validation_backends():
, so that openapi_spec_validator is first, and IMO flex should be last it has seen releases recently at https://pypi.org/project/flex/, while swagger_spec_validator is better maintained.

If there is some backwards compatibility reason for keeping flex first, it should be possible for it to only be first if the context is a swagger input.

Steps to Reproduce

  1. Install flex
  2. Run prance validate any_openapi3_schema.yaml

Environment

  • OS: Linux
  • Python version: 3.10
  • Swagger/OpenAPI version used: 3.0
  • Backend: flex
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

No branches or pull requests

1 participant