You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working in a Java environment. Java projects build the model and the libraries by connection/client type (feign, retrofit2, etc) with Swagger Codegen.
In any case, I have an API Rest service with a file field defined in the following way:
"type": "string",
"format": "byte"
The generated libraries have the corresponding model class with file field type byte[] but the same field in the Rest service class is generated with string type. This generates a casting error because the generated client doesn’t know how to convert a Base64 string to a byte[].
The retrofit2 library generates a JSON.java file with date adapters but ByteArrayAdapter is not added.
Description
I am working in a Java environment. Java projects build the model and the libraries by connection/client type (feign, retrofit2, etc) with Swagger Codegen.
In any case, I have an API Rest service with a file field defined in the following way:
"type": "string",
"format": "byte"
The generated libraries have the corresponding model class with file field type byte[] but the same field in the Rest service class is generated with string type. This generates a casting error because the generated client doesn’t know how to convert a Base64 string to a byte[].
The retrofit2 library generates a JSON.java file with date adapters but ByteArrayAdapter is not added.
Swagger-codegen version
2.4.7
Swagger declaration file content or url
Command line used for generation
Related issues/PRs
Similar issue for Java: #4824
Similar issue for C#: #7875
Suggest a fix/enhancement
// Register our new ByterArray type adapter
gsonBuilder.registerTypeAdapter(byte[].class, new ByteArrayAdapter(client));
The text was updated successfully, but these errors were encountered: