forked from loafle/openapi-generator-original
Merge branch 'arturdzm-master'
This commit is contained in:
commit
dd53f8478d
31
bin/jaxrs-spec-petstore-server.sh
Normal file
31
bin/jaxrs-spec-petstore-server.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
# 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"
|
||||
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-spec -o samples/server/petstore/jaxrs-spec -DhideGenerationTimestamp=true"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
@ -0,0 +1,145 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.swagger.codegen.CliOption;
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.CodegenModel;
|
||||
import io.swagger.codegen.CodegenOperation;
|
||||
import io.swagger.codegen.CodegenProperty;
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
import io.swagger.models.Operation;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.util.Json;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
||||
public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen
|
||||
{
|
||||
public JavaJAXRSSpecServerCodegen()
|
||||
{
|
||||
super();
|
||||
supportsInheritance = true;
|
||||
sourceFolder = "src/main/java";
|
||||
invokerPackage = "io.swagger.api";
|
||||
artifactId = "swagger-jaxrs-server";
|
||||
outputFolder = "generated-code/JavaJaxRS-Spec";
|
||||
|
||||
modelTemplateFiles.put("model.mustache", ".java");
|
||||
apiTemplateFiles.put("api.mustache", ".java");
|
||||
apiPackage = "io.swagger.api";
|
||||
modelPackage = "io.swagger.model";
|
||||
|
||||
additionalProperties.put("title", title);
|
||||
|
||||
typeMapping.put("date", "LocalDate");
|
||||
typeMapping.put("DateTime", "javax.xml.datatype.XMLGregorianCalendar"); // Map DateTime fields to Java standart class 'XMLGregorianCalendar'
|
||||
|
||||
importMapping.put("LocalDate", "org.joda.time.LocalDate");
|
||||
|
||||
super.embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "spec";
|
||||
|
||||
for ( int i = 0; i < cliOptions.size(); i++ ) {
|
||||
if ( CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt()) ) {
|
||||
cliOptions.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
|
||||
library.setDefault(DEFAULT_LIBRARY);
|
||||
|
||||
Map<String, String> supportedLibraries = new LinkedHashMap<String,String>();
|
||||
|
||||
supportedLibraries.put(DEFAULT_LIBRARY, "JAXRS");
|
||||
library.setEnum(supportedLibraries);
|
||||
|
||||
cliOptions.add(library);
|
||||
cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));
|
||||
cliOptions.add(new CliOption("title", "a title describing the application"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts()
|
||||
{
|
||||
super.processOpts();
|
||||
|
||||
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
|
||||
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
|
||||
writeOptional(outputFolder, new SupportingFile("RestApplication.mustache",
|
||||
(sourceFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "jaxrs-spec";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations) {
|
||||
String basePath = resourcePath;
|
||||
if (basePath.startsWith("/")) {
|
||||
basePath = basePath.substring(1);
|
||||
}
|
||||
int pos = basePath.indexOf("/");
|
||||
if (pos > 0) {
|
||||
basePath = basePath.substring(0, pos);
|
||||
}
|
||||
|
||||
if (basePath == "") {
|
||||
basePath = "default";
|
||||
} else {
|
||||
if (co.path.startsWith("/" + basePath)) {
|
||||
co.path = co.path.substring(("/" + basePath).length());
|
||||
}
|
||||
co.subresourceOperation = !co.path.isEmpty();
|
||||
}
|
||||
List<CodegenOperation> opList = operations.get(basePath);
|
||||
if (opList == null) {
|
||||
opList = new ArrayList<CodegenOperation>();
|
||||
operations.put(basePath, opList);
|
||||
}
|
||||
opList.add(co);
|
||||
co.baseName = basePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
|
||||
super.postProcessModelProperty(model, property);
|
||||
model.imports.remove("ApiModelProperty");
|
||||
model.imports.remove("ApiModel");
|
||||
model.imports.remove("JsonSerialize");
|
||||
model.imports.remove("ToStringSerializer");
|
||||
model.imports.remove("JsonValue");
|
||||
model.imports.remove("JsonProperty");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preprocessSwagger(Swagger swagger) {
|
||||
//copy input swagger to output folder
|
||||
try {
|
||||
String swaggerJson = Json.pretty(swagger);
|
||||
FileUtils.writeStringToFile(new File(outputFolder + File.separator + "swagger.json"), swaggerJson);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e.getMessage(), e.getCause());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e.getMessage(), e.getCause());
|
||||
}
|
||||
super.preprocessSwagger(swagger);
|
||||
|
||||
}
|
||||
@Override
|
||||
public String getHelp()
|
||||
{
|
||||
return "Generates a Java JAXRS Server according to JAXRS 2.0 specification.";
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package {{invokerPackage}};
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
import javax.ws.rs.core.Application;
|
||||
|
||||
@ApplicationPath("/")
|
||||
public class RestApplication extends Application {
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
{{#allowableValues}}allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}{{^values}}range=[{{#min}}{{.}}{{/min}}{{^min}}-infinity{{/min}}, {{#max}}{{.}}{{/max}}{{^max}}infinity{{/max}}]{{/values}}"{{/allowableValues}}
|
@ -0,0 +1,43 @@
|
||||
package {{package}};
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Path("/{{baseName}}")
|
||||
|
||||
@Api(description = "the {{baseName}} API")
|
||||
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
|
||||
{{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
|
||||
{{>generatedAnnotation}}
|
||||
|
||||
public class {{classname}} {
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
|
||||
@{{httpMethod}}
|
||||
{{#subresourceOperation}}@Path("{{path}}"){{/subresourceOperation}}
|
||||
{{#hasConsumes}}@Consumes({ {{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}} }){{/hasConsumes}}
|
||||
{{#hasProduces}}@Produces({ {{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}}
|
||||
@ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = {
|
||||
{{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = {
|
||||
{{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}},
|
||||
{{/hasMore}}{{/scopes}}
|
||||
}{{/isOAuth}}){{#hasMore}},
|
||||
{{/hasMore}}{{/authMethods}}
|
||||
}{{/hasAuthMethods}}, tags={ {{#vendorExtensions.x-tags}}"{{tag}}"{{#hasMore}}, {{/hasMore}}{{/vendorExtensions.x-tags}} })
|
||||
@ApiResponses(value = { {{#responses}}
|
||||
@ApiResponse(code = {{{code}}}, message = "{{{message}}}", response = {{{returnType}}}.class{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},{{/hasMore}}{{/responses}} })
|
||||
public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
|
@ -0,0 +1 @@
|
||||
{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}}
|
@ -0,0 +1,16 @@
|
||||
import javax.xml.bind.annotation.XmlEnum;
|
||||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
@XmlType(name="{{classname}}")
|
||||
@XmlEnum
|
||||
public enum {{classname}} {
|
||||
{{#allowableValues}}{{.}}{{^-last}}, {{/-last}}{{#-last}};{{/-last}}{{/allowableValues}}
|
||||
|
||||
public String value() {
|
||||
return name();
|
||||
}
|
||||
|
||||
public static {{classname}} fromValue(String v) {
|
||||
return valueOf(v);
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
{{#isFormParam}}{{#notFile}}@FormParam(value = "{{paramName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @FormParam(value = "{{paramName}}"{{^required}}, required = false{{/required}}) InputStream {{paramName}}InputStream,
|
||||
@FormParam(value = "{{paramName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}}
|
@ -0,0 +1 @@
|
||||
@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}")
|
@ -0,0 +1 @@
|
||||
{{#isHeaderParam}}@HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}
|
@ -0,0 +1,14 @@
|
||||
package {{package}};
|
||||
|
||||
{{#imports}}import {{import}};
|
||||
{{/imports}}
|
||||
|
||||
{{#models}}
|
||||
{{#model}}{{#description}}
|
||||
/**
|
||||
* {{description}}
|
||||
**/{{/description}}
|
||||
{{#isEnum}}{{>enumClass}}{{/isEnum}}
|
||||
{{^isEnum}}{{>pojo}}{{/isEnum}}
|
||||
{{/model}}
|
||||
{{/models}}
|
@ -0,0 +1 @@
|
||||
{{#isPathParam}}@PathParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}
|
@ -0,0 +1,74 @@
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.Objects;
|
||||
{{#description}}@ApiModel(description = "{{{description}}}"){{/description}}
|
||||
|
||||
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {{#serializableModel}}implements Serializable{{/serializableModel}} {
|
||||
{{#vars}}{{#isEnum}}
|
||||
|
||||
{{>enumClass}}{{/isEnum}}{{#items.isEnum}}{{#items}}
|
||||
|
||||
{{>enumClass}}{{/items}}{{/items.isEnum}}
|
||||
private {{{datatypeWithEnum}}} {{name}} = {{{defaultValue}}};{{/vars}}
|
||||
|
||||
{{#vars}}
|
||||
/**{{#description}}
|
||||
* {{{description}}}{{/description}}{{#minimum}}
|
||||
* minimum: {{minimum}}{{/minimum}}{{#maximum}}
|
||||
* maximum: {{maximum}}{{/maximum}}
|
||||
**/
|
||||
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
this.{{name}} = {{name}};
|
||||
return this;
|
||||
}
|
||||
|
||||
{{#vendorExtensions.extraAnnotation}}{{vendorExtensions.extraAnnotation}}{{/vendorExtensions.extraAnnotation}}
|
||||
@ApiModelProperty({{#example}}example = "{{example}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
|
||||
public {{{datatypeWithEnum}}} {{getter}}() {
|
||||
return {{name}};
|
||||
}
|
||||
public void {{setter}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
this.{{name}} = {{name}};
|
||||
}
|
||||
|
||||
{{/vars}}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
{{classname}} {{classVarName}} = ({{classname}}) o;{{#hasVars}}
|
||||
return {{#vars}}Objects.equals({{name}}, {{classVarName}}.{{name}}){{#hasMore}} &&
|
||||
{{/hasMore}}{{^hasMore}};{{/hasMore}}{{/vars}}{{/hasVars}}{{^hasVars}}
|
||||
return true;{{/hasVars}}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash({{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class {{classname}} {\n");
|
||||
{{#parent}}sb.append(" ").append(toIndentedString(super.toString())).append("\n");{{/parent}}
|
||||
{{#vars}}sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n");
|
||||
{{/vars}}sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>{{groupId}}</groupId>
|
||||
<artifactId>{{artifactId}}</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>{{artifactId}}</name>
|
||||
<version>{{artifactVersion}}</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>1.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>6.8.8</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bsh</artifactId>
|
||||
<groupId>org.beanshell</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
</properties>
|
||||
</project>
|
@ -0,0 +1 @@
|
||||
{{#isQueryParam}}@QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}
|
@ -12,6 +12,7 @@ io.swagger.codegen.languages.JavaClientCodegen
|
||||
io.swagger.codegen.languages.JavaJerseyServerCodegen
|
||||
io.swagger.codegen.languages.JavaCXFServerCodegen
|
||||
io.swagger.codegen.languages.JavaResteasyServerCodegen
|
||||
io.swagger.codegen.languages.JavaJAXRSSpecServerCodegen
|
||||
io.swagger.codegen.languages.JavaInflectorServerCodegen
|
||||
io.swagger.codegen.languages.JavascriptClientCodegen
|
||||
io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen
|
||||
|
201
samples/server/petstore/jaxrs-spec/LICENSE
Normal file
201
samples/server/petstore/jaxrs-spec/LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
76
samples/server/petstore/jaxrs-spec/pom.xml
Normal file
76
samples/server/petstore/jaxrs-spec/pom.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>wasdev</groupId>
|
||||
<artifactId>autogen-server</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<name>autogen-server</name>
|
||||
<version>1.0.0</version>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<configuration>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>1.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>6.8.8</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>junit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>bsh</artifactId>
|
||||
<groupId>org.beanshell</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
</properties>
|
||||
</project>
|
@ -0,0 +1,9 @@
|
||||
package com.ibm.ws.petstoresample;
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
import javax.ws.rs.core.Application;
|
||||
|
||||
@ApplicationPath("/")
|
||||
public class RestApplication extends Application {
|
||||
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package com.ibm.ws.petstoresample.api;
|
||||
|
||||
import com.ibm.ws.petstoresample.model.Pet;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Path("/pets")
|
||||
|
||||
@Api(description = "the pets API")
|
||||
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2016-06-06T11:04:02.369-04:00")
|
||||
|
||||
public class PetsApi {
|
||||
|
||||
@POST
|
||||
|
||||
@Consumes({ "application/json", "application/xml" })
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Add a new pet to the store", notes = "", response = void.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write_pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read_pets", description = "read your pets")
|
||||
})
|
||||
}, tags={ "pet", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 405, message = "Invalid input", response = void.class) })
|
||||
public Response addPet(Pet body) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/{petId}")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Deletes a pet", notes = "", response = void.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write_pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read_pets", description = "read your pets")
|
||||
})
|
||||
}, tags={ "pet", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 400, message = "Invalid pet value", response = void.class) })
|
||||
public Response deletePet(@HeaderParam("api_key") String apiKey,@PathParam("petId") Long petId) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/findByStatus")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write_pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read_pets", description = "read your pets")
|
||||
})
|
||||
}, tags={ "pet", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
|
||||
@ApiResponse(code = 400, message = "Invalid status value", response = Pet.class, responseContainer = "List") })
|
||||
public Response findPetsByStatus(@QueryParam("status") List<String> status) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/findByTags")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write_pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read_pets", description = "read your pets")
|
||||
})
|
||||
}, tags={ "pet", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
|
||||
@ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class, responseContainer = "List") })
|
||||
public Response findPetsByTags(@QueryParam("tags") List<String> tags) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{petId}")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write_pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read_pets", description = "read your pets")
|
||||
}),
|
||||
@Authorization(value = "api_key")
|
||||
}, tags={ "pet", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Pet.class),
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class),
|
||||
@ApiResponse(code = 404, message = "Pet not found", response = Pet.class) })
|
||||
public Response getPetById(@PathParam("petId") Long petId) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@PUT
|
||||
|
||||
@Consumes({ "application/json", "application/xml" })
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Update an existing pet", notes = "", response = void.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write_pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read_pets", description = "read your pets")
|
||||
})
|
||||
}, tags={ "pet", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied", response = void.class),
|
||||
@ApiResponse(code = 404, message = "Pet not found", response = void.class),
|
||||
@ApiResponse(code = 405, message = "Validation exception", response = void.class) })
|
||||
public Response updatePet(Pet body) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/{petId}")
|
||||
@Consumes({ "application/x-www-form-urlencoded" })
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = void.class, authorizations = {
|
||||
@Authorization(value = "petstore_auth", scopes = {
|
||||
@AuthorizationScope(scope = "write_pets", description = "modify pets in your account"),
|
||||
@AuthorizationScope(scope = "read_pets", description = "read your pets")
|
||||
})
|
||||
}, tags={ "pet" })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 405, message = "Invalid input", response = void.class) })
|
||||
public Response updatePetWithForm(@PathParam("petId") String petId,@FormParam(value = "name") String name,@FormParam(value = "status") String status) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
package com.ibm.ws.petstoresample.api;
|
||||
|
||||
import com.ibm.ws.petstoresample.model.Order;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Path("/stores")
|
||||
|
||||
@Api(description = "the stores API")
|
||||
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2016-06-06T11:04:02.369-04:00")
|
||||
|
||||
public class StoresApi {
|
||||
|
||||
@DELETE
|
||||
@Path("/order/{orderId}")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = void.class, tags={ "store", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied", response = void.class),
|
||||
@ApiResponse(code = 404, message = "Order not found", response = void.class) })
|
||||
public Response deleteOrder(@PathParam("orderId") String orderId) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/order/{orderId}")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class, tags={ "store", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
|
||||
@ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class),
|
||||
@ApiResponse(code = 404, message = "Order not found", response = Order.class) })
|
||||
public Response getOrderById(@PathParam("orderId") String orderId) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/order")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store" })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = Order.class),
|
||||
@ApiResponse(code = 400, message = "Invalid Order", response = Order.class) })
|
||||
public Response placeOrder(Order body) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,115 @@
|
||||
package com.ibm.ws.petstoresample.api;
|
||||
|
||||
import com.ibm.ws.petstoresample.model.User;
|
||||
import java.util.List;
|
||||
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Path("/users")
|
||||
|
||||
@Api(description = "the users API")
|
||||
|
||||
|
||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSSpecServerCodegen", date = "2016-06-06T11:04:02.369-04:00")
|
||||
|
||||
public class UsersApi {
|
||||
|
||||
@POST
|
||||
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = void.class) })
|
||||
public Response createUser(User body) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/createWithArray")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = void.class, tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = void.class) })
|
||||
public Response createUsersWithArrayInput(List<User> body) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/createWithList")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = void.class, tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = void.class) })
|
||||
public Response createUsersWithListInput(List<User> body) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/{username}")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 400, message = "Invalid username supplied", response = void.class),
|
||||
@ApiResponse(code = 404, message = "User not found", response = void.class) })
|
||||
public Response deleteUser(@PathParam("username") String username) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/{username}")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = User.class),
|
||||
@ApiResponse(code = 400, message = "Invalid username supplied", response = User.class),
|
||||
@ApiResponse(code = 404, message = "User not found", response = User.class) })
|
||||
public Response getUserByName(@PathParam("username") String username) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/login")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = String.class),
|
||||
@ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) })
|
||||
public Response loginUser(@QueryParam("username") String username,@QueryParam("password") String password) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/logout")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Logs out current logged in user session", notes = "", response = void.class, tags={ "user", })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 200, message = "successful operation", response = void.class) })
|
||||
public Response logoutUser() {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("/{username}")
|
||||
|
||||
@Produces({ "application/json", "application/xml" })
|
||||
@ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user" })
|
||||
@ApiResponses(value = {
|
||||
@ApiResponse(code = 400, message = "Invalid user supplied", response = void.class),
|
||||
@ApiResponse(code = 404, message = "User not found", response = void.class) })
|
||||
public Response updateUser(@PathParam("username") String username,User body) {
|
||||
return Response.ok().entity("magic!").build();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,87 @@
|
||||
package com.ibm.ws.petstoresample.model;
|
||||
|
||||
|
||||
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class Category {
|
||||
|
||||
private Long id = null;
|
||||
private String name = null;
|
||||
|
||||
/**
|
||||
**/
|
||||
public Category id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Category name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Category category = (Category) o;
|
||||
return Objects.equals(id, category.id) &&
|
||||
Objects.equals(name, category.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Category {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
package com.ibm.ws.petstoresample.model;
|
||||
|
||||
|
||||
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class Order {
|
||||
|
||||
private Long id = null;
|
||||
private Long petId = null;
|
||||
private Integer quantity = null;
|
||||
private javax.xml.datatype.XMLGregorianCalendar shipDate = null;
|
||||
private String status = null;
|
||||
private Boolean complete = null;
|
||||
|
||||
/**
|
||||
**/
|
||||
public Order id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Order petId(Long petId) {
|
||||
this.petId = petId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public Long getPetId() {
|
||||
return petId;
|
||||
}
|
||||
public void setPetId(Long petId) {
|
||||
this.petId = petId;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Order quantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public Integer getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
public void setQuantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Order shipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public javax.xml.datatype.XMLGregorianCalendar getShipDate() {
|
||||
return shipDate;
|
||||
}
|
||||
public void setShipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
**/
|
||||
public Order status(String status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "Order Status")
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Order complete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public Boolean getComplete() {
|
||||
return complete;
|
||||
}
|
||||
public void setComplete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Order order = (Order) o;
|
||||
return Objects.equals(id, order.id) &&
|
||||
Objects.equals(petId, order.petId) &&
|
||||
Objects.equals(quantity, order.quantity) &&
|
||||
Objects.equals(shipDate, order.shipDate) &&
|
||||
Objects.equals(status, order.status) &&
|
||||
Objects.equals(complete, order.complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, petId, quantity, shipDate, status, complete);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Order {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" petId: ").append(toIndentedString(petId)).append("\n");
|
||||
sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n");
|
||||
sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append(" complete: ").append(toIndentedString(complete)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
package com.ibm.ws.petstoresample.model;
|
||||
|
||||
import com.ibm.ws.petstoresample.model.Category;
|
||||
import com.ibm.ws.petstoresample.model.Tag;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class Pet {
|
||||
|
||||
private Long id = null;
|
||||
private Category category = null;
|
||||
private String name = null;
|
||||
private List<String> photoUrls = new ArrayList<String>();
|
||||
private List<Tag> tags = new ArrayList<Tag>();
|
||||
private String status = null;
|
||||
|
||||
/**
|
||||
**/
|
||||
public Pet id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Pet category(Category category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public Category getCategory() {
|
||||
return category;
|
||||
}
|
||||
public void setCategory(Category category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Pet name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "doggie", required = true, value = "")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Pet photoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", required = true, value = "")
|
||||
public List<String> getPhotoUrls() {
|
||||
return photoUrls;
|
||||
}
|
||||
public void setPhotoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Pet tags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public List<Tag> getTags() {
|
||||
return tags;
|
||||
}
|
||||
public void setTags(List<Tag> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
**/
|
||||
public Pet status(String status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "pet status in the store")
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Pet pet = (Pet) o;
|
||||
return Objects.equals(id, pet.id) &&
|
||||
Objects.equals(category, pet.category) &&
|
||||
Objects.equals(name, pet.name) &&
|
||||
Objects.equals(photoUrls, pet.photoUrls) &&
|
||||
Objects.equals(tags, pet.tags) &&
|
||||
Objects.equals(status, pet.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, category, name, photoUrls, tags, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Pet {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" category: ").append(toIndentedString(category)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n");
|
||||
sb.append(" tags: ").append(toIndentedString(tags)).append("\n");
|
||||
sb.append(" status: ").append(toIndentedString(status)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.ibm.ws.petstoresample.model;
|
||||
|
||||
|
||||
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class Tag {
|
||||
|
||||
private Long id = null;
|
||||
private String name = null;
|
||||
|
||||
/**
|
||||
**/
|
||||
public Tag id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public Tag name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Tag tag = (Tag) o;
|
||||
return Objects.equals(id, tag.id) &&
|
||||
Objects.equals(name, tag.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class Tag {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" name: ").append(toIndentedString(name)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
@ -0,0 +1,202 @@
|
||||
package com.ibm.ws.petstoresample.model;
|
||||
|
||||
|
||||
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
public class User {
|
||||
|
||||
private Long id = null;
|
||||
private String username = null;
|
||||
private String firstName = null;
|
||||
private String lastName = null;
|
||||
private String email = null;
|
||||
private String password = null;
|
||||
private String phone = null;
|
||||
private Integer userStatus = null;
|
||||
|
||||
/**
|
||||
**/
|
||||
public User id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public User username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public User firstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public User lastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public User email(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public User password(String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
**/
|
||||
public User phone(String phone) {
|
||||
this.phone = phone;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* User Status
|
||||
**/
|
||||
public User userStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@ApiModelProperty(example = "null", value = "User Status")
|
||||
public Integer getUserStatus() {
|
||||
return userStatus;
|
||||
}
|
||||
public void setUserStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
User user = (User) o;
|
||||
return Objects.equals(id, user.id) &&
|
||||
Objects.equals(username, user.username) &&
|
||||
Objects.equals(firstName, user.firstName) &&
|
||||
Objects.equals(lastName, user.lastName) &&
|
||||
Objects.equals(email, user.email) &&
|
||||
Objects.equals(password, user.password) &&
|
||||
Objects.equals(phone, user.phone) &&
|
||||
Objects.equals(userStatus, user.userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("class User {\n");
|
||||
|
||||
sb.append(" id: ").append(toIndentedString(id)).append("\n");
|
||||
sb.append(" username: ").append(toIndentedString(username)).append("\n");
|
||||
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
|
||||
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
|
||||
sb.append(" email: ").append(toIndentedString(email)).append("\n");
|
||||
sb.append(" password: ").append(toIndentedString(password)).append("\n");
|
||||
sb.append(" phone: ").append(toIndentedString(phone)).append("\n");
|
||||
sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n");
|
||||
sb.append("}");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the given object to string with each line indented by 4 spaces
|
||||
* (except the first line).
|
||||
*/
|
||||
private String toIndentedString(Object o) {
|
||||
if (o == null) {
|
||||
return "null";
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
}
|
674
samples/server/petstore/jaxrs-spec/swagger.json
Normal file
674
samples/server/petstore/jaxrs-spec/swagger.json
Normal file
@ -0,0 +1,674 @@
|
||||
{
|
||||
"swagger" : "2.0",
|
||||
"info" : {
|
||||
"description" : "This is a sample server Petstore server.\n\n[Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net.\n\nFor this sample, you can use the api key `special-key` to test the authorization filters\n",
|
||||
"version" : "1.0.0",
|
||||
"title" : "Swagger Petstore",
|
||||
"termsOfService" : "http://helloreverb.com/terms/",
|
||||
"contact" : {
|
||||
"name" : "apiteam@swagger.io"
|
||||
},
|
||||
"license" : {
|
||||
"name" : "Apache 2.0",
|
||||
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
}
|
||||
},
|
||||
"host" : "petstore.swagger.io",
|
||||
"basePath" : "/v2",
|
||||
"schemes" : [ "http" ],
|
||||
"paths" : {
|
||||
"/pets" : {
|
||||
"post" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Add a new pet to the store",
|
||||
"description" : "",
|
||||
"operationId" : "addPet",
|
||||
"consumes" : [ "application/json", "application/xml" ],
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "Pet object that needs to be added to the store",
|
||||
"required" : false,
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Pet"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"405" : {
|
||||
"description" : "Invalid input"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write_pets", "read_pets" ]
|
||||
} ]
|
||||
},
|
||||
"put" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Update an existing pet",
|
||||
"description" : "",
|
||||
"operationId" : "updatePet",
|
||||
"consumes" : [ "application/json", "application/xml" ],
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "Pet object that needs to be added to the store",
|
||||
"required" : false,
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Pet"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"400" : {
|
||||
"description" : "Invalid ID supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "Pet not found"
|
||||
},
|
||||
"405" : {
|
||||
"description" : "Validation exception"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write_pets", "read_pets" ]
|
||||
} ]
|
||||
}
|
||||
},
|
||||
"/pets/findByStatus" : {
|
||||
"get" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Finds Pets by status",
|
||||
"description" : "Multiple status values can be provided with comma seperated strings",
|
||||
"operationId" : "findPetsByStatus",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"name" : "status",
|
||||
"in" : "query",
|
||||
"description" : "Status values that need to be considered for filter",
|
||||
"required" : false,
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"collectionFormat" : "multi"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid status value"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write_pets", "read_pets" ]
|
||||
} ]
|
||||
}
|
||||
},
|
||||
"/pets/findByTags" : {
|
||||
"get" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Finds Pets by tags",
|
||||
"description" : "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.",
|
||||
"operationId" : "findPetsByTags",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"name" : "tags",
|
||||
"in" : "query",
|
||||
"description" : "Tags to filter by",
|
||||
"required" : false,
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"collectionFormat" : "multi"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/Pet"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid tag value"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write_pets", "read_pets" ]
|
||||
} ]
|
||||
}
|
||||
},
|
||||
"/pets/{petId}" : {
|
||||
"get" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Find pet by ID",
|
||||
"description" : "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions",
|
||||
"operationId" : "getPetById",
|
||||
"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" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Pet"
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid ID supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "Pet not found"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"api_key" : [ ]
|
||||
}, {
|
||||
"petstore_auth" : [ "write_pets", "read_pets" ]
|
||||
} ]
|
||||
},
|
||||
"post" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Updates a pet in the store with form data",
|
||||
"description" : "",
|
||||
"operationId" : "updatePetWithForm",
|
||||
"consumes" : [ "application/x-www-form-urlencoded" ],
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"name" : "petId",
|
||||
"in" : "path",
|
||||
"description" : "ID of pet that needs to be updated",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
}, {
|
||||
"name" : "name",
|
||||
"in" : "formData",
|
||||
"description" : "Updated name of the pet",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
}, {
|
||||
"name" : "status",
|
||||
"in" : "formData",
|
||||
"description" : "Updated status of the pet",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"405" : {
|
||||
"description" : "Invalid input"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write_pets", "read_pets" ]
|
||||
} ]
|
||||
},
|
||||
"delete" : {
|
||||
"tags" : [ "pet" ],
|
||||
"summary" : "Deletes a pet",
|
||||
"description" : "",
|
||||
"operationId" : "deletePet",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"name" : "api_key",
|
||||
"in" : "header",
|
||||
"description" : "",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
}, {
|
||||
"name" : "petId",
|
||||
"in" : "path",
|
||||
"description" : "Pet id to delete",
|
||||
"required" : true,
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
} ],
|
||||
"responses" : {
|
||||
"400" : {
|
||||
"description" : "Invalid pet value"
|
||||
}
|
||||
},
|
||||
"security" : [ {
|
||||
"petstore_auth" : [ "write_pets", "read_pets" ]
|
||||
} ]
|
||||
}
|
||||
},
|
||||
"/stores/order" : {
|
||||
"post" : {
|
||||
"tags" : [ "store" ],
|
||||
"summary" : "Place an order for a pet",
|
||||
"description" : "",
|
||||
"operationId" : "placeOrder",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "order placed for purchasing the pet",
|
||||
"required" : false,
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Order"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Order"
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid Order"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/stores/order/{orderId}" : {
|
||||
"get" : {
|
||||
"tags" : [ "store" ],
|
||||
"summary" : "Find purchase order by ID",
|
||||
"description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
|
||||
"operationId" : "getOrderById",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"name" : "orderId",
|
||||
"in" : "path",
|
||||
"description" : "ID of pet that needs to be fetched",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/Order"
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid ID supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "Order not found"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete" : {
|
||||
"tags" : [ "store" ],
|
||||
"summary" : "Delete purchase order by ID",
|
||||
"description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
|
||||
"operationId" : "deleteOrder",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"name" : "orderId",
|
||||
"in" : "path",
|
||||
"description" : "ID of the order that needs to be deleted",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"400" : {
|
||||
"description" : "Invalid ID supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "Order not found"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users" : {
|
||||
"post" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Create user",
|
||||
"description" : "This can only be done by the logged in user.",
|
||||
"operationId" : "createUser",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "Created user object",
|
||||
"required" : false,
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/User"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"default" : {
|
||||
"description" : "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/createWithArray" : {
|
||||
"post" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Creates list of users with given input array",
|
||||
"description" : "",
|
||||
"operationId" : "createUsersWithArrayInput",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "List of user object",
|
||||
"required" : false,
|
||||
"schema" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/User"
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"default" : {
|
||||
"description" : "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/createWithList" : {
|
||||
"post" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Creates list of users with given input array",
|
||||
"description" : "",
|
||||
"operationId" : "createUsersWithListInput",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "List of user object",
|
||||
"required" : false,
|
||||
"schema" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/User"
|
||||
}
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"default" : {
|
||||
"description" : "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/login" : {
|
||||
"get" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Logs user into the system",
|
||||
"description" : "",
|
||||
"operationId" : "loginUser",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"name" : "username",
|
||||
"in" : "query",
|
||||
"description" : "The user name for login",
|
||||
"required" : false,
|
||||
"type" : "string"
|
||||
}, {
|
||||
"name" : "password",
|
||||
"in" : "query",
|
||||
"description" : "The password for login in clear text",
|
||||
"required" : false,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid username/password supplied"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/logout" : {
|
||||
"get" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Logs out current logged in user session",
|
||||
"description" : "",
|
||||
"operationId" : "logoutUser",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ ],
|
||||
"responses" : {
|
||||
"default" : {
|
||||
"description" : "successful operation"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{username}" : {
|
||||
"get" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Get user by user name",
|
||||
"description" : "",
|
||||
"operationId" : "getUserByName",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"name" : "username",
|
||||
"in" : "path",
|
||||
"description" : "The name that needs to be fetched. Use user1 for testing.",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"200" : {
|
||||
"description" : "successful operation",
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/User"
|
||||
}
|
||||
},
|
||||
"400" : {
|
||||
"description" : "Invalid username supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "User not found"
|
||||
}
|
||||
}
|
||||
},
|
||||
"put" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Updated user",
|
||||
"description" : "This can only be done by the logged in user.",
|
||||
"operationId" : "updateUser",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"name" : "username",
|
||||
"in" : "path",
|
||||
"description" : "name that need to be deleted",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
}, {
|
||||
"in" : "body",
|
||||
"name" : "body",
|
||||
"description" : "Updated user object",
|
||||
"required" : false,
|
||||
"schema" : {
|
||||
"$ref" : "#/definitions/User"
|
||||
}
|
||||
} ],
|
||||
"responses" : {
|
||||
"400" : {
|
||||
"description" : "Invalid user supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "User not found"
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete" : {
|
||||
"tags" : [ "user" ],
|
||||
"summary" : "Delete user",
|
||||
"description" : "This can only be done by the logged in user.",
|
||||
"operationId" : "deleteUser",
|
||||
"produces" : [ "application/json", "application/xml" ],
|
||||
"parameters" : [ {
|
||||
"name" : "username",
|
||||
"in" : "path",
|
||||
"description" : "The name that needs to be deleted",
|
||||
"required" : true,
|
||||
"type" : "string"
|
||||
} ],
|
||||
"responses" : {
|
||||
"400" : {
|
||||
"description" : "Invalid username supplied"
|
||||
},
|
||||
"404" : {
|
||||
"description" : "User not found"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"securityDefinitions" : {
|
||||
"petstore_auth" : {
|
||||
"type" : "oauth2",
|
||||
"authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog",
|
||||
"flow" : "implicit",
|
||||
"scopes" : {
|
||||
"write_pets" : "modify pets in your account",
|
||||
"read_pets" : "read your pets"
|
||||
}
|
||||
},
|
||||
"api_key" : {
|
||||
"type" : "apiKey",
|
||||
"name" : "api_key",
|
||||
"in" : "header"
|
||||
}
|
||||
},
|
||||
"definitions" : {
|
||||
"User" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"username" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"firstName" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"lastName" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"email" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"password" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"phone" : {
|
||||
"type" : "string"
|
||||
},
|
||||
"userStatus" : {
|
||||
"type" : "integer",
|
||||
"format" : "int32",
|
||||
"description" : "User Status"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Category" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Pet" : {
|
||||
"type" : "object",
|
||||
"required" : [ "name", "photoUrls" ],
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"category" : {
|
||||
"$ref" : "#/definitions/Category"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string",
|
||||
"example" : "doggie"
|
||||
},
|
||||
"photoUrls" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"type" : "string"
|
||||
}
|
||||
},
|
||||
"tags" : {
|
||||
"type" : "array",
|
||||
"items" : {
|
||||
"$ref" : "#/definitions/Tag"
|
||||
}
|
||||
},
|
||||
"status" : {
|
||||
"type" : "string",
|
||||
"description" : "pet status in the store"
|
||||
}
|
||||
}
|
||||
},
|
||||
"Tag" : {
|
||||
"type" : "object",
|
||||
"properties" : {
|
||||
"id" : {
|
||||
"type" : "integer",
|
||||
"format" : "int64"
|
||||
},
|
||||
"name" : {
|
||||
"type" : "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"complete" : {
|
||||
"type" : "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user