Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenApi documentation converts byte[] in array of byte[] #81

Open
andrei-ion opened this issue Jun 4, 2021 · 3 comments
Open

OpenApi documentation converts byte[] in array of byte[] #81

andrei-ion opened this issue Jun 4, 2021 · 3 comments

Comments

@andrei-ion
Copy link

Describe the bug
I generate a java class from a yaml file describing the model.

I have the following model described in the yaml file:

Document:
required:
- documentMetaData
- documentContent
type: "object"
properties:
documentMetaData:
$ref: "#/definitions/DocumentMetaData"
description: "Document type information"
documentContent:
type: string
format: byte
description: "Base64 encoded document content"

This generates the following class which is ok:

public class DownloadDocument {
@JsonProperty("documentMetaData")
private DocumentMetaData documentMetaData;

@JsonProperty("documentContent")
private byte[] documentContent;

But when entering the swagger-ui.html page and trying to get the documentation by click on the link:

image

it looks like this:

"DownloadDocument": {
"required": [
"documentContent",
"documentMetaData"
],
"type": "object",
"properties": {
"documentMetaData": {
"$ref": "#/components/schemas/DocumentMetaData"
},
"documentContent": {
"type": "array",
"items": {
"type": "string",
"format": "byte"
}

}
The document content which is a byte[] is documented as an array of byte[] and when using this description in other app to generate an api client it generates a List<byte[]>.

I would expect the following format also in the OpenApi Specification:
"documentContent": {
"type": "string",
"format": "byte"
}**

Can you please advice if this is a bug or if not how can be resolved?

@andrei-ion
Copy link
Author

I am using the following versions:
<springdoc-openapi-ui.version>1.5.9</springdoc-openapi-ui.version>
<swagger-annotations.version>1.5.22</swagger-annotations.version> and
openapi-generator-maven-plugin
4.3.1

@langecode
Copy link
Member

langecode commented Jun 4, 2021 via email

@andrei-ion
Copy link
Author

Hi,
yes the swagger-maven-plugin works as expected and generated the model in the right way:

as

private byte[] documentContent;

but when entering the swagger-ui page and trying to get the api description the field is described as:

"documentContent": { "type": "array", "items": { "type": "string", "format": "byte" } },

And some other apps are using this json definition to generate a client to reach our API.
And because the field is wrong described the plugin generates the following model

List<byte[]> documentContent;

which is not what our API is exposing....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants