swagger-api/swagger-codegen

Swagger Code Generation. Help!

Open

#2 502 ouverte le 5 avr. 2016

Voir sur GitHub
 (16 commentaires) (0 réactions) (0 assignés)HTML (5 474 forks)batch import
Enhancement: FeatureServer: Javahelp wanted

Métriques du dépôt

Stars
 (12 701 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

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;

  }


              ...
              ...

Guide contributeur