Merge pull request #2497 from swagger-api/issue-2496

sanitize tags, update generation timestamp
This commit is contained in:
Tony Tam 2016-04-05 07:40:11 -07:00
commit a1c978751a
47 changed files with 492 additions and 526 deletions

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java/default" ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -o samples/client/petstore/java/default -DhideGenerationTimestamp=true"
java $JAVA_OPTS -jar $executable $ags java $JAVA_OPTS -jar $executable $ags

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs-cxf -o samples/server/petstore/jaxrs-cxf" ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-cxf -o samples/server/petstore/jaxrs-cxf -DhideGenerationTimestamp=true"
java $JAVA_OPTS -jar $executable $ags java $JAVA_OPTS -jar $executable $ags

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jaxrs" ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jaxrs -DhideGenerationTimestamp=true"
java $JAVA_OPTS -jar $executable $ags java $JAVA_OPTS -jar $executable $ags

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs-resteasy -o samples/server/petstore/jaxrs-resteasy" ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-resteasy -o samples/server/petstore/jaxrs-resteasy -DhideGenerationTimestamp=true"
java $JAVA_OPTS -jar $executable $ags java $JAVA_OPTS -jar $executable $ags

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jersey2 --library=jersey2" ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jersey2 --library=jersey2 -DhideGenerationTimestamp=true"
java $JAVA_OPTS -jar $executable $ags java $JAVA_OPTS -jar $executable $ags

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l nodejs-server -o samples/server/petstore/nodejs" ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l nodejs-server -o samples/server/petstore/nodejs"
java $JAVA_OPTS -Dservice -jar $executable $ags java $JAVA_OPTS -Dservice -jar $executable $ags

View File

@ -42,6 +42,8 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
protected Boolean serializableModel = false; protected Boolean serializableModel = false;
protected boolean serializeBigDecimalAsString = false; protected boolean serializeBigDecimalAsString = false;
protected boolean useRxJava = false; protected boolean useRxJava = false;
protected boolean hideGenerationTimestamp = false;
public JavaClientCodegen() { public JavaClientCodegen() {
super(); super();
@ -99,6 +101,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
.SERIALIZE_BIG_DECIMAL_AS_STRING_DESC)); .SERIALIZE_BIG_DECIMAL_AS_STRING_DESC));
cliOptions.add(CliOption.newBoolean(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util")); cliOptions.add(CliOption.newBoolean(FULL_JAVA_UTIL, "whether to use fully qualified name for classes under java.util"));
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library.")); cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library."));
cliOptions.add(new CliOption("hideGenerationTimestamp", "hides the timestamp when files were generated"));
supportedLibraries.put(DEFAULT_LIBRARY, "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2"); supportedLibraries.put(DEFAULT_LIBRARY, "HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2");
supportedLibraries.put("feign", "HTTP client: Netflix Feign 8.1.1"); supportedLibraries.put("feign", "HTTP client: Netflix Feign 8.1.1");

View File

@ -7,8 +7,6 @@ import java.io.File;
import java.util.*; import java.util.*;
public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen { public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
boolean showGenerationTimestamp = false;
public JavaJerseyServerCodegen() { public JavaJerseyServerCodegen() {
super(); super();
@ -48,7 +46,6 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
cliOptions.add(library); cliOptions.add(library);
cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC)); cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));
cliOptions.add(new CliOption("title", "a title describing the application")); cliOptions.add(new CliOption("title", "a title describing the application"));
cliOptions.add(new CliOption("showGenerationTimestamp", "shows the timestamp when files were generated"));
} }
@Override @Override
@ -152,7 +149,7 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
co.baseName = basePath; co.baseName = basePath;
} }
public void showGenerationTimestamp(boolean showGenerationTimestamp) { public void hideGenerationTimestamp(boolean hideGenerationTimestamp) {
this.showGenerationTimestamp = showGenerationTimestamp; this.hideGenerationTimestamp = hideGenerationTimestamp;
} }
} }

View File

@ -278,7 +278,9 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
if(operation.getOperationId() == null) { if(operation.getOperationId() == null) {
operation.setOperationId(getOrGenerateOperationId(operation, pathname, method.toString())); operation.setOperationId(getOrGenerateOperationId(operation, pathname, method.toString()));
} }
operation.getVendorExtensions().put("x-swagger-router-controller", toApiName(tag)); if(operation.getVendorExtensions().get("x-swagger-router-controller") == null) {
operation.getVendorExtensions().put("x-swagger-router-controller", sanitizeTag(tag));
}
} }
} }
} }

View File

@ -1 +1 @@
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") {{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}

View File

