Add a new JAX-RS server generator - jaxrs-cxf-cdi (#3940)

* Generate a JAX-RS server that assumes an Apache CXF framework on a Java EE server supporting CDI

* Samples for jaxrs-cxf-cdi

* Don't refer to missing class NotFoundException

* Update samples without missing NotFoundException reference
This commit is contained in:
Nick Maynard 2016-10-10 10:18:27 +01:00 committed by wing328
parent 0712ebc33d
commit dc2b8c29e2
39 changed files with 2443 additions and 1 deletions

View 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/cxf -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-cxf-cdi -o samples/server/petstore/jaxrs-cxf-cdi -DhideGenerationTimestamp=true"
java $JAVA_OPTS -jar $executable $ags

View File

@ -0,0 +1,53 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenProperty;
import java.io.File;
public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen
{
public JavaJAXRSCXFCDIServerCodegen()
{
sourceFolder = "src" + File.separator + "gen" + File.separator + "java";
// Three API templates to support CDI injection
apiTemplateFiles.put("apiService.mustache", ".java");
apiTemplateFiles.put("apiServiceImpl.mustache", ".java");
// Use standard types
typeMapping.put("DateTime", "java.util.Date");
// Updated template directory
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf-cdi";
}
@Override
public String getName()
{
return "jaxrs-cxf-cdi";
}
@Override
public void processOpts()
{
super.processOpts();
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
}
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
super.postProcessModelProperty(model, property);
// Reinstate JsonProperty
model.imports.add("JsonProperty");
}
@Override
public String getHelp()
{
return "Generates a Java JAXRS Server according to JAXRS 2.0 specification, assuming an Apache CXF runtime and a Java EE runtime with CDI enabled.";
}
}

View File

