swagger-api/swagger-codegen

Swagger Code Generation. Help!

Open

#2,502 opened on Apr 5, 2016

View on GitHub
 (16 comments) (0 reactions) (0 assignees)HTML (12,701 stars) (5,474 forks)batch import
Enhancement: FeatureServer: Javahelp wanted

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

Swagger Code Generation. Help! · swagger-api/swagger-codegen#2502 | Good First Issue