Open its-hammer-time opened 2 weeks ago
I tried adding a deserializers for the mimetype, but it's complaining that it's no longer "binary".
def deserialize_pdf(value: bytes) -> str:
return value.decode("utf-8")
open_api_config: Config = Config(
extra_media_type_deserializers={
"application/pdf": deserialize_pdf,
}
)
open_api_spec = OpenAPI.from_dict({ ... }, config=open_api_config)
If it's binary
the library complains that it's not a 'string' and if it's a string
it complains that it's not 'binary'
Hi @its-hammer-time
thanks for the report. it's a known issue that will requires breaking change #647
After further investigation the problem exist with Openapi 3.1.
If you change to openapi 3.0.3 it works 🤔
Actual Behavior
I hacked together the code below so that I could test this library in isolation, but for context we are using it inside of a Pyramid app. When I run the case below, I get the following exception:
If I then try to wrap it inside of a
str()
, I getis not of type 'binary'
so I believe there is an issue with the formatter understanding the bytes as a string.Expected Behavior
If I return a binary object (pdf file) it should pass validation.
Steps to Reproduce
OpenAPI Core Version
0.19.1
OpenAPI Core Integration
Natively using openapi-core
Affected Area(s)
Validation
References
No response
Anything else we need to know?
No response
Would you like to implement a fix?
None