@ -0,0 +1 @@
{{#allowableValues}}allowableValues="{{#values}}{{{.}}}{{^-last}}, {{/-last}}{{/values}}{{^values}}range=[{{#min}}{{.}}{{/min}}{{^min}}-infinity{{/min}}, {{#max}}{{.}}{{/max}}{{^max}}infinity{{/max}}]{{/values}}"{{/allowableValues}}

View File

@ -0,0 +1,55 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
import {{package}}.{{classname}}Service;
import javax.ws.rs.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import io.swagger.annotations.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import java.util.List;
@Path("/{{baseName}}")
@RequestScoped
@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}} {
@Context SecurityContext securityContext;
@Inject {{classname}}Service delegate;
{{#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 delegate.{{nickname}}({{#allParams}}{{#isFile}}inputStream, fileDetail{{/isFile}}{{^isFile}}{{paramName}}{{/isFile}}, {{/allParams}}securityContext);
}
{{/operation}}
}
{{/operations}}

View File

@ -0,0 +1,25 @@
package {{package}};
import {{package}}.*;
import {{modelPackage}}.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
{{#imports}}import {{import}};
{{/imports}}
import java.util.List;
import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
{{>generatedAnnotation}}
{{#operations}}
public interface {{classname}}Service {
{{#operation}}
public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}, {{/allParams}}SecurityContext securityContext);
{{/operation}}
}
{{/operations}}

View File

@ -0,0 +1,31 @@
package {{package}}.impl;
import {{package}}.*;
import {{modelPackage}}.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
{{#imports}}import {{import}};
{{/imports}}
import java.util.List;
import java.io.InputStream;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
{{>generatedAnnotation}}
{{#operations}}
public class {{classname}}ServiceImpl implements {{classname}}Service {
{{#operation}}
@Override
public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}, {{/allParams}}SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
{{/operation}}
}
{{/operations}}

View File

@ -0,0 +1 @@
{{#isBodyParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{{dataType}}} {{paramName}}{{/isBodyParam}}

View File

@ -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);
}
}

View File

@ -0,0 +1 @@
{{#isFormParam}}{{#notFile}}@Multipart(value = "{{paramName}}"{{^required}}, required = false{{/required}}) {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @Multipart(value = "{{paramName}}"{{^required}}, required = false{{/required}}) InputStream {{paramName}}InputStream, @Multipart(value = "{{paramName}}" {{^required}}, required = false{{/required}}) Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}}

View File

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

View File

@ -0,0 +1 @@
{{#isHeaderParam}}@ApiParam(value = "{{{description}}}" {{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}})@HeaderParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isHeaderParam}}

View File

@ -0,0 +1,14 @@
package {{package}};
{{#imports}}import {{import}};
{{/imports}}
{{#models}}
{{#model}}{{#description}}
/**
* {{description}}
**/{{/description}}
{{#isEnum}}{{>enumClass}}{{/isEnum}}
{{^isEnum}}{{>pojo}}{{/isEnum}}
{{/model}}
{{/models}}

View File

@ -0,0 +1 @@
{{#isPathParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) @PathParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isPathParam}}

View File

@ -0,0 +1,75 @@
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}}}")
@JsonProperty("{{baseName}}")
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 ");
}
}

View File

@ -0,0 +1 @@
{{#isQueryParam}}@ApiParam(value = "{{{description}}}"{{#required}},required=true{{/required}}{{#allowableValues}}, {{> allowableValues }}{{/allowableValues}}{{#defaultValue}}, defaultValue="{{{defaultValue}}}"{{/defaultValue}}) {{#defaultValue}}@DefaultValue("{{{defaultValue}}}"){{/defaultValue}} @QueryParam("{{baseName}}") {{{dataType}}} {{paramName}}{{/isQueryParam}}

View File

@ -0,0 +1 @@
{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}}

View File

@ -0,0 +1 @@
{{#isFormParam}}{{#notFile}}{{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}InputStream {{paramName}}InputStream, Attachment {{paramName}}Detail{{/isFile}}{{/isFormParam}}

View File

@ -0,0 +1 @@
{{#isHeaderParam}}{{{dataType}}} {{paramName}}{{/isHeaderParam}}

View File

@ -0,0 +1 @@
{{#isPathParam}}{{{dataType}}} {{paramName}}{{/isPathParam}}

View File

@ -0,0 +1 @@
{{#isQueryParam}}{{{dataType}}} {{paramName}}{{/isQueryParam}}

View File

@ -14,6 +14,7 @@ io.swagger.codegen.languages.JavaJerseyServerCodegen
io.swagger.codegen.languages.JavaCXFServerCodegen
io.swagger.codegen.languages.JavaResteasyServerCodegen
io.swagger.codegen.languages.JavaJAXRSSpecServerCodegen
io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen
io.swagger.codegen.languages.JavaInflectorServerCodegen
io.swagger.codegen.languages.JavascriptClientCodegen
io.swagger.codegen.languages.JavascriptClosureAngularClientCodegen
@ -53,4 +54,3 @@ io.swagger.codegen.languages.LumenServerCodegen
io.swagger.codegen.languages.GoServerCodegen
io.swagger.codegen.languages.ErlangServerCodegen
io.swagger.codegen.languages.UndertowCodegen

View File

@ -0,0 +1,23 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md

View 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.

View File

@ -0,0 +1,60 @@
package io.swagger.api;
import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.ext.multipart.*;
@Path("/v2")
public interface PetApi {
@POST
@Consumes({ "application/json", "application/xml" })
@Produces({ "application/xml", "application/json" })
Response addPet(Pet body);
@DELETE
@Path("/{petId}")
@Produces({ "application/xml", "application/json" })
Response deletePet(@PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey);
@GET
@Path("/findByStatus")
@Produces({ "application/xml", "application/json" })
Response findPetsByStatus(@QueryParam("status") List<String> status);
@GET
@Path("/findByTags")
@Produces({ "application/xml", "application/json" })
Response findPetsByTags(@QueryParam("tags") List<String> tags);
@GET
@Path("/{petId}")
@Produces({ "application/xml", "application/json" })
Response getPetById(@PathParam("petId") Long petId);
@PUT
@Consumes({ "application/json", "application/xml" })
@Produces({ "application/xml", "application/json" })
Response updatePet(Pet body);
@POST
@Path("/{petId}")
@Consumes({ "application/x-www-form-urlencoded" })
@Produces({ "application/xml", "application/json" })
Response updatePetWithForm(@PathParam("petId") Long petId,@Multipart(value = "name", required = false) String name,@Multipart(value = "status", required = false) String status);
@POST
@Path("/{petId}/uploadImage")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json" })
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);
}

View File

@ -0,0 +1,29 @@
package io.swagger.api;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import java.util.List;
import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-07T11:14:51.064+01:00")
public interface PetApiService {
public Response addPet(Pet body, SecurityContext securityContext);
public Response deletePet(Long petId, String apiKey, SecurityContext securityContext);
public Response findPetsByStatus(List<String> status, SecurityContext securityContext);
public Response findPetsByTags(List<String> tags, SecurityContext securityContext);
public Response getPetById(Long petId, SecurityContext securityContext);
public Response updatePet(Pet body, SecurityContext securityContext);
public Response updatePetWithForm(Long petId, String name, String status, SecurityContext securityContext);
public Response uploadFile(Long petId, String additionalMetadata, InputStream fileInputStream, Attachment fileDetail, SecurityContext securityContext);
}

View File

@ -0,0 +1,38 @@
package io.swagger.api;
import java.util.Map;
import io.swagger.model.Order;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.ext.multipart.*;
@Path("/v2")
public interface StoreApi {
@DELETE
@Path("/order/{orderId}")
@Produces({ "application/xml", "application/json" })
Response deleteOrder(@PathParam("orderId") String orderId);
@GET
@Path("/inventory")
@Produces({ "application/json" })
Response getInventory();
@GET
@Path("/order/{orderId}")
@Produces({ "application/xml", "application/json" })
Response getOrderById(@PathParam("orderId") Long orderId);
@POST
@Path("/order")
@Produces({ "application/xml", "application/json" })
Response placeOrder(Order body);
}

View File

@ -0,0 +1,24 @@
package io.swagger.api;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import java.util.Map;
import io.swagger.model.Order;
import java.util.List;
import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-07T11:14:51.064+01:00")
public interface StoreApiService {
public Response deleteOrder(String orderId, SecurityContext securityContext);
public Response getInventory(SecurityContext securityContext);
public Response getOrderById(Long orderId, SecurityContext securityContext);
public Response placeOrder(Order body, SecurityContext securityContext);
}

View File

@ -0,0 +1,58 @@
package io.swagger.api;
import io.swagger.model.User;
import java.util.List;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import org.apache.cxf.jaxrs.ext.multipart.*;
@Path("/v2")
public interface UserApi {
@POST
@Produces({ "application/xml", "application/json" })
Response createUser(User body);
@POST
@Path("/createWithArray")
@Produces({ "application/xml", "application/json" })
Response createUsersWithArrayInput(List<User> body);
@POST
@Path("/createWithList")
@Produces({ "application/xml", "application/json" })
Response createUsersWithListInput(List<User> body);
@DELETE
@Path("/{username}")
@Produces({ "application/xml", "application/json" })
Response deleteUser(@PathParam("username") String username);
@GET
@Path("/{username}")
@Produces({ "application/xml", "application/json" })
Response getUserByName(@PathParam("username") String username);
@GET
@Path("/login")
@Produces({ "application/xml", "application/json" })
Response loginUser(@QueryParam("username") String username,@QueryParam("password") String password);
@GET
@Path("/logout")
@Produces({ "application/xml", "application/json" })
Response logoutUser();
@PUT
@Path("/{username}")
@Produces({ "application/xml", "application/json" })
Response updateUser(@PathParam("username") String username,User body);
}

View File

@ -0,0 +1,28 @@
package io.swagger.api;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import io.swagger.model.User;
import java.util.List;
import java.util.List;
import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-07T11:14:51.064+01:00")
public interface UserApiService {
public Response createUser(User body, SecurityContext securityContext);
public Response createUsersWithArrayInput(List<User> body, SecurityContext securityContext);
public Response createUsersWithListInput(List<User> body, SecurityContext securityContext);
public Response deleteUser(String username, SecurityContext securityContext);
public Response getUserByName(String username, SecurityContext securityContext);
public Response loginUser(String username, String password, SecurityContext securityContext);
public Response logoutUser(SecurityContext securityContext);
public Response updateUser(String username, User body, SecurityContext securityContext);
}

View File

@ -0,0 +1,70 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Category", propOrder =
{ "id", "name"
})
@XmlRootElement(name="Category")
public class Category {
@XmlElement(name="id")
private Long id = null;
@XmlElement(name="name")
private String name = null;
/**
**/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public String getName() {
return name;
}
public void setName(String name) {
this.name = 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 static String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,83 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ModelApiResponse", propOrder =
{ "code", "type", "message"
})
@XmlRootElement(name="ModelApiResponse")
public class ModelApiResponse {
@XmlElement(name="code")
private Integer code = null;
@XmlElement(name="type")
private String type = null;
@XmlElement(name="message")
private String message = null;
/**
**/
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
/**
**/
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
/**
**/
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ModelApiResponse {\n");
sb.append(" code: ").append(toIndentedString(code)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" message: ").append(toIndentedString(message)).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 static String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,146 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Order", propOrder =
{ "id", "petId", "quantity", "shipDate", "status", "complete"
})
@XmlRootElement(name="Order")
public class Order {
@XmlElement(name="id")
private Long id = null;
@XmlElement(name="petId")
private Long petId = null;
@XmlElement(name="quantity")
private Integer quantity = null;
@XmlElement(name="shipDate")
private java.util.Date shipDate = null;
@XmlType(name="StatusEnum")
@XmlEnum
public enum StatusEnum {
PLACED(String.valueOf("placed")), APPROVED(String.valueOf("approved")), DELIVERED(String.valueOf("delivered"));
private String value;
StatusEnum (String v) {
value = v;
}
public String value() {
return value;
}
public static StatusEnum fromValue(String v) {
return valueOf(v);
}
}
@XmlElement(name="status")
private StatusEnum status = null;
@XmlElement(name="complete")
private Boolean complete = false;
/**
**/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public Long getPetId() {
return petId;
}
public void setPetId(Long petId) {
this.petId = petId;
}
/**
**/
public Integer getQuantity() {
return quantity;
}
public void setQuantity(Integer quantity) {
this.quantity = quantity;
}
/**
**/
public java.util.Date getShipDate() {
return shipDate;
}
public void setShipDate(java.util.Date shipDate) {
this.shipDate = shipDate;
}
/**
* Order Status
**/
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = status;
}
/**
**/
public Boolean getComplete() {
return complete;
}
public void setComplete(Boolean complete) {
this.complete = 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 static String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,150 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.model.Category;
import io.swagger.model.Tag;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Pet", propOrder =
{ "id", "category", "name", "photoUrls", "tags", "status"
})
@XmlRootElement(name="Pet")
public class Pet {
@XmlElement(name="id")
private Long id = null;
@XmlElement(name="category")
private Category category = null;
@XmlElement(name="name")
private String name = null;
@XmlElement(name="photoUrls")
private List<String> photoUrls = new ArrayList<String>();
@XmlElement(name="tags")
private List<Tag> tags = new ArrayList<Tag>();
@XmlType(name="StatusEnum")
@XmlEnum
public enum StatusEnum {
AVAILABLE(String.valueOf("available")), PENDING(String.valueOf("pending")), SOLD(String.valueOf("sold"));
private String value;
StatusEnum (String v) {
value = v;
}
public String value() {
return value;
}
public static StatusEnum fromValue(String v) {
return valueOf(v);
}
}
@XmlElement(name="status")
private StatusEnum status = null;
/**
**/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
/**
**/
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
**/
public List<String> getPhotoUrls() {
return photoUrls;
}
public void setPhotoUrls(List<String> photoUrls) {
this.photoUrls = photoUrls;
}
/**
**/
public List<Tag> getTags() {
return tags;
}
public void setTags(List<Tag> tags) {
this.tags = tags;
}
/**
* pet status in the store
**/
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = 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 static String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,70 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Tag", propOrder =
{ "id", "name"
})
@XmlRootElement(name="Tag")
public class Tag {
@XmlElement(name="id")
private Long id = null;
@XmlElement(name="name")
private String name = null;
/**
**/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public String getName() {
return name;
}
public void setName(String name) {
this.name = 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 static String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,149 @@
package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlEnum;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "User", propOrder =
{ "id", "username", "firstName", "lastName", "email", "password", "phone", "userStatus"
})
@XmlRootElement(name="User")
public class User {
@XmlElement(name="id")
private Long id = null;
@XmlElement(name="username")
private String username = null;
@XmlElement(name="firstName")
private String firstName = null;
@XmlElement(name="lastName")
private String lastName = null;
@XmlElement(name="email")
private String email = null;
@XmlElement(name="password")
private String password = null;
@XmlElement(name="phone")
private String phone = null;
@XmlElement(name="userStatus")
private Integer userStatus = null;
/**
**/
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
/**
**/
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
/**
**/
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
/**
**/
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
/**
**/
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
/**
**/
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
/**
* User Status
**/
public Integer getUserStatus() {
return userStatus;
}
public void setUserStatus(Integer userStatus) {
this.userStatus = 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 static String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,64 @@
package io.swagger.api.impl;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import java.util.List;
import io.swagger.api.NotFoundException;
import java.io.InputStream;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-06T16:59:45.939+01:00")
public class PetApiServiceImpl implements PetApiService {
@Override
public Response addPet(Pet body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response deletePet(Long petId, String apiKey, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response findPetsByStatus(List<String> status, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response findPetsByTags(List<String> tags, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response getPetById(Long petId, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response updatePet(Pet body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response updatePetWithForm(Long petId, String name, String status, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response uploadFile(Long petId, String additionalMetadata, InputStream fileInputStream, Attachment fileDetail, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
}

View File

@ -0,0 +1,43 @@
package io.swagger.api.impl;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import java.util.Map;
import io.swagger.model.Order;
import java.util.List;
import io.swagger.api.NotFoundException;
import java.io.InputStream;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-06T16:59:45.939+01:00")
public class StoreApiServiceImpl implements StoreApiService {
@Override
public Response deleteOrder(String orderId, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response getInventory(SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response getOrderById(Long orderId, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response placeOrder(Order body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
}

View File

@ -0,0 +1,63 @@
package io.swagger.api.impl;
import io.swagger.api.*;
import io.swagger.model.*;
import org.apache.cxf.jaxrs.ext.multipart.Attachment;
import io.swagger.model.User;
import java.util.List;
import java.util.List;
import io.swagger.api.NotFoundException;
import java.io.InputStream;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-06T16:59:45.939+01:00")
public class UserApiServiceImpl implements UserApiService {
@Override
public Response createUser(User body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response createUsersWithArrayInput(List<User> body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response createUsersWithListInput(List<User> body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response deleteUser(String username, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response getUserByName(String username, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response loginUser(String username, String password, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response logoutUser(SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
@Override
public Response updateUser(String username, User body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
}
}

View File

@ -0,0 +1,831 @@
{
"swagger" : "2.0",
"info" : {
"description" : "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.",
"version" : "1.0.0",
"title" : "Swagger Petstore",
"termsOfService" : "http://swagger.io/terms/",
"contact" : {
"email" : "apiteam@swagger.io"
},
"license" : {
"name" : "Apache 2.0",
"url" : "http://www.apache.org/licenses/LICENSE-2.0.html"
}
},
"host" : "petstore.swagger.io",
"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" : [ "http" ],
"paths" : {
"/pet" : {
"post" : {
"tags" : [ "pet" ],
"summary" : "Add a new pet to the store",
"description" : "",
"operationId" : "addPet",
"consumes" : [ "application/json", "application/xml" ],
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : true,
"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/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Pet object that needs to be added to the store",
"required" : true,
"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" ]
} ]
}
},
"/pet/findByStatus" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Finds Pets by status",
"description" : "Multiple status values can be provided with comma separated strings",
"operationId" : "findPetsByStatus",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "status",
"in" : "query",
"description" : "Status values that need to be considered for filter",
"required" : true,
"type" : "array",
"items" : {
"type" : "string",
"default" : "available",
"enum" : [ "available", "pending", "sold" ]
},
"collectionFormat" : "csv"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
},
"400" : {
"description" : "Invalid status value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/findByTags" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Finds Pets by tags",
"description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
"operationId" : "findPetsByTags",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "tags",
"in" : "query",
"description" : "Tags to filter by",
"required" : true,
"type" : "array",
"items" : {
"type" : "string"
},
"collectionFormat" : "csv"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/Pet"
}
}
},
"400" : {
"description" : "Invalid tag value"
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/pet/{petId}" : {
"get" : {
"tags" : [ "pet" ],
"summary" : "Find pet by ID",
"description" : "Returns a single pet",
"operationId" : "getPetById",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet to return",
"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" : [ ]
} ]
},
"post" : {
"tags" : [ "pet" ],
"summary" : "Updates a pet in the store with form data",
"description" : "",
"operationId" : "updatePetWithForm",
"consumes" : [ "application/x-www-form-urlencoded" ],
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet that needs to be updated",
"required" : true,
"type" : "integer",
"format" : "int64"
}, {
"name" : "name",
"in" : "formData",
"description" : "Updated name of the pet",
"required" : false,
"type" : "string"
}, {
"name" : "status",
"in" : "formData",
"description" : "Updated status of the pet",
"required" : false,
"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/xml", "application/json" ],
"parameters" : [ {
"name" : "api_key",
"in" : "header",
"required" : false,
"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" ]
} ]
}
},
"/pet/{petId}/uploadImage" : {
"post" : {
"tags" : [ "pet" ],
"summary" : "uploads an image",
"description" : "",
"operationId" : "uploadFile",
"consumes" : [ "multipart/form-data" ],
"produces" : [ "application/json" ],
"parameters" : [ {
"name" : "petId",
"in" : "path",
"description" : "ID of pet to update",
"required" : true,
"type" : "integer",
"format" : "int64"
}, {
"name" : "additionalMetadata",
"in" : "formData",
"description" : "Additional data to pass to server",
"required" : false,
"type" : "string"
}, {
"name" : "file",
"in" : "formData",
"description" : "file to upload",
"required" : false,
"type" : "file"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/ApiResponse"
}
}
},
"security" : [ {
"petstore_auth" : [ "write:pets", "read:pets" ]
} ]
}
},
"/store/inventory" : {
"get" : {
"tags" : [ "store" ],
"summary" : "Returns pet inventories by status",
"description" : "Returns a map of status codes to quantities",
"operationId" : "getInventory",
"produces" : [ "application/json" ],
"parameters" : [ ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"type" : "object",
"additionalProperties" : {
"type" : "integer",
"format" : "int32"
}
}
}
},
"security" : [ {
"api_key" : [ ]
} ]
}
},
"/store/order" : {
"post" : {
"tags" : [ "store" ],
"summary" : "Place an order for a pet",
"description" : "",
"operationId" : "placeOrder",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "order placed for purchasing the pet",
"required" : true,
"schema" : {
"$ref" : "#/definitions/Order"
}
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Order"
}
},
"400" : {
"description" : "Invalid Order"
}
}
}
},
"/store/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/xml", "application/json" ],
"parameters" : [ {
"name" : "orderId",
"in" : "path",
"description" : "ID of pet that needs to be fetched",
"required" : true,
"type" : "integer",
"maximum" : 5.0,
"minimum" : 1.0,
"format" : "int64"
} ],
"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/xml", "application/json" ],
"parameters" : [ {
"name" : "orderId",
"in" : "path",
"description" : "ID of the order that needs to be deleted",
"required" : true,
"type" : "string",
"minimum" : 1.0
} ],
"responses" : {
"400" : {
"description" : "Invalid ID supplied"
},
"404" : {
"description" : "Order not found"
}
}
}
},
"/user" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Create user",
"description" : "This can only be done by the logged in user.",
"operationId" : "createUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "Created user object",
"required" : true,
"schema" : {
"$ref" : "#/definitions/User"
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/createWithArray" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Creates list of users with given input array",
"description" : "",
"operationId" : "createUsersWithArrayInput",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : true,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/createWithList" : {
"post" : {
"tags" : [ "user" ],
"summary" : "Creates list of users with given input array",
"description" : "",
"operationId" : "createUsersWithListInput",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"in" : "body",
"name" : "body",
"description" : "List of user object",
"required" : true,
"schema" : {
"type" : "array",
"items" : {
"$ref" : "#/definitions/User"
}
}
} ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/login" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Logs user into the system",
"description" : "",
"operationId" : "loginUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ {
"name" : "username",
"in" : "query",
"description" : "The user name for login",
"required" : true,
"type" : "string"
}, {
"name" : "password",
"in" : "query",
"description" : "The password for login in clear text",
"required" : true,
"type" : "string"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"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 toekn expires"
}
}
},
"400" : {
"description" : "Invalid username/password supplied"
}
}
}
},
"/user/logout" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Logs out current logged in user session",
"description" : "",
"operationId" : "logoutUser",
"produces" : [ "application/xml", "application/json" ],
"parameters" : [ ],
"responses" : {
"default" : {
"description" : "successful operation"
}
}
}
},
"/user/{username}" : {
"get" : {
"tags" : [ "user" ],
"summary" : "Get user by user name",
"description" : "",
"operationId" : "getUserByName",
"produces" : [ "application/xml", "application/json" ],
"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/xml", "application/json" ],
"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" : true,
"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/xml", "application/json" ],
"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" : {
"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
}
},
"title" : "Pet Order",
"description" : "An order for a pets from the pet store",
"xml" : {
"name" : "Order"
}
},
"Category" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
}
},
"title" : "Pet catehgry",
"description" : "A category for a pet",
"xml" : {
"name" : "Category"
}
},
"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"
}
},
"title" : "a User",
"description" : "A User who is purchasing from the pet store",
"xml" : {
"name" : "User"
}
},
"Tag" : {
"type" : "object",
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"name" : {
"type" : "string"
}
},
"title" : "Pet Tag",
"description" : "A tag for a pet",
"xml" : {
"name" : "Tag"
}
},
"Pet" : {
"type" : "object",
"required" : [ "name", "photoUrls" ],
"properties" : {
"id" : {
"type" : "integer",
"format" : "int64"
},
"category" : {
"$ref" : "#/definitions/Category"
},
"name" : {
"type" : "string",
"example" : "doggie"
},
"photoUrls" : {
"type" : "array",
"xml" : {
"name" : "photoUrl",
"wrapped" : true
},
"items" : {
"type" : "string"
}
},
"tags" : {
"type" : "array",
"xml" : {
"name" : "tag",
"wrapped" : true
},
"items" : {
"$ref" : "#/definitions/Tag"
}
},
"status" : {
"type" : "string",
"description" : "pet status in the store",
"enum" : [ "available", "pending", "sold" ]
}
},
"title" : "a Pet",
"description" : "A pet for sale in the pet store",
"xml" : {
"name" : "Pet"
}
},
"ApiResponse" : {
"type" : "object",
"properties" : {
"code" : {
"type" : "integer",
"format" : "int32"
},
"type" : {
"type" : "string"
},
"message" : {
"type" : "string"
}
},
"title" : "An uploaded response",
"description" : "Describes the result of uploading an image resource"
}
},
"externalDocs" : {
"description" : "Find out more about Swagger",
"url" : "http://swagger.io"
}
}