swagger-api / swagger-api/swagger-codegen
Java Codegen Problem
@HugoMario is already working on this.
Since Dec 23, 2020.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Wrong/different types in Java/C# for "type" : "string","format" : "binary" declarations
When we define something like this to transfer binary data we could do it like this:
"transferData" : {
"description" : "Any data to be exchanged between callers and callees.",
"type" : "string",
"format" : "base64"
}
The generated code for this is correct for both, C# and Java (both String). – Perfect!
But if we define the following:
"deviceData" : {
"type" : "string",
"format" : "binary"
}
The generated code for C# is correct (public byte[] DeviceData { get; set; }), but for Java a File type is generated (private File deviceData = null;) which is definitely not the intention behind ‘binary’.
3.0.21
The SwaggerHub CodeGen feature for 'java' and 'csharp' were used.
The problematic definition:
"RequestData" : {
"description" : "Data to be passed with directive calls.",
"type" : "object",
"properties" : {
"deviceData" : {
"type" : "string",
"format" : "binary"
}
}
}
creates this Java code:
public class RequestData {
@SerializedName("deviceData")
private File deviceData = null;
public RequestData deviceData(File deviceData) {
this.deviceData = deviceData;
return this;
}
...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.