Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork70
Description
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 anenum
, 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:
openapi_spec_validator/shortcuts.py:48:invalidatereturnv.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.OpenAPIV31SpecValidatorobjectat0x782454500440>__ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _self=<openapi_spec_validator.validation.validators.OpenAPIV31SpecValidatorobjectat0x782454500440>defvalidate(self)->None:forerrinself.iter_errors():>raiseerrEopenapi_spec_validator.validation.exceptions.OpenAPIValidationError:Noneisnotoneof ['ALIVE','DEAD']EEFailedvalidating'enum'inschema: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']}EEOninstance:ENoneerr=<OpenAPIValidationError:"None is not one of ['ALIVE', 'DEAD']">self=<openapi_spec_validator.validation.validators.OpenAPIV31SpecValidatorobjectat0x782454500440>openapi_spec_validator/validation/validators.py:71:OpenAPIValidationError
It is true thatNone
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 fromOpenAPI 3.0.3
where we migrate from havingnullable: true
into these type arrays.