I'm migrating my API from Swagger 2.0 to OpenAPI 3.0. In a DTO I have a field specified as a byte array. Swagger definition of the DTO:
Job:
type: object
properties:
body:
type: string
format: binary
Using the definition above the swagger code generator generates an object that accepts byte[]
array as the body field new Job().setBody(new byte[1])
.
After converting the API definition to OpenAPI the definition for that object stayed the same but the openapi code generator now requires org.springframework.core.io.Resource
instead of byte[]
(new Job().setBody(org.springframework.core.io.Resource)
). There are some places in my code where I have to serialize the Job object but it's no longer possible because Resource
doesn't implement serializable.
As a workaround I changed the type to object
:
Job:
type: object
properties:
body:
type: object
Now I have to cast the body to String
and then convert to byte[]
everywhere and I'd rather have the type as byte[]
as it was before.
How can I specify the type as byte[]
using OpenAPI 3.0?