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

[Feature] Support more media types for images #78

Closed rtyping closed 10 months ago

rtyping commented 10 months ago

What is a problem? OpenApi specification describes the ContentType as:

The Content-Type for encoding a specific property. Default value depends on the property type: for string with format being binary – application/octet-stream; for other primitive types – text/plain; for object - application/json; for array – the default is defined based on the inner type. The value can be a specific media type (e.g. application/json), a wildcard media type (e.g. image/*), or a comma-separated list of the two types.

precisely *a wildcard media type (e.g. image/)**

Openapi3-parser support only one image type: image/png

Describe the solution you'd like Openapi3-parser is able to parse Content type with various types of images, for example image/jpeg and others

Describe alternatives you've considered

Additional context https://spec.openapis.org/oas/v3.0.3#fixed-fields-12

manchenkoff commented 10 months ago

Hi @rtyping, there is a possibility to disable strict content-type checks with parse() function calls by passing strict_enum=False as an argument. It will allow you to use any Content-Type you want, even if it is not officially registered as a media type. However, I will extend the current enum with a few more values for images.

rtyping commented 8 months ago

Thank you very much for the correction. The strict_enum flag is also useful. Have a good day!