Description
With springdoc-openapi-starter-common:2.0.4 and newer, generating an OpenAPI spec from a value object containing a byte array field, e.g:
@Schema(description = "foo")
byte[] content;
will generate an OpenAPI specification, in which the description of the field is missing:
content:
type: string
format: byte
If I generate the specification from the same model class with version 2.0.2, the following spec comes out:
content:
type: array
description: foo
items:
type: string
description: foo
format: byte
Here, the description is present, although the data type is incorrectly specified. There have been a lot of bugs reported against both Springdoc as well as Swagger with the data type issue. Probably something went wrong with the bugfix. It is BTW also no more possible to overwrite the type and format fields with the corresponding values in the Schema annotation. The required value in the Schema annotation seem however still to be evaluated.
I am honestly not sure which project (Springdoc or Swagger) might be responsible for this issue, but I assume that it actually is some issue in Springdoc. The reason is:
- using Springdoc 2.0.4 and Swagger-Core downgraded to version 2.0.7, the description is missing and the data type is correctly specified
- using Springdoc 2.0.2 and Swagger-Core 2.0.7 (as used by Springdoc 2.0.2), the description is present, but the the data type is incorrectly specified
When using Springdoc 2.0.2, it is at least possible to specify the correct type and format in the Schema annotation:
@Schema(description = "foo", type = "string", format = "byte")
byte[] content = {};
... in which case the correct spec is generated:
content:
type: string
description: foo
format: byte