swagger-api/swagger-codegen

Swagger Code Generation. Help!

Open

#2.502 geöffnet am 5. Apr. 2016

Auf GitHub ansehen
 (16 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)HTML (5.474 Forks)batch import
Enhancement: FeatureServer: Javahelp wanted

Repository-Metriken

Stars
 (12.701 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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