@ -1 +1 @@
{{#showGenerationTimestamps}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/showGenerationTimestamps}} {{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}

View File

@ -1 +1 @@
{{#showGenerationTimestamps}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/showGenerationTimestamps}} {{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}}

View File

@ -1,11 +1,9 @@
package io.swagger.codegen.options; package io.swagger.codegen.options;
import io.swagger.codegen.Codegen; import com.google.common.collect.ImmutableMap;
import io.swagger.codegen.CodegenConstants; import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.JavaClientCodegen; import io.swagger.codegen.languages.JavaClientCodegen;
import com.google.common.collect.ImmutableMap;
import java.util.Map; import java.util.Map;
public class JavaOptionsProvider implements OptionsProvider { public class JavaOptionsProvider implements OptionsProvider {
@ -46,6 +44,7 @@ public class JavaOptionsProvider implements OptionsProvider {
.put(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, "true") .put(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, "true")
.put(JavaClientCodegen.USE_RX_JAVA, "false") .put(JavaClientCodegen.USE_RX_JAVA, "false")
.put(JavaClientCodegen.DATE_LIBRARY, "joda") .put(JavaClientCodegen.DATE_LIBRARY, "joda")
.put("hideGenerationTimestamp", "true")
.build(); .build();
} }

View File

@ -27,8 +27,7 @@ public class JaxRSServerOptionsProvider extends JavaOptionsProvider {
builder.putAll(options) builder.putAll(options)
.put(CodegenConstants.IMPL_FOLDER, IMPL_FOLDER_VALUE) .put(CodegenConstants.IMPL_FOLDER, IMPL_FOLDER_VALUE)
//.put(JavaJaxRSJersey1ServerCodegen.DATE_LIBRARY, "joda") //java.lang.IllegalArgumentException: Multiple entries with same key: dateLibrary=joda and dateLibrary=joda //.put(JavaJaxRSJersey1ServerCodegen.DATE_LIBRARY, "joda") //java.lang.IllegalArgumentException: Multiple entries with same key: dateLibrary=joda and dateLibrary=joda
.put("title", "Test title") .put("title", "Test title");
.put("showGenerationTimestamp", "true");
return builder.build(); return builder.build();
} }

View File

@ -3,7 +3,7 @@ package io.swagger.client;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class ApiException extends Exception { public class ApiException extends Exception {
private int code = 0; private int code = 0;
private Map<String, List<String>> responseHeaders = null; private Map<String, List<String>> responseHeaders = null;

View File

@ -1,6 +1,6 @@
package io.swagger.client; package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class Configuration { public class Configuration {
private static ApiClient defaultApiClient = new ApiClient(); private static ApiClient defaultApiClient = new ApiClient();

View File

@ -1,6 +1,6 @@
package io.swagger.client; package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class Pair { public class Pair {
private String name = ""; private String name = "";
private String value = ""; private String value = "";

View File

@ -1,6 +1,6 @@
package io.swagger.client; package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class StringUtil { public class StringUtil {
/** /**
* Check if the given array contains the given value (with case-insensitive comparison). * Check if the given array contains the given value (with case-insensitive comparison).

View File

@ -16,7 +16,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T16:01:11.428+08:00")
public class PetApi { public class PetApi {
private ApiClient apiClient; private ApiClient apiClient;
@ -294,7 +294,7 @@ public class PetApi {
}; };
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" };
GenericType<Pet> localVarReturnType = new GenericType<Pet>() {}; GenericType<Pet> localVarReturnType = new GenericType<Pet>() {};
@ -342,7 +342,7 @@ public class PetApi {
}; };
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" };
GenericType<InlineResponse200> localVarReturnType = new GenericType<InlineResponse200>() {}; GenericType<InlineResponse200> localVarReturnType = new GenericType<InlineResponse200>() {};
@ -390,7 +390,7 @@ public class PetApi {
}; };
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "petstore_auth", "api_key" }; String[] localVarAuthNames = new String[] { "api_key", "petstore_auth" };
GenericType<byte[]> localVarReturnType = new GenericType<byte[]>() {}; GenericType<byte[]> localVarReturnType = new GenericType<byte[]>() {};

View File

@ -14,7 +14,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T16:01:11.428+08:00")
public class StoreApi { public class StoreApi {
private ApiClient apiClient; private ApiClient apiClient;
@ -247,7 +247,7 @@ public class StoreApi {
}; };
final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes); final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
String[] localVarAuthNames = new String[] { "test_api_key_query", "test_api_key_header" }; String[] localVarAuthNames = new String[] { "test_api_key_header", "test_api_key_query" };
GenericType<Order> localVarReturnType = new GenericType<Order>() {}; GenericType<Order> localVarReturnType = new GenericType<Order>() {};

View File

@ -14,7 +14,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T16:01:11.428+08:00")
public class UserApi { public class UserApi {
private ApiClient apiClient; private ApiClient apiClient;

View File

@ -5,7 +5,7 @@ import io.swagger.client.Pair;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class ApiKeyAuth implements Authentication { public class ApiKeyAuth implements Authentication {
private final String location; private final String location;
private final String paramName; private final String paramName;

View File

@ -9,7 +9,7 @@ import java.util.List;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class HttpBasicAuth implements Authentication { public class HttpBasicAuth implements Authentication {
private String username; private String username;
private String password; private String password;

View File

@ -5,7 +5,7 @@ import io.swagger.client.Pair;
import java.util.Map; import java.util.Map;
import java.util.List; import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class OAuth implements Authentication { public class OAuth implements Authentication {
private String accessToken; private String accessToken;

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class Category { public class Category {
private Long id = null; private Long id = null;

View File

@ -13,7 +13,7 @@ import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class InlineResponse200 { public class InlineResponse200 {
private List<Tag> tags = new ArrayList<Tag>(); private List<Tag> tags = new ArrayList<Tag>();

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class Model200Response { public class Model200Response {
private Integer name = null; private Integer name = null;

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class ModelReturn { public class ModelReturn {
private Integer _return = null; private Integer _return = null;

View File

@ -9,10 +9,11 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class Name { public class Name {
private Integer name = null; private Integer name = null;
private Integer snakeCase = null;
/** /**
@ -32,6 +33,23 @@ public class Name {
} }
/**
**/
public Name snakeCase(Integer snakeCase) {
this.snakeCase = snakeCase;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("snake_case")
public Integer getSnakeCase() {
return snakeCase;
}
public void setSnakeCase(Integer snakeCase) {
this.snakeCase = snakeCase;
}
@Override @Override
public boolean equals(java.lang.Object o) { public boolean equals(java.lang.Object o) {
@ -42,12 +60,13 @@ public class Name {
return false; return false;
} }
Name name = (Name) o; Name name = (Name) o;
return Objects.equals(this.name, name.name); return Objects.equals(this.name, name.name) &&
Objects.equals(this.snakeCase, name.snakeCase);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(name); return Objects.hash(name, snakeCase);
} }
@Override @Override
@ -56,6 +75,7 @@ public class Name {
sb.append("class Name {\n"); sb.append("class Name {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n");
sb.append("}"); sb.append("}");
return sb.toString(); return sb.toString();
} }

View File

@ -11,7 +11,7 @@ import java.util.Date;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class Order { public class Order {
private Long id = null; private Long id = null;

View File

@ -14,7 +14,7 @@ import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class Pet { public class Pet {
private Long id = null; private Long id = null;

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class SpecialModelName { public class SpecialModelName {
private Long specialPropertyName = null; private Long specialPropertyName = null;

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class Tag { public class Tag {
private Long id = null; private Long id = null;

View File

@ -9,7 +9,7 @@ import io.swagger.annotations.ApiModelProperty;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-03-17T10:45:51.189+08:00")
public class User { public class User {
private Long id = null; private Long id = null;

View File

@ -1,7 +1,7 @@
package io.swagger.api; package io.swagger.api;
import io.swagger.model.Pet; import io.swagger.model.Pet;
import io.swagger.model.InlineResponse200; import io.swagger.model.ApiResponse;
import java.io.File; import java.io.File;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -14,57 +14,42 @@ public interface PetApi {
@POST @POST
@Path("/pet") @Path("/pet")
@Consumes({ "application/json", "application/xml" }) @Consumes({ "application/json", "application/xml" })
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response addPet(Pet body); public Response addPet(Pet body);
@POST
@Path("/pet?testing_byte_array=true")
@Consumes({ "application/json", "application/xml" })
@Produces({ "application/json", "application/xml" })
public Response addPetUsingByteArray(byte[] body);
@DELETE @DELETE
@Path("/pet/{petId}") @Path("/pet/{petId}")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response deletePet(@PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey); public Response deletePet(@PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey);
@GET @GET
@Path("/pet/findByStatus") @Path("/pet/findByStatus")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response findPetsByStatus(@QueryParam("status") List<String> status); public Response findPetsByStatus(@QueryParam("status") List<String> status);
@GET @GET
@Path("/pet/findByTags") @Path("/pet/findByTags")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response findPetsByTags(@QueryParam("tags") List<String> tags); public Response findPetsByTags(@QueryParam("tags") List<String> tags);
@GET @GET
@Path("/pet/{petId}") @Path("/pet/{petId}")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response getPetById(@PathParam("petId") Long petId); public Response getPetById(@PathParam("petId") Long petId);
@GET
@Path("/pet/{petId}?response=inline_arbitrary_object")
@Produces({ "application/json", "application/xml" })
public Response getPetByIdInObject(@PathParam("petId") Long petId);
@GET
@Path("/pet/{petId}?testing_byte_array=true")
@Produces({ "application/json", "application/xml" })
public Response petPetIdtestingByteArraytrueGet(@PathParam("petId") Long petId);
@PUT @PUT
@Path("/pet") @Path("/pet")
@Consumes({ "application/json", "application/xml" }) @Consumes({ "application/json", "application/xml" })
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response updatePet(Pet body); public Response updatePet(Pet body);
@POST @POST
@Path("/pet/{petId}") @Path("/pet/{petId}")
@Consumes({ "application/x-www-form-urlencoded" }) @Consumes({ "application/x-www-form-urlencoded" })
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response updatePetWithForm(@PathParam("petId") String petId,@Multipart(value = "name", required = false) String name,@Multipart(value = "status", required = false) String status); public Response updatePetWithForm(@PathParam("petId") Long petId,@Multipart(value = "name", required = false) String name,@Multipart(value = "status", required = false) String status);
@POST @POST
@Path("/pet/{petId}/uploadImage") @Path("/pet/{petId}/uploadImage")
@Consumes({ "multipart/form-data" }) @Consumes({ "multipart/form-data" })
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json" })
public Response uploadFile(@PathParam("petId") Long petId,@Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file", required = false) InputStream fileInputStream, public Response uploadFile(@PathParam("petId") Long petId,@Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file", required = false) InputStream fileInputStream,
@Multipart(value = "file" , required = false) Attachment fileDetail); @Multipart(value = "file" , required = false) Attachment fileDetail);
} }

View File

@ -1,7 +1,7 @@
package io.swagger.api; package io.swagger.api;
import io.swagger.model.Order;
import java.util.Map; import java.util.Map;
import io.swagger.model.Order;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
@ -13,32 +13,22 @@ public interface StoreApi {
@DELETE @DELETE
@Path("/store/order/{orderId}") @Path("/store/order/{orderId}")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response deleteOrder(@PathParam("orderId") String orderId); public Response deleteOrder(@PathParam("orderId") Long orderId);
@GET
@Path("/store/findByStatus")
@Produces({ "application/json", "application/xml" })
public Response findOrdersByStatus(@QueryParam("status") String status);
@GET @GET
@Path("/store/inventory") @Path("/store/inventory")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json" })
public Response getInventory(); public Response getInventory();
@GET @GET
@Path("/store/inventory?response=arbitrary_object")
@Produces({ "application/json", "application/xml" })
public Response getInventoryInObject();
@GET
@Path("/store/order/{orderId}") @Path("/store/order/{orderId}")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response getOrderById(@PathParam("orderId") String orderId); public Response getOrderById(@PathParam("orderId") Long orderId);
@POST @POST
@Path("/store/order") @Path("/store/order")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response placeOrder(Order body); public Response placeOrder(Order body);
} }

View File

@ -13,42 +13,42 @@ public interface UserApi {
@POST @POST
@Path("/user") @Path("/user")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response createUser(User body); public Response createUser(User body);
@POST @POST
@Path("/user/createWithArray") @Path("/user/createWithArray")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response createUsersWithArrayInput(List<User> body); public Response createUsersWithArrayInput(List<User> body);
@POST @POST
@Path("/user/createWithList") @Path("/user/createWithList")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response createUsersWithListInput(List<User> body); public Response createUsersWithListInput(List<User> body);
@DELETE @DELETE
@Path("/user/{username}") @Path("/user/{username}")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response deleteUser(@PathParam("username") String username); public Response deleteUser(@PathParam("username") String username);
@GET @GET
@Path("/user/{username}") @Path("/user/{username}")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response getUserByName(@PathParam("username") String username); public Response getUserByName(@PathParam("username") String username);
@GET @GET
@Path("/user/login") @Path("/user/login")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response loginUser(@QueryParam("username") String username,@QueryParam("password") String password); public Response loginUser(@QueryParam("username") String username,@QueryParam("password") String password);
@GET @GET
@Path("/user/logout") @Path("/user/logout")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response logoutUser(); public Response logoutUser();
@PUT @PUT
@Path("/user/{username}") @Path("/user/{username}")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/xml", "application/json" })
public Response updateUser(@PathParam("username") String username,User body); public Response updateUser(@PathParam("username") String username,User body);
} }

View File

@ -45,7 +45,7 @@ public enum Order {
private StatusEnum status = null; private StatusEnum status = null;
private Boolean complete = null; private Boolean complete = false;
/** /**

View File

@ -0,0 +1,31 @@
package io.swagger.api;
import io.swagger.jaxrs.config.SwaggerContextService;
import io.swagger.models.*;
import io.swagger.models.auth.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
public class Bootstrap extends HttpServlet {
@Override
public void init(ServletConfig config) throws ServletException {
Info info = new Info()
.title("Swagger Server")
.description("This is a sample server Petstore server. You can find out more about\nSwagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\nFor this sample, you can use the api key `special-key` to test the authorization filters.\n")
.termsOfService("http://swagger.io/terms/")
.contact(new Contact()
.email("apiteam@swagger.io"))
.license(new License()
.name("Apache 2.0")
.url("http://www.apache.org/licenses/LICENSE-2.0.html"));
ServletContext context = config.getServletContext();
Swagger swagger = new Swagger().info(info);
new SwaggerContextService().withServletConfig(config).updateSwagger(swagger);
}
}

View File

@ -1,10 +1,10 @@
--- ---
swagger: "2.0" swagger: "2.0"
info: info:
description: "This is a sample server Petstore server. You can find out more about\ description: "This is a sample server Petstore server. You can find out more about\n\
\ Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net,\ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\n\
\ #swagger. For this sample, you can use the api key \"special-key\" to test\ For this sample, you can use the api key `special-key` to test the authorization\
\ the authorization filters" \ filters.\n"
version: "1.0.0" version: "1.0.0"
title: "Swagger Petstore" title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/" termsOfService: "http://swagger.io/terms/"
@ -15,6 +15,19 @@ info:
url: "http://www.apache.org/licenses/LICENSE-2.0.html" url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io" host: "petstore.swagger.io"
basePath: "/v2" basePath: "/v2"
tags:
- name: "pet"
description: "Everything about your Pets"
externalDocs:
description: "Find out more"
url: "http://swagger.io"
- name: "store"
description: "Access to Petstore orders"
- name: "user"
description: "Operations about user"
externalDocs:
description: "Find out more about our store"
url: "http://swagger.io"
schemes: schemes:
- "http" - "http"
paths: paths:
@ -23,19 +36,18 @@ paths:
tags: tags:
- "pet" - "pet"
summary: "Add a new pet to the store" summary: "Add a new pet to the store"
description: ""
operationId: "addPet" operationId: "addPet"
consumes: consumes:
- "application/json" - "application/json"
- "application/xml" - "application/xml"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
description: "Pet object that needs to be added to the store" description: "Pet object that needs to be added to the store"
required: false required: true
schema: schema:
$ref: "#/definitions/Pet" $ref: "#/definitions/Pet"
responses: responses:
@ -45,23 +57,23 @@ paths:
- petstore_auth: - petstore_auth:
- "write:pets" - "write:pets"
- "read:pets" - "read:pets"
x-swagger-router-controller: "Pet"
put: put:
tags: tags:
- "pet" - "pet"
summary: "Update an existing pet" summary: "Update an existing pet"
description: ""
operationId: "updatePet" operationId: "updatePet"
consumes: consumes:
- "application/json" - "application/json"
- "application/xml" - "application/xml"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
description: "Pet object that needs to be added to the store" description: "Pet object that needs to be added to the store"
required: false required: true
schema: schema:
$ref: "#/definitions/Pet" $ref: "#/definitions/Pet"
responses: responses:
@ -75,26 +87,31 @@ paths:
- petstore_auth: - petstore_auth:
- "write:pets" - "write:pets"
- "read:pets" - "read:pets"
x-swagger-router-controller: "Pet"
/pet/findByStatus: /pet/findByStatus:
get: get:
tags: tags:
- "pet" - "pet"
summary: "Finds Pets by status" summary: "Finds Pets by status"
description: "Multiple status values can be provided with comma seperated strings" description: "Multiple status values can be provided with comma separated strings"
operationId: "findPetsByStatus" operationId: "findPetsByStatus"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "status" - name: "status"
in: "query" in: "query"
description: "Status values that need to be considered for filter" description: "Status values that need to be considered for filter"
required: false required: true
type: "array" type: "array"
items: items:
type: "string" type: "string"
collectionFormat: "multi"
default: "available" default: "available"
enum:
- "available"
- "pending"
- "sold"
collectionFormat: "multi"
responses: responses:
200: 200:
description: "successful operation" description: "successful operation"
@ -108,22 +125,23 @@ paths:
- petstore_auth: - petstore_auth:
- "write:pets" - "write:pets"
- "read:pets" - "read:pets"
x-swagger-router-controller: "Pet"
/pet/findByTags: /pet/findByTags:
get: get:
tags: tags:
- "pet" - "pet"
summary: "Finds Pets by tags" summary: "Finds Pets by tags"
description: "Muliple tags can be provided with comma seperated strings. Use\ description: "Muliple tags can be provided with comma separated strings. Use\n\
\ tag1, tag2, tag3 for testing." tag1, tag2, tag3 for testing.\n"
operationId: "findPetsByTags" operationId: "findPetsByTags"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "tags" - name: "tags"
in: "query" in: "query"
description: "Tags to filter by" description: "Tags to filter by"
required: false required: true
type: "array" type: "array"
items: items:
type: "string" type: "string"
@ -141,21 +159,22 @@ paths:
- petstore_auth: - petstore_auth:
- "write:pets" - "write:pets"
- "read:pets" - "read:pets"
deprecated: true
x-swagger-router-controller: "Pet"
/pet/{petId}: /pet/{petId}:
get: get:
tags: tags:
- "pet" - "pet"
summary: "Find pet by ID" summary: "Find pet by ID"
description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\ description: "Returns a single pet"
\ API error conditions"
operationId: "getPetById" operationId: "getPetById"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "petId" - name: "petId"
in: "path" in: "path"
description: "ID of pet that needs to be fetched" description: "ID of pet to return"
required: true required: true
type: "integer" type: "integer"
format: "int64" format: "int64"
@ -170,26 +189,25 @@ paths:
description: "Pet not found" description: "Pet not found"
security: security:
- api_key: [] - api_key: []
- petstore_auth: x-swagger-router-controller: "Pet"
- "write:pets"
- "read:pets"
post: post:
tags: tags:
- "pet" - "pet"
summary: "Updates a pet in the store with form data" summary: "Updates a pet in the store with form data"
description: "" description: "null"
operationId: "updatePetWithForm" operationId: "updatePetWithForm"
consumes: consumes:
- "application/x-www-form-urlencoded" - "application/x-www-form-urlencoded"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "petId" - name: "petId"
in: "path" in: "path"
description: "ID of pet that needs to be updated" description: "ID of pet that needs to be updated"
required: true required: true
type: "string" type: "integer"
format: "int64"
- name: "name" - name: "name"
in: "formData" in: "formData"
description: "Updated name of the pet" description: "Updated name of the pet"
@ -207,19 +225,18 @@ paths:
- petstore_auth: - petstore_auth:
- "write:pets" - "write:pets"
- "read:pets" - "read:pets"
x-swagger-router-controller: "Pet"
delete: delete:
tags: tags:
- "pet" - "pet"
summary: "Deletes a pet" summary: "Deletes a pet"
description: ""
operationId: "deletePet" operationId: "deletePet"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "api_key" - name: "api_key"
in: "header" in: "header"
description: ""
required: false required: false
type: "string" type: "string"
- name: "petId" - name: "petId"
@ -230,23 +247,24 @@ paths:
format: "int64" format: "int64"
responses: responses:
400: 400:
description: "Invalid pet value" description: "Invalid ID supplied"
404:
description: "Pet not found"
security: security:
- petstore_auth: - petstore_auth:
- "write:pets" - "write:pets"
- "read:pets" - "read:pets"
x-swagger-router-controller: "Pet"
/pet/{petId}/uploadImage: /pet/{petId}/uploadImage:
post: post:
tags: tags:
- "pet" - "pet"
summary: "uploads an image" summary: "uploads an image"
description: ""
operationId: "uploadFile" operationId: "uploadFile"
consumes: consumes:
- "multipart/form-data" - "multipart/form-data"
produces: produces:
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "petId" - name: "petId"
in: "path" in: "path"
@ -264,75 +282,16 @@ paths:
description: "file to upload" description: "file to upload"
required: false required: false
type: "file" type: "file"
responses:
default:
description: "successful operation"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
/pet/{petId}?testing_byte_array=true:
get:
tags:
- "pet"
summary: "Fake endpoint to test byte array return by 'Find pet by ID'"
description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\
\ API error conditions"
operationId: "getPetByIdWithByteArray"
produces:
- "application/json"
- "application/xml"
parameters:
- name: "petId"
in: "path"
description: "ID of pet that needs to be fetched"
required: true
type: "integer"
format: "int64"
responses: responses:
200: 200:
description: "successful operation" description: "successful operation"
schema: schema:
type: "string" $ref: "#/definitions/ApiResponse"
format: "binary"
400:
description: "Invalid ID supplied"
404:
description: "Pet not found"
security:
- api_key: []
- petstore_auth:
- "write:pets"
- "read:pets"
/pet?testing_byte_array=true:
post:
tags:
- "pet"
summary: "Fake endpoint to test byte array in body parameter for adding a new\
\ pet to the store"
description: ""
operationId: "addPetUsingByteArray"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/json"
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "Pet object in the form of byte array"
required: false
schema:
type: "string"
format: "binary"
responses:
405:
description: "Invalid input"
security: security:
- petstore_auth: - petstore_auth:
- "write:pets" - "write:pets"
- "read:pets" - "read:pets"
x-swagger-router-controller: "Pet"
/store/inventory: /store/inventory:
get: get:
tags: tags:
@ -342,7 +301,6 @@ paths:
operationId: "getInventory" operationId: "getInventory"
produces: produces:
- "application/json" - "application/json"
- "application/xml"
parameters: [] parameters: []
responses: responses:
200: 200:
@ -354,21 +312,21 @@ paths:
format: "int32" format: "int32"
security: security:
- api_key: [] - api_key: []
x-swagger-router-controller: "Store"
/store/order: /store/order:
post: post:
tags: tags:
- "store" - "store"
summary: "Place an order for a pet" summary: "Place an order for a pet"
description: ""
operationId: "placeOrder" operationId: "placeOrder"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
description: "order placed for purchasing the pet" description: "order placed for purchasing the pet"
required: false required: true
schema: schema:
$ref: "#/definitions/Order" $ref: "#/definitions/Order"
responses: responses:
@ -378,23 +336,27 @@ paths:
$ref: "#/definitions/Order" $ref: "#/definitions/Order"
400: 400:
description: "Invalid Order" description: "Invalid Order"
x-swagger-router-controller: "Store"
/store/order/{orderId}: /store/order/{orderId}:
get: get:
tags: tags:
- "store" - "store"
summary: "Find purchase order by ID" summary: "Find purchase order by ID"
description: "For valid response try integer IDs with value <= 5 or > 10. Other\ description: "For valid response try integer IDs with value >= 1 and <= 10.\n\
\ values will generated exceptions" Other values will generated exceptions\n"
operationId: "getOrderById" operationId: "getOrderById"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "orderId" - name: "orderId"
in: "path" in: "path"
description: "ID of pet that needs to be fetched" description: "ID of pet that needs to be fetched"
required: true required: true
type: "string" type: "integer"
maximum: 10
minimum: 1
format: "int64"
responses: responses:
200: 200:
description: "successful operation" description: "successful operation"
@ -404,27 +366,31 @@ paths:
description: "Invalid ID supplied" description: "Invalid ID supplied"
404: 404:
description: "Order not found" description: "Order not found"
x-swagger-router-controller: "Store"
delete: delete:
tags: tags:
- "store" - "store"
summary: "Delete purchase order by ID" summary: "Delete purchase order by ID"
description: "For valid response try integer IDs with value < 1000. Anything\ description: "For valid response try integer IDs with positive integer value.\\\
\ above 1000 or nonintegers will generate API errors" \ \\ Negative or non-integer values will generate API errors"
operationId: "deleteOrder" operationId: "deleteOrder"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "orderId" - name: "orderId"
in: "path" in: "path"
description: "ID of the order that needs to be deleted" description: "ID of the order that needs to be deleted"
required: true required: true
type: "string" type: "integer"
minimum: 1
format: "int64"
responses: responses:
400: 400:
description: "Invalid ID supplied" description: "Invalid ID supplied"
404: 404:
description: "Order not found" description: "Order not found"
x-swagger-router-controller: "Store"
/user: /user:
post: post:
tags: tags:
@ -433,33 +399,33 @@ paths:
description: "This can only be done by the logged in user." description: "This can only be done by the logged in user."
operationId: "createUser" operationId: "createUser"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
description: "Created user object" description: "Created user object"
required: false required: true
schema: schema:
$ref: "#/definitions/User" $ref: "#/definitions/User"
responses: responses:
default: default:
description: "successful operation" description: "successful operation"
x-swagger-router-controller: "User"
/user/createWithArray: /user/createWithArray:
post: post:
tags: tags:
- "user" - "user"
summary: "Creates list of users with given input array" summary: "Creates list of users with given input array"
description: ""
operationId: "createUsersWithArrayInput" operationId: "createUsersWithArrayInput"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
description: "List of user object" description: "List of user object"
required: false required: true
schema: schema:
type: "array" type: "array"
items: items:
@ -467,21 +433,21 @@ paths:
responses: responses:
default: default:
description: "successful operation" description: "successful operation"
x-swagger-router-controller: "User"
/user/createWithList: /user/createWithList:
post: post:
tags: tags:
- "user" - "user"
summary: "Creates list of users with given input array" summary: "Creates list of users with given input array"
description: ""
operationId: "createUsersWithListInput" operationId: "createUsersWithListInput"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
description: "List of user object" description: "List of user object"
required: false required: true
schema: schema:
type: "array" type: "array"
items: items:
@ -489,62 +455,72 @@ paths:
responses: responses:
default: default:
description: "successful operation" description: "successful operation"
x-swagger-router-controller: "User"
/user/login: /user/login:
get: get:
tags: tags:
- "user" - "user"
summary: "Logs user into the system" summary: "Logs user into the system"
description: ""
operationId: "loginUser" operationId: "loginUser"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "username" - name: "username"
in: "query" in: "query"
description: "The user name for login" description: "The user name for login"
required: false required: true
type: "string" type: "string"
- name: "password" - name: "password"
in: "query" in: "query"
description: "The password for login in clear text" description: "The password for login in clear text"
required: false required: true
type: "string" type: "string"
responses: responses:
200: 200:
description: "successful operation" description: "successful operation"
schema: schema:
type: "string" type: "string"
headers:
X-Rate-Limit:
type: "integer"
format: "int32"
description: "calls per hour allowed by the user"
X-Expires-After:
type: "string"
format: "date-time"
description: "date in UTC when token expires"
400: 400:
description: "Invalid username/password supplied" description: "Invalid username/password supplied"
x-swagger-router-controller: "User"
/user/logout: /user/logout:
get: get:
tags: tags:
- "user" - "user"
summary: "Logs out current logged in user session" summary: "Logs out current logged in user session"
description: "" description: "null"
operationId: "logoutUser" operationId: "logoutUser"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: [] parameters: []
responses: responses:
default: default:
description: "successful operation" description: "successful operation"
x-swagger-router-controller: "User"
/user/{username}: /user/{username}:
get: get:
tags: tags:
- "user" - "user"
summary: "Get user by user name" summary: "Get user by user name"
description: ""
operationId: "getUserByName" operationId: "getUserByName"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "username" - name: "username"
in: "path" in: "path"
description: "The name that needs to be fetched. Use user1 for testing. " description: "The name that needs to be fetched. Use user1 for testing."
required: true required: true
type: "string" type: "string"
responses: responses:
@ -552,20 +528,11 @@ paths:
description: "successful operation" description: "successful operation"
schema: schema:
$ref: "#/definitions/User" $ref: "#/definitions/User"
examples:
application/json:
id: 1
username: "johnp"
firstName: "John"
lastName: "Public"
email: "johnp@swagger.io"
password: "-secret-"
phone: "0123456789"
userStatus: 0
400: 400:
description: "Invalid username supplied" description: "Invalid username supplied"
404: 404:
description: "User not found" description: "User not found"
x-swagger-router-controller: "User"
put: put:
tags: tags:
- "user" - "user"
@ -573,18 +540,18 @@ paths:
description: "This can only be done by the logged in user." description: "This can only be done by the logged in user."
operationId: "updateUser" operationId: "updateUser"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "username" - name: "username"
in: "path" in: "path"
description: "name that need to be deleted" description: "name that need to be updated"
required: true required: true
type: "string" type: "string"
- in: "body" - in: "body"
name: "body" name: "body"
description: "Updated user object" description: "Updated user object"
required: false required: true
schema: schema:
$ref: "#/definitions/User" $ref: "#/definitions/User"
responses: responses:
@ -592,6 +559,7 @@ paths:
description: "Invalid user supplied" description: "Invalid user supplied"
404: 404:
description: "User not found" description: "User not found"
x-swagger-router-controller: "User"
delete: delete:
tags: tags:
- "user" - "user"
@ -599,8 +567,8 @@ paths:
description: "This can only be done by the logged in user." description: "This can only be done by the logged in user."
operationId: "deleteUser" operationId: "deleteUser"
produces: produces:
- "application/json"
- "application/xml" - "application/xml"
- "application/json"
parameters: parameters:
- name: "username" - name: "username"
in: "path" in: "path"
@ -612,6 +580,7 @@ paths:
description: "Invalid username supplied" description: "Invalid username supplied"
404: 404:
description: "User not found" description: "User not found"
x-swagger-router-controller: "User"
securityDefinitions: securityDefinitions:
api_key: api_key:
type: "apiKey" type: "apiKey"
@ -619,13 +588,41 @@ securityDefinitions:
in: "header" in: "header"
petstore_auth: petstore_auth:
type: "oauth2" type: "oauth2"
authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog" authorizationUrl: "http://petstore.swagger.io/oauth/dialog"
flow: "implicit" flow: "implicit"
scopes: scopes:
write:pets: "modify pets in your account" write:pets: "modify pets in your account"
read:pets: "read your pets" read:pets: "read your pets"
definitions: definitions:
Order:
type: "object"
properties:
id:
type: "integer"
format: "int64"
petId:
type: "integer"
format: "int64"
quantity:
type: "integer"
format: "int32"
shipDate:
type: "string"
format: "date-time"
status:
type: "string"
description: "Order Status"
enum:
- "placed"
- "approved"
- "delivered"
complete:
type: "boolean"
default: false
xml:
name: "Order"
User: User:
type: "object"
properties: properties:
id: id:
type: "integer" type: "integer"
@ -649,6 +646,7 @@ definitions:
xml: xml:
name: "User" name: "User"
Category: Category:
type: "object"
properties: properties:
id: id:
type: "integer" type: "integer"
@ -657,7 +655,18 @@ definitions:
type: "string" type: "string"
xml: xml:
name: "Category" name: "Category"
Tag:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Tag"
Pet: Pet:
type: "object"
required: required:
- "name" - "name"
- "photoUrls" - "photoUrls"
@ -693,37 +702,16 @@ definitions:
- "sold" - "sold"
xml: xml:
name: "Pet" name: "Pet"
Tag: ApiResponse:
type: "object"
properties: properties:
id: code:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Tag"
Order:
properties:
id:
type: "integer"
format: "int64"
petId:
type: "integer"
format: "int64"
quantity:
type: "integer" type: "integer"
format: "int32" format: "int32"
shipDate: type:
type: "string" type: "string"
format: "date-time" message:
status:
type: "string" type: "string"
description: "Order Status" externalDocs:
enum: description: "Find out more about Swagger"
- "placed" url: "http://swagger.io"
- "approved"
- "delivered"
complete:
type: "boolean"
xml:
name: "Order"

View File

@ -6,14 +6,14 @@ var url = require('url');
var Pet = require('./PetService'); var Pet = require('./PetService');
module.exports.updatePet = function updatePet (req, res, next) {
Pet.updatePet(req.swagger.params, res, next);
};
module.exports.addPet = function addPet (req, res, next) { module.exports.addPet = function addPet (req, res, next) {
Pet.addPet(req.swagger.params, res, next); Pet.addPet(req.swagger.params, res, next);
}; };
module.exports.deletePet = function deletePet (req, res, next) {
Pet.deletePet(req.swagger.params, res, next);
};
module.exports.findPetsByStatus = function findPetsByStatus (req, res, next) { module.exports.findPetsByStatus = function findPetsByStatus (req, res, next) {
Pet.findPetsByStatus(req.swagger.params, res, next); Pet.findPetsByStatus(req.swagger.params, res, next);
}; };
@ -26,22 +26,14 @@ module.exports.getPetById = function getPetById (req, res, next) {
Pet.getPetById(req.swagger.params, res, next); Pet.getPetById(req.swagger.params, res, next);
}; };
module.exports.updatePetWithForm = function updatePetWithForm (req, res, next) { module.exports.updatePet = function updatePet (req, res, next) {
Pet.updatePetWithForm(req.swagger.params, res, next); Pet.updatePet(req.swagger.params, res, next);
}; };
module.exports.deletePet = function deletePet (req, res, next) { module.exports.updatePetWithForm = function updatePetWithForm (req, res, next) {
Pet.deletePet(req.swagger.params, res, next); Pet.updatePetWithForm(req.swagger.params, res, next);
}; };
module.exports.uploadFile = function uploadFile (req, res, next) { module.exports.uploadFile = function uploadFile (req, res, next) {
Pet.uploadFile(req.swagger.params, res, next); Pet.uploadFile(req.swagger.params, res, next);
}; };
module.exports.getPetByIdWithByteArray = function getPetByIdWithByteArray (req, res, next) {
Pet.getPetByIdWithByteArray(req.swagger.params, res, next);
};
module.exports.addPetUsingByteArray = function addPetUsingByteArray (req, res, next) {
Pet.addPetUsingByteArray(req.swagger.params, res, next);
};

View File

@ -1,37 +1,36 @@
'use strict'; 'use strict';
exports.updatePet = function(args, res, next) {
/**
* parameters expected in the args:
* body (Pet)
**/
var examples = {};
res.end();
}
exports.addPet = function(args, res, next) { exports.addPet = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
* body (Pet) * body (Pet)
**/ **/
// no response value expected for this operation
var examples = {};
res.end(); res.end();
} }
exports.deletePet = function(args, res, next) {
/**
* parameters expected in the args:
* petId (Long)
* apiKey (String)
**/
// no response value expected for this operation
res.end();
}
exports.findPetsByStatus = function(args, res, next) { exports.findPetsByStatus = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
* status (List) * status (List)
**/ **/
var examples = {};
var examples = {};
examples['application/json'] = [ { examples['application/json'] = [ {
"tags" : [ { "tags" : [ {
"id" : 123456789, "id" : 123456789,
@ -47,8 +46,6 @@ var examples = {};
"photoUrls" : [ "aeiou" ] "photoUrls" : [ "aeiou" ]
} ]; } ];
if(Object.keys(examples).length > 0) { if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -59,14 +56,15 @@ var examples = {};
} }
exports.findPetsByTags = function(args, res, next) { exports.findPetsByTags = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
* tags (List) * tags (List)
**/ **/
var examples = {};
var examples = {};
examples['application/json'] = [ { examples['application/json'] = [ {
"tags" : [ { "tags" : [ {
"id" : 123456789, "id" : 123456789,
@ -82,8 +80,6 @@ var examples = {};
"photoUrls" : [ "aeiou" ] "photoUrls" : [ "aeiou" ]
} ]; } ];
if(Object.keys(examples).length > 0) { if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -94,14 +90,15 @@ var examples = {};
} }
exports.getPetById = function(args, res, next) { exports.getPetById = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
* petId (Long) * petId (Long)
**/ **/
var examples = {};
var examples = {};
examples['application/json'] = { examples['application/json'] = {
"tags" : [ { "tags" : [ {
"id" : 123456789, "id" : 123456789,
@ -117,8 +114,6 @@ var examples = {};
"photoUrls" : [ "aeiou" ] "photoUrls" : [ "aeiou" ]
}; };
if(Object.keys(examples).length > 0) { if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -129,33 +124,31 @@ var examples = {};
} }
exports.updatePet = function(args, res, next) {
/**
* parameters expected in the args:
* body (Pet)
**/
// no response value expected for this operation
res.end();
}
exports.updatePetWithForm = function(args, res, next) { exports.updatePetWithForm = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
* petId (String) * petId (Long)
* name (String) * name (String)
* status (String) * status (String)
**/ **/
// no response value expected for this operation
var examples = {};
res.end(); res.end();
} }
exports.deletePet = function(args, res, next) {
/**
* parameters expected in the args:
* petId (Long)
* apiKey (String)
**/
var examples = {};
res.end();
}
exports.uploadFile = function(args, res, next) { exports.uploadFile = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
@ -164,23 +157,13 @@ exports.uploadFile = function(args, res, next) {
* file (file) * file (file)
**/ **/
var examples = {};
res.end();
}
exports.getPetByIdWithByteArray = function(args, res, next) {
/**
* parameters expected in the args:
* petId (Long)
**/
var examples = {};
examples['application/json'] = "";
var examples = {};
examples['application/json'] = {
"message" : "aeiou",
"code" : 123,
"type" : "aeiou"
};
if(Object.keys(examples).length > 0) { if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
@ -192,15 +175,4 @@ var examples = {};
} }
exports.addPetUsingByteArray = function(args, res, next) {
/**
* parameters expected in the args:
* body (byte[])
**/
var examples = {};
res.end();
}

View File

@ -6,18 +6,18 @@ var url = require('url');
var Store = require('./StoreService'); var Store = require('./StoreService');
module.exports.getInventory = function getInventory (req, res, next) { module.exports.deleteOrder = function deleteOrder (req, res, next) {
Store.getInventory(req.swagger.params, res, next); Store.deleteOrder(req.swagger.params, res, next);
}; };
module.exports.placeOrder = function placeOrder (req, res, next) { module.exports.getInventory = function getInventory (req, res, next) {
Store.placeOrder(req.swagger.params, res, next); Store.getInventory(req.swagger.params, res, next);
}; };
module.exports.getOrderById = function getOrderById (req, res, next) { module.exports.getOrderById = function getOrderById (req, res, next) {
Store.getOrderById(req.swagger.params, res, next); Store.getOrderById(req.swagger.params, res, next);
}; };
module.exports.deleteOrder = function deleteOrder (req, res, next) { module.exports.placeOrder = function placeOrder (req, res, next) {
Store.deleteOrder(req.swagger.params, res, next); Store.placeOrder(req.swagger.params, res, next);
}; };

View File

@ -1,18 +1,27 @@
'use strict'; 'use strict';
exports.deleteOrder = function(args, res, next) {
/**
* parameters expected in the args:
* orderId (Long)
**/
// no response value expected for this operation
res.end();
}
exports.getInventory = function(args, res, next) { exports.getInventory = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
**/ **/
var examples = {};
var examples = {};
examples['application/json'] = { examples['application/json'] = {
"key" : 123 "key" : 123
}; };
if(Object.keys(examples).length > 0) { if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -23,25 +32,52 @@ var examples = {};
} }
exports.getOrderById = function(args, res, next) {
/**
* parameters expected in the args:
* orderId (Long)
**/
var examples = {};
examples['application/json'] = {
"id" : 123456789,
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
};
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
}
else {
res.end();
}
}
exports.placeOrder = function(args, res, next) { exports.placeOrder = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
* body (Order) * body (Order)
**/ **/
var examples = {};
var examples = {};
examples['application/json'] = { examples['application/json'] = {
"id" : 123456789, "id" : 123456789,
"petId" : 123456789, "petId" : 123456789,
"complete" : true, "complete" : true,
"status" : "aeiou", "status" : "aeiou",
"quantity" : 123, "quantity" : 123,
"shipDate" : "2016-01-24T14:07:57.768+0000" "shipDate" : "2000-01-23T04:56:07.000+0000"
}; };
if(Object.keys(examples).length > 0) { if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -52,44 +88,4 @@ var examples = {};
} }
exports.getOrderById = function(args, res, next) {
/**
* parameters expected in the args:
* orderId (String)
**/
var examples = {};
examples['application/json'] = {
"id" : 123456789,
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2016-01-24T14:07:57.780+0000"
};
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
}
else {
res.end();
}
}
exports.deleteOrder = function(args, res, next) {
/**
* parameters expected in the args:
* orderId (String)
**/
var examples = {};
res.end();
}

View File

@ -18,6 +18,14 @@ module.exports.createUsersWithListInput = function createUsersWithListInput (req
User.createUsersWithListInput(req.swagger.params, res, next); User.createUsersWithListInput(req.swagger.params, res, next);
}; };
module.exports.deleteUser = function deleteUser (req, res, next) {
User.deleteUser(req.swagger.params, res, next);
};
module.exports.getUserByName = function getUserByName (req, res, next) {
User.getUserByName(req.swagger.params, res, next);
};
module.exports.loginUser = function loginUser (req, res, next) { module.exports.loginUser = function loginUser (req, res, next) {
User.loginUser(req.swagger.params, res, next); User.loginUser(req.swagger.params, res, next);
}; };
@ -26,14 +34,6 @@ module.exports.logoutUser = function logoutUser (req, res, next) {
User.logoutUser(req.swagger.params, res, next); User.logoutUser(req.swagger.params, res, next);
}; };
module.exports.getUserByName = function getUserByName (req, res, next) {
User.getUserByName(req.swagger.params, res, next);
};
module.exports.updateUser = function updateUser (req, res, next) { module.exports.updateUser = function updateUser (req, res, next) {
User.updateUser(req.swagger.params, res, next); User.updateUser(req.swagger.params, res, next);
}; };
module.exports.deleteUser = function deleteUser (req, res, next) {
User.deleteUser(req.swagger.params, res, next);
};

View File

@ -5,37 +5,75 @@ exports.createUser = function(args, res, next) {
* parameters expected in the args: * parameters expected in the args:
* body (User) * body (User)
**/ **/
// no response value expected for this operation
var examples = {};
res.end(); res.end();
} }
exports.createUsersWithArrayInput = function(args, res, next) { exports.createUsersWithArrayInput = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
* body (List) * body (List)
**/ **/
// no response value expected for this operation
var examples = {};
res.end(); res.end();
} }
exports.createUsersWithListInput = function(args, res, next) { exports.createUsersWithListInput = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
* body (List) * body (List)
**/ **/
// no response value expected for this operation
var examples = {};
res.end(); res.end();
} }
exports.deleteUser = function(args, res, next) {
/**
* parameters expected in the args:
* username (String)
**/
// no response value expected for this operation
res.end();
}
exports.getUserByName = function(args, res, next) {
/**
* parameters expected in the args:
* username (String)
**/
var examples = {};
examples['application/json'] = {
"id" : 123456789,
"lastName" : "aeiou",
"phone" : "aeiou",
"username" : "aeiou",
"email" : "aeiou",
"userStatus" : 123,
"firstName" : "aeiou",
"password" : "aeiou"
};
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
}
else {
res.end();
}
}
exports.loginUser = function(args, res, next) { exports.loginUser = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
@ -43,12 +81,10 @@ exports.loginUser = function(args, res, next) {
* password (String) * password (String)
**/ **/
var examples = {};
var examples = {};
examples['application/json'] = "aeiou"; examples['application/json'] = "aeiou";
if(Object.keys(examples).length > 0) { if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json'); res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2)); res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
@ -59,70 +95,26 @@ var examples = {};
} }
exports.logoutUser = function(args, res, next) { exports.logoutUser = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
**/ **/
// no response value expected for this operation
var examples = {};
res.end(); res.end();
} }
exports.getUserByName = function(args, res, next) {
/**
* parameters expected in the args:
* username (String)
**/
var examples = {};
examples['application/json'] = {
"id" : 1,
"username" : "johnp",
"firstName" : "John",
"lastName" : "Public",
"email" : "johnp@swagger.io",
"password" : "-secret-",
"phone" : "0123456789",
"userStatus" : 0
};
if(Object.keys(examples).length > 0) {
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(examples[Object.keys(examples)[0]] || {}, null, 2));
}
else {
res.end();
}
}
exports.updateUser = function(args, res, next) { exports.updateUser = function(args, res, next) {
/** /**
* parameters expected in the args: * parameters expected in the args:
* username (String) * username (String)
* body (User) * body (User)
**/ **/
// no response value expected for this operation
var examples = {};
res.end(); res.end();
} }
exports.deleteUser = function(args, res, next) {
/**
* parameters expected in the args:
* username (String)
**/
var examples = {};
res.end();
}

View File

@ -1,7 +1,7 @@
{ {
"name": "swagger-petstore", "name": "swagger-petstore",
"version": "1.0.0", "version": "1.0.0",
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", "description": "This is a sample server Petstore server. You can find out more about\nSwagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\nFor this sample, you can use the api key `special-key` to test the authorization filters.\n",
"main": "index.js", "main": "index.js",
"keywords": [ "keywords": [
"swagger" "swagger"