swagger-api / swagger-api/swagger-codegen
[JAVA] Binary data is not generated
Open
Nobody has claimed this yet.
Issue: Bug
Swagger-Parser
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
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
Suggest a Fix
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 Java client generation with the Swagger JSON shown, then trace how the generator handles the string schema with format binary and the $ref to BinaryData. Done means the generated BinaryData class includes the binary content representation and the example is covered by regression testing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100