manchenkoff / openapi3-parser

OpenAPI 3 parser to use a specification inside of the code in your projects
https://pypi.org/project/openapi3-parser/
MIT License
64 stars 33 forks source link

[BUG] `nullable` enums do not add `null` to the enum list #74

Closed Pizzaface closed 11 months ago

Pizzaface commented 11 months ago

Describe the bug When adding a nullable enum Schema, the operation will fail unless null is directly provided in the enum list. This is because nullable is not processed before the schema is validated and not having null in the values causes an error.

The error is similar to:

openapi_parser.errors.ParserError: OpenAPI validation error: 
("None is not one of ['asc', 'desc']", 'enum', deque([]), None, [], ['asc', 'desc'], None, {'type': 'string', 'nullable': True, 'default': None, 'enum': ['asc', 'desc']}, deque(['enum']), None)

To Reproduce Steps to reproduce the behavior:

  1. Create an endpoint with a nullable string parameter.
  2. Do not include null in the enum values
  3. Attempt to parse the spec

Expected behavior When adding a nullable field - the property should have null automatically added to the enum list - with the default being null if not supplied while allowing a set value.

System details (please complete the following information):

manchenkoff commented 11 months ago

Hey @Pizzaface, this error is coming from prance package since I do not have any validation for enums. Could you please check if some newer version works with that? If yes, I could upgrade the dependency, but if not, please open the issue in the related repo - Prance

Pizzaface commented 11 months ago

Whoops! Sorry about that - appreciate the quick response. Will open an issue there. Cheers!

Pizzaface commented 11 months ago

Bug opened on the prance repo for those who find this issue:

Bug

manchenkoff commented 11 months ago

I'm closing this issue for now, feel free to raise a new one once new version of dependency should be used