swagger-api / swagger-api/swagger-codegen
Swagger Code Generation. Help!
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Hello All,
I created a swagger document using the swagger editor http://editor.swagger.io and specified that each of the service supports both xml and json formats (including the base path section).
"consumes": [
"application/json",
"application/xml"
],
"produces": [
"application/json",
"application/xml"
I then generated the jaxrs code using the following command:
java -jar swagger-codegen-cli-2.1.4.jar generate -i my.json -l jaxrs -o /path/output/ -c /config.json
All the source files were created properly except that the java sources that were generated under the models folder didn't have the required @XmlElement tags to support "application/xml" message generation. JSON works just fine but I also need to support XML at the same time.
Is there a way to generate the model files with the @XmlElement tags aside from adding them manually?
Please help!
import io.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty;
@ApiModel(description = "Standard response object.")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JaxRSServerCodegen", date = "2016-04-05T14:44:12.314-07:00")
public class Response {
private String requestID = null;
private String statusCode = null;
private String statusMessage = null;
@JsonProperty("RequestID")
public String getRequestID() {
return requestID;
}
public void setRequestID(String requestID) {
this.requestID = requestID;
}
...
...
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 JAX-RS model sources generated under the models folder and the config.json used by swagger-codegen-cli 2.1.4. Trace how the consumes and produces settings reach the model templates, then verify that XML generation produces the required @XmlElement annotations without breaking JSON output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100