swagger-api / swagger-api/swagger-codegen
[JAVA] Serialization of parts of multipart request bodies
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I am using the Swagger Codegen to generate a JAVA client to request a Spring Boot API.
This API provides a POST web service which takes a JSON parameter "dto" as a part of multipart/form-data.
I am using the "encoding" attribute in the swagger declaration but the client does not seem to use it.
The parameter is not serialized to JSON but is sent as the string representation of the class.
Swagger-codegen version
swagger-codegen-cli-3.0.5-20190130.172841-36.jar
Swagger declaration file content or url
Open API v3.0.2
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"properties": {
"dto": {
"$ref": "#/components/schemas/PushConfigurationDto"
}
}
},
"encoding": {
"dto": {
"contentType": "application/json"
}
}
}
}
}
This case corresponds to the "Complex Serialization in Form Data" example described into this documentation.
Command line used for generation
java -jar swagger-codegen-cli-3.0.5-20190130.172841-36.jar generate -i http://192.168.5.159:8080/openApi -l java -o ./java_api_client
Suggest a fix/enhancement
Is there a solution to make the client serializing multiparts other than String?
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 with the supplied OpenAPI 3.0.2 multipart/form-data declaration and the Java generation command, then inspect the generated client's multipart parameter handling. Confirm how the dto part is serialized and verify that it is sent as application/json rather than the class's string representation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100