We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I have in an external projects some problems with the openapi-spec-validator.
In our project, we happen to generate an property that either has a value from an enum, or can be null.
enum
null.
See: master...kazie:openapi-spec-validator:test/test-with-enum-string-or-null-property
I would believe this is valid OpenAPI specification for a field, but the validation fails, as from this project fork when running test:
openapi_spec_validator/shortcuts.py:48: in validate return v.validate() base_uri = 'file:///home/kazie/src/github/openapi-spec-validator/tests/integration/data/v3.1/petstore.yaml' cls = <class 'openapi_spec_validator.validation.validators.OpenAPIV31SpecValidator'> sp = SchemaPath('') spec = {'components': {'pathItems': {'PetPath': {'get': {'operationId': 'showPetById', 'parameters': [{...}], 'responses': {'...r'}}, 'summary': 'Create a pet', 'tags': ['pets']}}, '/pets/{petId}': {'$ref': '#/components/pathItems/PetPath'}}, ...} v = <openapi_spec_validator.validation.validators.OpenAPIV31SpecValidator object at 0x782454500440> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <openapi_spec_validator.validation.validators.OpenAPIV31SpecValidator object at 0x782454500440> def validate(self) -> None: for err in self.iter_errors(): > raise err E openapi_spec_validator.validation.exceptions.OpenAPIValidationError: None is not one of ['ALIVE', 'DEAD'] E E Failed validating 'enum' in schema: E {'default': None, E 'description': 'The status of the pet. `null` if current status can ' E 'not be confirmed.', E 'enum': ['ALIVE', 'DEAD'], E 'example': 'ALIVE', E 'type': ['string', 'null']} E E On instance: E None err = <OpenAPIValidationError: "None is not one of ['ALIVE', 'DEAD']"> self = <openapi_spec_validator.validation.validators.OpenAPIV31SpecValidator object at 0x782454500440> openapi_spec_validator/validation/validators.py:71: OpenAPIValidationError
It is true that None is not in the enum [ ALIVE, DEAD ], but it is in the type array as ['string', 'null']
None
[ ALIVE, DEAD ]
['string', 'null']
So, do you believe that my specification is just invalid, or do we have a bug on our hands in the validation here? 😅
I came to this when migrating from OpenAPI 3.0.3 where we migrate from having nullable: true into these type arrays.
OpenAPI 3.0.3
nullable: true
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have in an external projects some problems with the openapi-spec-validator.
In our project, we happen to generate an property that either has a value from an
enum
, or can benull.
See: master...kazie:openapi-spec-validator:test/test-with-enum-string-or-null-property
I would believe this is valid OpenAPI specification for a field, but the validation fails, as from this project fork when running test:
It is true that
None
is not in the enum[ ALIVE, DEAD ]
, but it is in the type array as['string', 'null']
So, do you believe that my specification is just invalid, or do we have a bug on our hands in the validation here? 😅
I came to this when migrating from
OpenAPI 3.0.3
where we migrate from havingnullable: true
into these type arrays.The text was updated successfully, but these errors were encountered: