swagger-api / swagger-api/swagger-parser
Binary data is not generated
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 867
- Forks
- 560
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 7
Description
Description
We have something like that in our swagger json file:
definitions {
...
"BinaryData": {
"format": "binary",
"type": "string"
}
...
}
...
"/test": {
"get": {
"responses": {
"200": {
"schema": {
"$ref": "#/definitions/BinaryData"
}
}
}
}
}
The generated Java class is the following:
public class BinaryData {
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return true;
}
@Override
public int hashCode() {
return Objects.hash();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class BinaryData {\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
As you can see, the content is missing.
Swagger-codegen version
2.2.2
Steps to reproduce
- Create swagger file like the examples above
- Generate java client
Related issues
See https://github.com/swagger-api/swagger-codegen/issues/5083
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.
Research direction
Start by reproducing the supplied swagger JSON with swagger-codegen 2.2.2 and inspect how the BinaryData schema is represented during Java client generation. Compare the generated class with the schema's string/binary content, and use related issue 5083 for context. Done means the generated Java model preserves the binary data instead of producing an empty class.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100