From fa72a80b85571480382c235c44bb0f92c793435f Mon Sep 17 00:00:00 2001 From: "J. Fiala" Date: Tue, 7 Feb 2017 22:04:25 +0100 Subject: [PATCH 1/2] update to interface #4509 --- .../AbstractJavaJAXRSServerCodegen.java | 9 + .../languages/JavaJAXRSSpecServerCodegen.java | 2 + .../resources/JavaJaxRS/spec/api.mustache | 10 +- .../JavaJaxRS/spec/apiServiceImpl.mustache | 37 + .../JavaJaxRS/spec/formParams.mustache | 3 +- .../spec/generatedAnnotation.mustache | 2 +- .../resources/JavaJaxRS/spec/pom.mustache | 19 + .../JavaJaxRS/spec/serviceBodyParams.mustache | 1 + .../JavaJaxRS/spec/serviceFormParams.mustache | 1 + .../spec/serviceHeaderParams.mustache | 1 + .../JavaJaxRS/spec/servicePathParams.mustache | 1 + .../spec/serviceQueryParams.mustache | 1 + .../jaxrs-spec/.swagger-codegen-ignore | 23 + samples/server/petstore/jaxrs-spec/pom.xml | 25 +- .../src/gen/java/io/swagger/api/FakeApi.java | 54 + .../io/swagger/api/FakeClassnameTestApi.java | 30 + .../src/gen/java/io/swagger/api/PetApi.java | 138 +++ .../java/io/swagger/api}/RestApplication.java | 2 +- .../src/gen/java/io/swagger/api/StoreApi.java | 64 ++ .../src/gen/java/io/swagger/api/UserApi.java | 99 ++ .../model/AdditionalPropertiesClass.java | 90 ++ .../src/gen/java/io/swagger/model/Animal.java | 89 ++ .../gen/java/io/swagger/model/AnimalFarm.java | 53 + .../model/ArrayOfArrayOfNumberOnly.java | 71 ++ .../io/swagger/model/ArrayOfNumberOnly.java | 71 ++ .../gen/java/io/swagger/model/ArrayTest.java | 109 ++ .../src/gen/java/io/swagger/model/Cat.java | 69 ++ .../java/io/swagger}/model/Category.java | 2 +- .../gen/java/io/swagger/model/ClassModel.java | 72 ++ .../src/gen/java/io/swagger/model/Client.java | 68 ++ .../src/gen/java/io/swagger/model/Dog.java | 69 ++ .../gen/java/io/swagger/model/EnumArrays.java | 140 +++ .../gen/java/io/swagger/model/EnumClass.java | 21 + .../gen/java/io/swagger/model/EnumTest.java | 177 ++++ .../gen/java/io/swagger/model/FormatTest.java | 309 ++++++ .../io/swagger/model/HasOnlyReadOnly.java | 87 ++ .../gen/java/io/swagger/model/MapTest.java | 124 +++ ...ropertiesAndAdditionalPropertiesClass.java | 111 ++ .../io/swagger/model/Model200Response.java | 91 ++ .../io/swagger/model/ModelApiResponse.java | 106 ++ .../java/io/swagger/model/ModelReturn.java | 72 ++ .../src/gen/java/io/swagger/model/Name.java | 129 +++ .../gen/java/io/swagger/model/NumberOnly.java | 69 ++ .../java/io/swagger}/model/Order.java | 29 +- .../gen/java/io/swagger/model/OuterEnum.java | 21 + .../java/io/swagger}/model/Pet.java | 31 +- .../java/io/swagger/model/ReadOnlyFirst.java | 87 ++ .../io/swagger/model/SpecialModelName.java | 68 ++ .../java/io/swagger}/model/Tag.java | 2 +- .../java/io/swagger}/model/User.java | 2 +- .../ibm/ws/petstoresample/api/PetsApi.java | 140 --- .../ibm/ws/petstoresample/api/StoresApi.java | 58 -- .../ibm/ws/petstoresample/api/UsersApi.java | 115 -- .../swagger/api/impl/FakeApiServiceImpl.java | 39 + .../impl/FakeClassnameTestApiServiceImpl.java | 29 + .../swagger/api/impl/PetApiServiceImpl.java | 59 ++ .../swagger/api/impl/StoreApiServiceImpl.java | 42 + .../swagger/api/impl/UserApiServiceImpl.java | 58 ++ .../server/petstore/jaxrs-spec/swagger.json | 979 ++++++++++++++++-- 59 files changed, 4054 insertions(+), 426 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/apiServiceImpl.mustache create mode 100644 modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceBodyParams.mustache create mode 100644 modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceFormParams.mustache create mode 100644 modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceHeaderParams.mustache create mode 100644 modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/servicePathParams.mustache create mode 100644 modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceQueryParams.mustache create mode 100644 samples/server/petstore/jaxrs-spec/.swagger-codegen-ignore create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeApi.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeClassnameTestApi.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/PetApi.java rename samples/server/petstore/jaxrs-spec/src/{main/java/com/ibm/ws/petstoresample => gen/java/io/swagger/api}/RestApplication.java (81%) create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/StoreApi.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/UserApi.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/AdditionalPropertiesClass.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Animal.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/AnimalFarm.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayOfNumberOnly.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayTest.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Cat.java rename samples/server/petstore/jaxrs-spec/src/{main/java/com/ibm/ws/petstoresample => gen/java/io/swagger}/model/Category.java (97%) create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ClassModel.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Client.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Dog.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumArrays.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumClass.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumTest.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/FormatTest.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/HasOnlyReadOnly.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/MapTest.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Model200Response.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelApiResponse.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelReturn.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Name.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/NumberOnly.java rename samples/server/petstore/jaxrs-spec/src/{main/java/com/ibm/ws/petstoresample => gen/java/io/swagger}/model/Order.java (82%) create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/OuterEnum.java rename samples/server/petstore/jaxrs-spec/src/{main/java/com/ibm/ws/petstoresample => gen/java/io/swagger}/model/Pet.java (82%) create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ReadOnlyFirst.java create mode 100644 samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/SpecialModelName.java rename samples/server/petstore/jaxrs-spec/src/{main/java/com/ibm/ws/petstoresample => gen/java/io/swagger}/model/Tag.java (97%) rename samples/server/petstore/jaxrs-spec/src/{main/java/com/ibm/ws/petstoresample => gen/java/io/swagger}/model/User.java (99%) delete mode 100644 samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/PetsApi.java delete mode 100644 samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/StoresApi.java delete mode 100644 samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/UsersApi.java create mode 100644 samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java create mode 100644 samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/FakeClassnameTestApiServiceImpl.java create mode 100644 samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java create mode 100644 samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java create mode 100644 samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java index 08410c47d44..7d4c9dcdd33 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AbstractJavaJAXRSServerCodegen.java @@ -138,6 +138,15 @@ public Map postProcessOperations(Map objs) { if ( "0".equals(resp.code) ) { resp.code = "200"; } + + // set vendorExtensions.x-java-is-response-void to true + // as dataType is set to "void" + if (resp.dataType == null) { + // TODO: CodegenResponse.vendorExtensions from + // master is missing!? + // resp.vendorExtensions.put("x-java-is-response-void", + // true); + } } } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java index 7c8d03c1375..3c21b5717b1 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java @@ -30,6 +30,8 @@ public JavaJAXRSSpecServerCodegen() modelTemplateFiles.put("model.mustache", ".java"); apiTemplateFiles.put("api.mustache", ".java"); + apiTemplateFiles.put("apiServiceImpl.mustache", ".java"); + apiPackage = "io.swagger.api"; modelPackage = "io.swagger.model"; diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/api.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/api.mustache index 5ffd9c2a6d3..94dddbb855c 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/api.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/api.mustache @@ -17,7 +17,7 @@ import java.util.List; {{#hasProduces}}@Produces({ {{#produces}}"{{{mediaType}}}"{{#hasMore}}, {{/hasMore}}{{/produces}} }){{/hasProduces}} {{>generatedAnnotation}} -public class {{classname}} { +public interface {{classname}} { {{#operations}} {{#operation}} @@ -25,7 +25,7 @@ public class {{classname}} { {{#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 = { + @ApiOperation(value = "{{{summary}}}", notes = "{{{notes}}}"{{^vendorExtensions.x-java-is-response-void}}, response = {{{returnType}}}.class{{/vendorExtensions.x-java-is-response-void}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}{{#hasAuthMethods}}, authorizations = { {{#authMethods}}@Authorization(value = "{{name}}"{{#isOAuth}}, scopes = { {{#scopes}}@AuthorizationScope(scope = "{{scope}}", description = "{{description}}"){{#hasMore}}, {{/hasMore}}{{/scopes}} @@ -33,10 +33,8 @@ public class {{classname}} { {{/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(); - } + @ApiResponse(code = {{{code}}}, message = "{{{message}}}"{{^vendorExtensions.x-java-is-response-void}}{{#baseType}}, response = {{{baseType}}}.class{{/baseType}}{{/vendorExtensions.x-java-is-response-void}}{{#returnContainer}}, responseContainer = "{{{returnContainer}}}"{{/returnContainer}}){{#hasMore}},{{/hasMore}}{{/responses}} }) + public Response {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{#hasMore}},{{/hasMore}}{{/allParams}}); {{/operation}} } {{/operations}} diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/apiServiceImpl.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/apiServiceImpl.mustache new file mode 100644 index 00000000000..63396ef43a2 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/apiServiceImpl.mustache @@ -0,0 +1,37 @@ +package {{package}}.impl; + +{{#imports}}import {{import}}; +{{/imports}} + +import {{package}}.{{classname}}; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.io.InputStream; + +import java.util.List; +{{#useBeanValidation}} +import javax.validation.constraints.*; +{{/useBeanValidation}} + +@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}}ServiceImpl implements {{classname}} { +{{#operations}} +{{#operation}} + + public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { + return Response.ok().entity("magic!").build(); + } +{{/operation}} +} +{{/operations}} + diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/formParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/formParams.mustache index b1036ceeb54..11b2460d624 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/formParams.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/formParams.mustache @@ -1,2 +1 @@ -{{#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}} \ No newline at end of file +{{#isFormParam}}{{#notFile}}@FormParam(value = "{{paramName}}") {{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}} @FormParam(value = "{{paramName}}") java.io.InputStream {{paramName}}InputStream{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/generatedAnnotation.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/generatedAnnotation.mustache index 49110fc1ad9..a47b6faa85b 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/generatedAnnotation.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/generatedAnnotation.mustache @@ -1 +1 @@ -@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}") \ No newline at end of file +{{^hideGenerationTimestamp}}@javax.annotation.Generated(value = "{{generatorClass}}", date = "{{generatedDate}}"){{/hideGenerationTimestamp}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/pom.mustache index e65d27f8db4..56675ed9109 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/pom.mustache @@ -28,6 +28,25 @@ + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceBodyParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceBodyParams.mustache new file mode 100644 index 00000000000..c7d1abfe527 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceBodyParams.mustache @@ -0,0 +1 @@ +{{#isBodyParam}}{{{dataType}}} {{paramName}}{{/isBodyParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceFormParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceFormParams.mustache new file mode 100644 index 00000000000..648724eb54a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceFormParams.mustache @@ -0,0 +1 @@ +{{#isFormParam}}{{#notFile}}{{{dataType}}} {{paramName}}{{/notFile}}{{#isFile}}InputStream fileDetail{{/isFile}}{{/isFormParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceHeaderParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceHeaderParams.mustache new file mode 100644 index 00000000000..bd03573d196 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceHeaderParams.mustache @@ -0,0 +1 @@ +{{#isHeaderParam}}{{{dataType}}} {{paramName}}{{/isHeaderParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/servicePathParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/servicePathParams.mustache new file mode 100644 index 00000000000..6829cf8c7a6 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/servicePathParams.mustache @@ -0,0 +1 @@ +{{#isPathParam}}{{{dataType}}} {{paramName}}{{/isPathParam}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceQueryParams.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceQueryParams.mustache new file mode 100644 index 00000000000..ff79730471d --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/serviceQueryParams.mustache @@ -0,0 +1 @@ +{{#isQueryParam}}{{{dataType}}} {{paramName}}{{/isQueryParam}} \ No newline at end of file diff --git a/samples/server/petstore/jaxrs-spec/.swagger-codegen-ignore b/samples/server/petstore/jaxrs-spec/.swagger-codegen-ignore new file mode 100644 index 00000000000..c5fa491b4c5 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/.swagger-codegen-ignore @@ -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 diff --git a/samples/server/petstore/jaxrs-spec/pom.xml b/samples/server/petstore/jaxrs-spec/pom.xml index c06fcab78d0..9355bab501c 100644 --- a/samples/server/petstore/jaxrs-spec/pom.xml +++ b/samples/server/petstore/jaxrs-spec/pom.xml @@ -1,9 +1,9 @@ 4.0.0 - wasdev - autogen-server + io.swagger + swagger-jaxrs-server war - autogen-server + swagger-jaxrs-server 1.0.0 src/main/java @@ -28,6 +28,25 @@ + + org.codehaus.mojo + build-helper-maven-plugin + 1.9.1 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeApi.java new file mode 100644 index 00000000000..804c9ac02b4 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeApi.java @@ -0,0 +1,54 @@ +package io.swagger.api; + +import java.math.BigDecimal; +import io.swagger.model.Client; +import org.joda.time.LocalDate; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.util.List; + +@Path("/fake") + +@Api(description = "the fake API") + + + + +public interface FakeApi { + + @PATCH + + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "To test \"client\" model", notes = "To test \"client\" model", response = Client.class, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + public Response testClientModel(Client body); + + @POST + + @Consumes({ "application/xml; charset=utf-8", "application/json; charset=utf-8" }) + @Produces({ "application/xml; charset=utf-8", "application/json; charset=utf-8" }) + @ApiOperation(value = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", notes = "Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 ", authorizations = { + @Authorization(value = "http_basic_test") + }, tags={ "fake", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid username supplied"), + @ApiResponse(code = 404, message = "User not found") }) + public Response testEndpointParameters(@FormParam(value = "number") BigDecimal number,@FormParam(value = "_double") Double _double,@FormParam(value = "patternWithoutDelimiter") String patternWithoutDelimiter,@FormParam(value = "_byte") byte[] _byte,@FormParam(value = "integer") Integer integer,@FormParam(value = "int32") Integer int32,@FormParam(value = "int64") Long int64,@FormParam(value = "_float") Float _float,@FormParam(value = "string") String string,@FormParam(value = "binary") byte[] binary,@FormParam(value = "date") LocalDate date,@FormParam(value = "dateTime") javax.xml.datatype.XMLGregorianCalendar dateTime,@FormParam(value = "password") String password,@FormParam(value = "paramCallback") String paramCallback); + + @GET + + @Consumes({ "*/*" }) + @Produces({ "*/*" }) + @ApiOperation(value = "To test enum parameters", notes = "To test enum parameters", tags={ "fake" }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid request"), + @ApiResponse(code = 404, message = "Not found") }) + public Response testEnumParameters(@FormParam(value = "enumFormStringArray") List enumFormStringArray,@FormParam(value = "enumFormString") String enumFormString,@HeaderParam("enum_header_string_array") List enumHeaderStringArray,@HeaderParam("enum_header_string") String enumHeaderString,@QueryParam("enum_query_string_array") List enumQueryStringArray,@QueryParam("enum_query_string") String enumQueryString,@QueryParam("enum_query_integer") Integer enumQueryInteger,@FormParam(value = "enumQueryDouble") Double enumQueryDouble); +} + diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeClassnameTestApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeClassnameTestApi.java new file mode 100644 index 00000000000..45575da645b --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/FakeClassnameTestApi.java @@ -0,0 +1,30 @@ +package io.swagger.api; + +import io.swagger.model.Client; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.util.List; + +@Path("/fake_classname_test") + +@Api(description = "the fake_classname_test API") + + + + +public interface FakeClassnameTestApi { + + @PATCH + + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + @ApiOperation(value = "To test class name in snake case", notes = "", response = Client.class, tags={ "fake_classname_tags 123#$%^" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Client.class) }) + public Response testClassname(Client body); +} + diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/PetApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/PetApi.java new file mode 100644 index 00000000000..e224c06a7b8 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/PetApi.java @@ -0,0 +1,138 @@ +package io.swagger.api; + +import java.io.File; +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.util.List; + +@Path("/pet") + +@Api(description = "the pet API") + + + + +public interface PetApi { + + @POST + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Add a new pet to the store", notes = "", 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") }) + public Response addPet(Pet body); + + @DELETE + @Path("/{petId}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Deletes a pet", notes = "", 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") }) + public Response deletePet(@PathParam("petId") Long petId,@HeaderParam("api_key") String apiKey); + + @GET + @Path("/findByStatus") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated 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", responseContainer = "List") }) + public Response findPetsByStatus(@QueryParam("status") List status); + + @GET + @Path("/findByTags") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated 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", responseContainer = "List") }) + public Response findPetsByTags(@QueryParam("tags") List tags); + + @GET + @Path("/{petId}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { + @Authorization(value = "api_key") + }, tags={ "pet", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Pet.class), + @ApiResponse(code = 400, message = "Invalid ID supplied"), + @ApiResponse(code = 404, message = "Pet not found") }) + public Response getPetById(@PathParam("petId") Long petId); + + @PUT + + @Consumes({ "application/json", "application/xml" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Update an existing pet", notes = "", 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"), + @ApiResponse(code = 404, message = "Pet not found"), + @ApiResponse(code = 405, message = "Validation exception") }) + public Response updatePet(Pet body); + + @POST + @Path("/{petId}") + @Consumes({ "application/x-www-form-urlencoded" }) + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Updates a pet in the store with form data", notes = "", 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") }) + public Response updatePetWithForm(@PathParam("petId") Long petId,@FormParam(value = "name") String name,@FormParam(value = "status") String status); + + @POST + @Path("/{petId}/uploadImage") + @Consumes({ "multipart/form-data" }) + @Produces({ "application/json" }) + @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.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 = 200, message = "successful operation", response = ModelApiResponse.class) }) + public Response uploadFile(@PathParam("petId") Long petId,@FormParam(value = "additionalMetadata") String additionalMetadata, @FormParam(value = "file") java.io.InputStream fileInputStream); +} + diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/RestApplication.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/RestApplication.java similarity index 81% rename from samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/RestApplication.java rename to samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/RestApplication.java index 9c43b1e80ba..56e801bbf5f 100644 --- a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/RestApplication.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/RestApplication.java @@ -1,4 +1,4 @@ -package com.ibm.ws.petstoresample; +package io.swagger.api; import javax.ws.rs.ApplicationPath; import javax.ws.rs.core.Application; diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/StoreApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/StoreApi.java new file mode 100644 index 00000000000..4126f5f1738 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/StoreApi.java @@ -0,0 +1,64 @@ +package io.swagger.api; + +import java.util.Map; +import io.swagger.model.Order; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.util.List; + +@Path("/store") + +@Api(description = "the store API") + + + + +public interface StoreApi { + + @DELETE + @Path("/order/{orderId}") + + @Produces({ "application/xml", "application/json" }) + @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", tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid ID supplied"), + @ApiResponse(code = 404, message = "Order not found") }) + public Response deleteOrder(@PathParam("orderId") String orderId); + + @GET + @Path("/inventory") + + @Produces({ "application/json" }) + @ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { + @Authorization(value = "api_key") + }, tags={ "store", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation", response = Map.class, responseContainer = "Map") }) + public Response getInventory(); + + @GET + @Path("/order/{orderId}") + + @Produces({ "application/xml", "application/json" }) + @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"), + @ApiResponse(code = 404, message = "Order not found") }) + public Response getOrderById(@PathParam("orderId") Long orderId); + + @POST + @Path("/order") + + @Produces({ "application/xml", "application/json" }) + @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") }) + public Response placeOrder(Order body); +} + diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/UserApi.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/UserApi.java new file mode 100644 index 00000000000..39a767f3284 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/api/UserApi.java @@ -0,0 +1,99 @@ +package io.swagger.api; + +import java.util.List; +import io.swagger.model.User; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.util.List; + +@Path("/user") + +@Api(description = "the user API") + + + + +public interface UserApi { + + @POST + + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + public Response createUser(User body); + + @POST + @Path("/createWithArray") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Creates list of users with given input array", notes = "", tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + public Response createUsersWithArrayInput(List body); + + @POST + @Path("/createWithList") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Creates list of users with given input array", notes = "", tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + public Response createUsersWithListInput(List body); + + @DELETE + @Path("/{username}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid username supplied"), + @ApiResponse(code = 404, message = "User not found") }) + public Response deleteUser(@PathParam("username") String username); + + @GET + @Path("/{username}") + + @Produces({ "application/xml", "application/json" }) + @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"), + @ApiResponse(code = 404, message = "User not found") }) + public Response getUserByName(@PathParam("username") String username); + + @GET + @Path("/login") + + @Produces({ "application/xml", "application/json" }) + @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") }) + public Response loginUser(@QueryParam("username") String username,@QueryParam("password") String password); + + @GET + @Path("/logout") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Logs out current logged in user session", notes = "", tags={ "user", }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "successful operation") }) + public Response logoutUser(); + + @PUT + @Path("/{username}") + + @Produces({ "application/xml", "application/json" }) + @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", tags={ "user" }) + @ApiResponses(value = { + @ApiResponse(code = 400, message = "Invalid user supplied"), + @ApiResponse(code = 404, message = "User not found") }) + public Response updateUser(@PathParam("username") String username,User body); +} + diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/AdditionalPropertiesClass.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/AdditionalPropertiesClass.java new file mode 100644 index 00000000000..0e8e20a3eeb --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/AdditionalPropertiesClass.java @@ -0,0 +1,90 @@ +package io.swagger.model; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class AdditionalPropertiesClass { + + private Map mapProperty = new HashMap(); + private Map> mapOfMapProperty = new HashMap>(); + + /** + **/ + public AdditionalPropertiesClass mapProperty(Map mapProperty) { + this.mapProperty = mapProperty; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Map getMapProperty() { + return mapProperty; + } + public void setMapProperty(Map mapProperty) { + this.mapProperty = mapProperty; + } + + /** + **/ + public AdditionalPropertiesClass mapOfMapProperty(Map> mapOfMapProperty) { + this.mapOfMapProperty = mapOfMapProperty; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Map> getMapOfMapProperty() { + return mapOfMapProperty; + } + public void setMapOfMapProperty(Map> mapOfMapProperty) { + this.mapOfMapProperty = mapOfMapProperty; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AdditionalPropertiesClass additionalPropertiesClass = (AdditionalPropertiesClass) o; + return Objects.equals(mapProperty, additionalPropertiesClass.mapProperty) && + Objects.equals(mapOfMapProperty, additionalPropertiesClass.mapOfMapProperty); + } + + @Override + public int hashCode() { + return Objects.hash(mapProperty, mapOfMapProperty); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AdditionalPropertiesClass {\n"); + + sb.append(" mapProperty: ").append(toIndentedString(mapProperty)).append("\n"); + sb.append(" mapOfMapProperty: ").append(toIndentedString(mapOfMapProperty)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Animal.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Animal.java new file mode 100644 index 00000000000..f14882cbf54 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Animal.java @@ -0,0 +1,89 @@ +package io.swagger.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class Animal { + + private String className = null; + private String color = "red"; + + /** + **/ + public Animal className(String className) { + this.className = className; + return this; + } + + + @ApiModelProperty(example = "null", required = true, value = "") + public String getClassName() { + return className; + } + public void setClassName(String className) { + this.className = className; + } + + /** + **/ + public Animal color(String color) { + this.color = color; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getColor() { + return color; + } + public void setColor(String color) { + this.color = color; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Animal animal = (Animal) o; + return Objects.equals(className, animal.className) && + Objects.equals(color, animal.color); + } + + @Override + public int hashCode() { + return Objects.hash(className, color); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Animal {\n"); + + sb.append(" className: ").append(toIndentedString(className)).append("\n"); + sb.append(" color: ").append(toIndentedString(color)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/AnimalFarm.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/AnimalFarm.java new file mode 100644 index 00000000000..eefaeeb83fc --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/AnimalFarm.java @@ -0,0 +1,53 @@ +package io.swagger.model; + +import io.swagger.model.Animal; +import java.util.ArrayList; +import java.util.List; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class AnimalFarm extends ArrayList { + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AnimalFarm animalFarm = (AnimalFarm) o; + return true; + } + + @Override + public int hashCode() { + return Objects.hash(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AnimalFarm {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java new file mode 100644 index 00000000000..5990b864e2e --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayOfArrayOfNumberOnly.java @@ -0,0 +1,71 @@ +package io.swagger.model; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class ArrayOfArrayOfNumberOnly { + + private List> arrayArrayNumber = new ArrayList>(); + + /** + **/ + public ArrayOfArrayOfNumberOnly arrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public List> getArrayArrayNumber() { + return arrayArrayNumber; + } + public void setArrayArrayNumber(List> arrayArrayNumber) { + this.arrayArrayNumber = arrayArrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfArrayOfNumberOnly arrayOfArrayOfNumberOnly = (ArrayOfArrayOfNumberOnly) o; + return Objects.equals(arrayArrayNumber, arrayOfArrayOfNumberOnly.arrayArrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayArrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfArrayOfNumberOnly {\n"); + + sb.append(" arrayArrayNumber: ").append(toIndentedString(arrayArrayNumber)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayOfNumberOnly.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayOfNumberOnly.java new file mode 100644 index 00000000000..48914bf4043 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayOfNumberOnly.java @@ -0,0 +1,71 @@ +package io.swagger.model; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class ArrayOfNumberOnly { + + private List arrayNumber = new ArrayList(); + + /** + **/ + public ArrayOfNumberOnly arrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public List getArrayNumber() { + return arrayNumber; + } + public void setArrayNumber(List arrayNumber) { + this.arrayNumber = arrayNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayOfNumberOnly arrayOfNumberOnly = (ArrayOfNumberOnly) o; + return Objects.equals(arrayNumber, arrayOfNumberOnly.arrayNumber); + } + + @Override + public int hashCode() { + return Objects.hash(arrayNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayOfNumberOnly {\n"); + + sb.append(" arrayNumber: ").append(toIndentedString(arrayNumber)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayTest.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayTest.java new file mode 100644 index 00000000000..0095dc23f9d --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ArrayTest.java @@ -0,0 +1,109 @@ +package io.swagger.model; + +import io.swagger.model.ReadOnlyFirst; +import java.util.ArrayList; +import java.util.List; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class ArrayTest { + + private List arrayOfString = new ArrayList(); + private List> arrayArrayOfInteger = new ArrayList>(); + private List> arrayArrayOfModel = new ArrayList>(); + + /** + **/ + public ArrayTest arrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public List getArrayOfString() { + return arrayOfString; + } + public void setArrayOfString(List arrayOfString) { + this.arrayOfString = arrayOfString; + } + + /** + **/ + public ArrayTest arrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public List> getArrayArrayOfInteger() { + return arrayArrayOfInteger; + } + public void setArrayArrayOfInteger(List> arrayArrayOfInteger) { + this.arrayArrayOfInteger = arrayArrayOfInteger; + } + + /** + **/ + public ArrayTest arrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public List> getArrayArrayOfModel() { + return arrayArrayOfModel; + } + public void setArrayArrayOfModel(List> arrayArrayOfModel) { + this.arrayArrayOfModel = arrayArrayOfModel; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ArrayTest arrayTest = (ArrayTest) o; + return Objects.equals(arrayOfString, arrayTest.arrayOfString) && + Objects.equals(arrayArrayOfInteger, arrayTest.arrayArrayOfInteger) && + Objects.equals(arrayArrayOfModel, arrayTest.arrayArrayOfModel); + } + + @Override + public int hashCode() { + return Objects.hash(arrayOfString, arrayArrayOfInteger, arrayArrayOfModel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ArrayTest {\n"); + + sb.append(" arrayOfString: ").append(toIndentedString(arrayOfString)).append("\n"); + sb.append(" arrayArrayOfInteger: ").append(toIndentedString(arrayArrayOfInteger)).append("\n"); + sb.append(" arrayArrayOfModel: ").append(toIndentedString(arrayArrayOfModel)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Cat.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Cat.java new file mode 100644 index 00000000000..4609ebeed5b --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Cat.java @@ -0,0 +1,69 @@ +package io.swagger.model; + +import io.swagger.model.Animal; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class Cat extends Animal { + + private Boolean declawed = null; + + /** + **/ + public Cat declawed(Boolean declawed) { + this.declawed = declawed; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Boolean getDeclawed() { + return declawed; + } + public void setDeclawed(Boolean declawed) { + this.declawed = declawed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Cat cat = (Cat) o; + return Objects.equals(declawed, cat.declawed); + } + + @Override + public int hashCode() { + return Objects.hash(declawed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Cat {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" declawed: ").append(toIndentedString(declawed)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Category.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Category.java similarity index 97% rename from samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Category.java rename to samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Category.java index cef2cf7ff95..53f99e693de 100644 --- a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Category.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Category.java @@ -1,4 +1,4 @@ -package com.ibm.ws.petstoresample.model; +package io.swagger.model; diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ClassModel.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ClassModel.java new file mode 100644 index 00000000000..ab4ab557fd5 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ClassModel.java @@ -0,0 +1,72 @@ +package io.swagger.model; + +import io.swagger.annotations.ApiModel; + + +/** + * Model for testing model with \"_class\" property + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +@ApiModel(description = "Model for testing model with \"_class\" property") + +public class ClassModel { + + private String propertyClass = null; + + /** + **/ + public ClassModel propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getPropertyClass() { + return propertyClass; + } + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClassModel classModel = (ClassModel) o; + return Objects.equals(propertyClass, classModel.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClassModel {\n"); + + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Client.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Client.java new file mode 100644 index 00000000000..281112f5877 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Client.java @@ -0,0 +1,68 @@ +package io.swagger.model; + + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class Client { + + private String client = null; + + /** + **/ + public Client client(String client) { + this.client = client; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getClient() { + return client; + } + public void setClient(String client) { + this.client = client; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Client client = (Client) o; + return Objects.equals(client, client.client); + } + + @Override + public int hashCode() { + return Objects.hash(client); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Client {\n"); + + sb.append(" client: ").append(toIndentedString(client)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Dog.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Dog.java new file mode 100644 index 00000000000..991bad1dce6 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Dog.java @@ -0,0 +1,69 @@ +package io.swagger.model; + +import io.swagger.model.Animal; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class Dog extends Animal { + + private String breed = null; + + /** + **/ + public Dog breed(String breed) { + this.breed = breed; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getBreed() { + return breed; + } + public void setBreed(String breed) { + this.breed = breed; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Dog dog = (Dog) o; + return Objects.equals(breed, dog.breed); + } + + @Override + public int hashCode() { + return Objects.hash(breed); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Dog {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" breed: ").append(toIndentedString(breed)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumArrays.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumArrays.java new file mode 100644 index 00000000000..875109f4226 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumArrays.java @@ -0,0 +1,140 @@ +package io.swagger.model; + +import java.util.ArrayList; +import java.util.List; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class EnumArrays { + + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="EnumArrays") +@XmlEnum +public enum EnumArrays { + {values=[>=, $], enumVars=[{name=GREATER_THAN_OR_EQUAL_TO, value=">="}, {name=DOLLAR, value="$"}]}, + + public String value() { + return name(); + } + + public static EnumArrays fromValue(String v) { + return valueOf(v); + } +} + private JustSymbolEnum justSymbol = null; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="EnumArrays") +@XmlEnum +public enum EnumArrays { + {values=[fish, crab], enumVars=[{name=FISH, value="fish"}, {name=CRAB, value="crab"}]}, + + public String value() { + return name(); + } + + public static EnumArrays fromValue(String v) { + return valueOf(v); + } +} + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="EnumArrays") +@XmlEnum +public enum EnumArrays { + {values=[fish, crab], enumVars=[{name=FISH, value="fish"}, {name=CRAB, value="crab"}]}, + + public String value() { + return name(); + } + + public static EnumArrays fromValue(String v) { + return valueOf(v); + } +} + private List arrayEnum = new ArrayList(); + + /** + **/ + public EnumArrays justSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public JustSymbolEnum getJustSymbol() { + return justSymbol; + } + public void setJustSymbol(JustSymbolEnum justSymbol) { + this.justSymbol = justSymbol; + } + + /** + **/ + public EnumArrays arrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public List getArrayEnum() { + return arrayEnum; + } + public void setArrayEnum(List arrayEnum) { + this.arrayEnum = arrayEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumArrays enumArrays = (EnumArrays) o; + return Objects.equals(justSymbol, enumArrays.justSymbol) && + Objects.equals(arrayEnum, enumArrays.arrayEnum); + } + + @Override + public int hashCode() { + return Objects.hash(justSymbol, arrayEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumArrays {\n"); + + sb.append(" justSymbol: ").append(toIndentedString(justSymbol)).append("\n"); + sb.append(" arrayEnum: ").append(toIndentedString(arrayEnum)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumClass.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumClass.java new file mode 100644 index 00000000000..8af311452fb --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumClass.java @@ -0,0 +1,21 @@ +package io.swagger.model; + + + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="EnumClass") +@XmlEnum +public enum EnumClass { + {values=[_abc, -efg, (xyz)], enumVars=[{name=_ABC, value="_abc"}, {name=_EFG, value="-efg"}, {name=_XYZ_, value="(xyz)"}]}, + + public String value() { + return name(); + } + + public static EnumClass fromValue(String v) { + return valueOf(v); + } +} + diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumTest.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumTest.java new file mode 100644 index 00000000000..22f21b1538d --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/EnumTest.java @@ -0,0 +1,177 @@ +package io.swagger.model; + +import io.swagger.model.OuterEnum; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class EnumTest { + + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="EnumTest") +@XmlEnum +public enum EnumTest { + {values=[UPPER, lower], enumVars=[{name=UPPER, value="UPPER"}, {name=LOWER, value="lower"}]}, + + public String value() { + return name(); + } + + public static EnumTest fromValue(String v) { + return valueOf(v); + } +} + private EnumStringEnum enumString = null; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="EnumTest") +@XmlEnum +public enum EnumTest { + {values=[1, -1], enumVars=[{name=NUMBER_1, value=1}, {name=NUMBER_MINUS_1, value=-1}]}, + + public String value() { + return name(); + } + + public static EnumTest fromValue(String v) { + return valueOf(v); + } +} + private EnumIntegerEnum enumInteger = null; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="EnumTest") +@XmlEnum +public enum EnumTest { + {values=[1.1, -1.2], enumVars=[{name=NUMBER_1_DOT_1, value=1.1}, {name=NUMBER_MINUS_1_DOT_2, value=-1.2}]}, + + public String value() { + return name(); + } + + public static EnumTest fromValue(String v) { + return valueOf(v); + } +} + private EnumNumberEnum enumNumber = null; + private OuterEnum outerEnum = null; + + /** + **/ + public EnumTest enumString(EnumStringEnum enumString) { + this.enumString = enumString; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public EnumStringEnum getEnumString() { + return enumString; + } + public void setEnumString(EnumStringEnum enumString) { + this.enumString = enumString; + } + + /** + **/ + public EnumTest enumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public EnumIntegerEnum getEnumInteger() { + return enumInteger; + } + public void setEnumInteger(EnumIntegerEnum enumInteger) { + this.enumInteger = enumInteger; + } + + /** + **/ + public EnumTest enumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public EnumNumberEnum getEnumNumber() { + return enumNumber; + } + public void setEnumNumber(EnumNumberEnum enumNumber) { + this.enumNumber = enumNumber; + } + + /** + **/ + public EnumTest outerEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public OuterEnum getOuterEnum() { + return outerEnum; + } + public void setOuterEnum(OuterEnum outerEnum) { + this.outerEnum = outerEnum; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EnumTest enumTest = (EnumTest) o; + return Objects.equals(enumString, enumTest.enumString) && + Objects.equals(enumInteger, enumTest.enumInteger) && + Objects.equals(enumNumber, enumTest.enumNumber) && + Objects.equals(outerEnum, enumTest.outerEnum); + } + + @Override + public int hashCode() { + return Objects.hash(enumString, enumInteger, enumNumber, outerEnum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EnumTest {\n"); + + sb.append(" enumString: ").append(toIndentedString(enumString)).append("\n"); + sb.append(" enumInteger: ").append(toIndentedString(enumInteger)).append("\n"); + sb.append(" enumNumber: ").append(toIndentedString(enumNumber)).append("\n"); + sb.append(" outerEnum: ").append(toIndentedString(outerEnum)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/FormatTest.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/FormatTest.java new file mode 100644 index 00000000000..e71329af37b --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/FormatTest.java @@ -0,0 +1,309 @@ +package io.swagger.model; + +import java.math.BigDecimal; +import java.util.UUID; +import org.joda.time.LocalDate; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class FormatTest { + + private Integer integer = null; + private Integer int32 = null; + private Long int64 = null; + private BigDecimal number = null; + private Float _float = null; + private Double _double = null; + private String string = null; + private byte[] _byte = null; + private byte[] binary = null; + private LocalDate date = null; + private javax.xml.datatype.XMLGregorianCalendar dateTime = null; + private UUID uuid = null; + private String password = null; + + /** + * minimum: 10 + * maximum: 100 + **/ + public FormatTest integer(Integer integer) { + this.integer = integer; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Integer getInteger() { + return integer; + } + public void setInteger(Integer integer) { + this.integer = integer; + } + + /** + * minimum: 20 + * maximum: 200 + **/ + public FormatTest int32(Integer int32) { + this.int32 = int32; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Integer getInt32() { + return int32; + } + public void setInt32(Integer int32) { + this.int32 = int32; + } + + /** + **/ + public FormatTest int64(Long int64) { + this.int64 = int64; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Long getInt64() { + return int64; + } + public void setInt64(Long int64) { + this.int64 = int64; + } + + /** + * minimum: 32.1 + * maximum: 543.2 + **/ + public FormatTest number(BigDecimal number) { + this.number = number; + return this; + } + + + @ApiModelProperty(example = "null", required = true, value = "") + public BigDecimal getNumber() { + return number; + } + public void setNumber(BigDecimal number) { + this.number = number; + } + + /** + * minimum: 54.3 + * maximum: 987.6 + **/ + public FormatTest _float(Float _float) { + this._float = _float; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Float getFloat() { + return _float; + } + public void setFloat(Float _float) { + this._float = _float; + } + + /** + * minimum: 67.8 + * maximum: 123.4 + **/ + public FormatTest _double(Double _double) { + this._double = _double; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Double getDouble() { + return _double; + } + public void setDouble(Double _double) { + this._double = _double; + } + + /** + **/ + public FormatTest string(String string) { + this.string = string; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getString() { + return string; + } + public void setString(String string) { + this.string = string; + } + + /** + **/ + public FormatTest _byte(byte[] _byte) { + this._byte = _byte; + return this; + } + + + @ApiModelProperty(example = "null", required = true, value = "") + public byte[] getByte() { + return _byte; + } + public void setByte(byte[] _byte) { + this._byte = _byte; + } + + /** + **/ + public FormatTest binary(byte[] binary) { + this.binary = binary; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public byte[] getBinary() { + return binary; + } + public void setBinary(byte[] binary) { + this.binary = binary; + } + + /** + **/ + public FormatTest date(LocalDate date) { + this.date = date; + return this; + } + + + @ApiModelProperty(example = "null", required = true, value = "") + public LocalDate getDate() { + return date; + } + public void setDate(LocalDate date) { + this.date = date; + } + + /** + **/ + public FormatTest dateTime(javax.xml.datatype.XMLGregorianCalendar dateTime) { + this.dateTime = dateTime; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public javax.xml.datatype.XMLGregorianCalendar getDateTime() { + return dateTime; + } + public void setDateTime(javax.xml.datatype.XMLGregorianCalendar dateTime) { + this.dateTime = dateTime; + } + + /** + **/ + public FormatTest uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public UUID getUuid() { + return uuid; + } + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + /** + **/ + public FormatTest password(String password) { + this.password = password; + return this; + } + + + @ApiModelProperty(example = "null", required = true, value = "") + public String getPassword() { + return password; + } + public void setPassword(String password) { + this.password = password; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FormatTest formatTest = (FormatTest) o; + return Objects.equals(integer, formatTest.integer) && + Objects.equals(int32, formatTest.int32) && + Objects.equals(int64, formatTest.int64) && + Objects.equals(number, formatTest.number) && + Objects.equals(_float, formatTest._float) && + Objects.equals(_double, formatTest._double) && + Objects.equals(string, formatTest.string) && + Objects.equals(_byte, formatTest._byte) && + Objects.equals(binary, formatTest.binary) && + Objects.equals(date, formatTest.date) && + Objects.equals(dateTime, formatTest.dateTime) && + Objects.equals(uuid, formatTest.uuid) && + Objects.equals(password, formatTest.password); + } + + @Override + public int hashCode() { + return Objects.hash(integer, int32, int64, number, _float, _double, string, _byte, binary, date, dateTime, uuid, password); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FormatTest {\n"); + + sb.append(" integer: ").append(toIndentedString(integer)).append("\n"); + sb.append(" int32: ").append(toIndentedString(int32)).append("\n"); + sb.append(" int64: ").append(toIndentedString(int64)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" _float: ").append(toIndentedString(_float)).append("\n"); + sb.append(" _double: ").append(toIndentedString(_double)).append("\n"); + sb.append(" string: ").append(toIndentedString(string)).append("\n"); + sb.append(" _byte: ").append(toIndentedString(_byte)).append("\n"); + sb.append(" binary: ").append(toIndentedString(binary)).append("\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/HasOnlyReadOnly.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/HasOnlyReadOnly.java new file mode 100644 index 00000000000..03adf0ab2cc --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/HasOnlyReadOnly.java @@ -0,0 +1,87 @@ +package io.swagger.model; + + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class HasOnlyReadOnly { + + private String bar = null; + private String foo = null; + + /** + **/ + public HasOnlyReadOnly bar(String bar) { + this.bar = bar; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getBar() { + return bar; + } + public void setBar(String bar) { + this.bar = bar; + } + + /** + **/ + public HasOnlyReadOnly foo(String foo) { + this.foo = foo; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getFoo() { + return foo; + } + public void setFoo(String foo) { + this.foo = foo; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HasOnlyReadOnly hasOnlyReadOnly = (HasOnlyReadOnly) o; + return Objects.equals(bar, hasOnlyReadOnly.bar) && + Objects.equals(foo, hasOnlyReadOnly.foo); + } + + @Override + public int hashCode() { + return Objects.hash(bar, foo); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HasOnlyReadOnly {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" foo: ").append(toIndentedString(foo)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/MapTest.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/MapTest.java new file mode 100644 index 00000000000..fde68fee594 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/MapTest.java @@ -0,0 +1,124 @@ +package io.swagger.model; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class MapTest { + + private Map> mapMapOfString = new HashMap>(); + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="MapTest") +@XmlEnum +public enum MapTest { + {values=[UPPER, lower], enumVars=[{name=UPPER, value="UPPER"}, {name=LOWER, value="lower"}]}, + + public String value() { + return name(); + } + + public static MapTest fromValue(String v) { + return valueOf(v); + } +} + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="MapTest") +@XmlEnum +public enum MapTest { + {values=[UPPER, lower], enumVars=[{name=UPPER, value="UPPER"}, {name=LOWER, value="lower"}]}, + + public String value() { + return name(); + } + + public static MapTest fromValue(String v) { + return valueOf(v); + } +} + private Map mapOfEnumString = new HashMap(); + + /** + **/ + public MapTest mapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Map> getMapMapOfString() { + return mapMapOfString; + } + public void setMapMapOfString(Map> mapMapOfString) { + this.mapMapOfString = mapMapOfString; + } + + /** + **/ + public MapTest mapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Map getMapOfEnumString() { + return mapOfEnumString; + } + public void setMapOfEnumString(Map mapOfEnumString) { + this.mapOfEnumString = mapOfEnumString; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MapTest mapTest = (MapTest) o; + return Objects.equals(mapMapOfString, mapTest.mapMapOfString) && + Objects.equals(mapOfEnumString, mapTest.mapOfEnumString); + } + + @Override + public int hashCode() { + return Objects.hash(mapMapOfString, mapOfEnumString); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MapTest {\n"); + + sb.append(" mapMapOfString: ").append(toIndentedString(mapMapOfString)).append("\n"); + sb.append(" mapOfEnumString: ").append(toIndentedString(mapOfEnumString)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java new file mode 100644 index 00000000000..3154e16d3c4 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/MixedPropertiesAndAdditionalPropertiesClass.java @@ -0,0 +1,111 @@ +package io.swagger.model; + +import io.swagger.model.Animal; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class MixedPropertiesAndAdditionalPropertiesClass { + + private UUID uuid = null; + private javax.xml.datatype.XMLGregorianCalendar dateTime = null; + private Map map = new HashMap(); + + /** + **/ + public MixedPropertiesAndAdditionalPropertiesClass uuid(UUID uuid) { + this.uuid = uuid; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public UUID getUuid() { + return uuid; + } + public void setUuid(UUID uuid) { + this.uuid = uuid; + } + + /** + **/ + public MixedPropertiesAndAdditionalPropertiesClass dateTime(javax.xml.datatype.XMLGregorianCalendar dateTime) { + this.dateTime = dateTime; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public javax.xml.datatype.XMLGregorianCalendar getDateTime() { + return dateTime; + } + public void setDateTime(javax.xml.datatype.XMLGregorianCalendar dateTime) { + this.dateTime = dateTime; + } + + /** + **/ + public MixedPropertiesAndAdditionalPropertiesClass map(Map map) { + this.map = map; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Map getMap() { + return map; + } + public void setMap(Map map) { + this.map = map; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MixedPropertiesAndAdditionalPropertiesClass mixedPropertiesAndAdditionalPropertiesClass = (MixedPropertiesAndAdditionalPropertiesClass) o; + return Objects.equals(uuid, mixedPropertiesAndAdditionalPropertiesClass.uuid) && + Objects.equals(dateTime, mixedPropertiesAndAdditionalPropertiesClass.dateTime) && + Objects.equals(map, mixedPropertiesAndAdditionalPropertiesClass.map); + } + + @Override + public int hashCode() { + return Objects.hash(uuid, dateTime, map); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MixedPropertiesAndAdditionalPropertiesClass {\n"); + + sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); + sb.append(" dateTime: ").append(toIndentedString(dateTime)).append("\n"); + sb.append(" map: ").append(toIndentedString(map)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Model200Response.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Model200Response.java new file mode 100644 index 00000000000..9d8ebc07c02 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Model200Response.java @@ -0,0 +1,91 @@ +package io.swagger.model; + +import io.swagger.annotations.ApiModel; + + +/** + * Model for testing model name starting with number + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +@ApiModel(description = "Model for testing model name starting with number") + +public class Model200Response { + + private Integer name = null; + private String propertyClass = null; + + /** + **/ + public Model200Response name(Integer name) { + this.name = name; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Integer getName() { + return name; + } + public void setName(Integer name) { + this.name = name; + } + + /** + **/ + public Model200Response propertyClass(String propertyClass) { + this.propertyClass = propertyClass; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getPropertyClass() { + return propertyClass; + } + public void setPropertyClass(String propertyClass) { + this.propertyClass = propertyClass; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Model200Response _200Response = (Model200Response) o; + return Objects.equals(name, _200Response.name) && + Objects.equals(propertyClass, _200Response.propertyClass); + } + + @Override + public int hashCode() { + return Objects.hash(name, propertyClass); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Model200Response {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelApiResponse.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelApiResponse.java new file mode 100644 index 00000000000..2d11dd789f6 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelApiResponse.java @@ -0,0 +1,106 @@ +package io.swagger.model; + + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class ModelApiResponse { + + private Integer code = null; + private String type = null; + private String message = null; + + /** + **/ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Integer getCode() { + return code; + } + public void setCode(Integer code) { + this.code = code; + } + + /** + **/ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + /** + **/ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelApiResponse _apiResponse = (ModelApiResponse) o; + return Objects.equals(code, _apiResponse.code) && + Objects.equals(type, _apiResponse.type) && + Objects.equals(message, _apiResponse.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, type, 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 String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelReturn.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelReturn.java new file mode 100644 index 00000000000..286c9c06502 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ModelReturn.java @@ -0,0 +1,72 @@ +package io.swagger.model; + +import io.swagger.annotations.ApiModel; + + +/** + * Model for testing reserved words + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +@ApiModel(description = "Model for testing reserved words") + +public class ModelReturn { + + private Integer _return = null; + + /** + **/ + public ModelReturn _return(Integer _return) { + this._return = _return; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Integer getReturn() { + return _return; + } + public void setReturn(Integer _return) { + this._return = _return; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelReturn _return = (ModelReturn) o; + return Objects.equals(_return, _return._return); + } + + @Override + public int hashCode() { + return Objects.hash(_return); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelReturn {\n"); + + sb.append(" _return: ").append(toIndentedString(_return)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Name.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Name.java new file mode 100644 index 00000000000..2960c177bde --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Name.java @@ -0,0 +1,129 @@ +package io.swagger.model; + +import io.swagger.annotations.ApiModel; + + +/** + * Model for testing model name same as property name + **/ + +import io.swagger.annotations.*; +import java.util.Objects; +@ApiModel(description = "Model for testing model name same as property name") + +public class Name { + + private Integer name = null; + private Integer snakeCase = null; + private String property = null; + private Integer _123Number = null; + + /** + **/ + public Name name(Integer name) { + this.name = name; + return this; + } + + + @ApiModelProperty(example = "null", required = true, value = "") + public Integer getName() { + return name; + } + public void setName(Integer name) { + this.name = name; + } + + /** + **/ + public Name snakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Integer getSnakeCase() { + return snakeCase; + } + public void setSnakeCase(Integer snakeCase) { + this.snakeCase = snakeCase; + } + + /** + **/ + public Name property(String property) { + this.property = property; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getProperty() { + return property; + } + public void setProperty(String property) { + this.property = property; + } + + /** + **/ + public Name _123Number(Integer _123Number) { + this._123Number = _123Number; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Integer get123Number() { + return _123Number; + } + public void set123Number(Integer _123Number) { + this._123Number = _123Number; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Name name = (Name) o; + return Objects.equals(name, name.name) && + Objects.equals(snakeCase, name.snakeCase) && + Objects.equals(property, name.property) && + Objects.equals(_123Number, name._123Number); + } + + @Override + public int hashCode() { + return Objects.hash(name, snakeCase, property, _123Number); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Name {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" snakeCase: ").append(toIndentedString(snakeCase)).append("\n"); + sb.append(" property: ").append(toIndentedString(property)).append("\n"); + sb.append(" _123Number: ").append(toIndentedString(_123Number)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/NumberOnly.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/NumberOnly.java new file mode 100644 index 00000000000..c1ea5771c5a --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/NumberOnly.java @@ -0,0 +1,69 @@ +package io.swagger.model; + +import java.math.BigDecimal; + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class NumberOnly { + + private BigDecimal justNumber = null; + + /** + **/ + public NumberOnly justNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public BigDecimal getJustNumber() { + return justNumber; + } + public void setJustNumber(BigDecimal justNumber) { + this.justNumber = justNumber; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberOnly numberOnly = (NumberOnly) o; + return Objects.equals(justNumber, numberOnly.justNumber); + } + + @Override + public int hashCode() { + return Objects.hash(justNumber); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberOnly {\n"); + + sb.append(" justNumber: ").append(toIndentedString(justNumber)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Order.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Order.java similarity index 82% rename from samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Order.java rename to samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Order.java index ce7995e3437..5f9ceabed49 100644 --- a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Order.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Order.java @@ -1,4 +1,4 @@ -package com.ibm.ws.petstoresample.model; +package io.swagger.model; @@ -13,8 +13,25 @@ public class Order { private Long petId = null; private Integer quantity = null; private javax.xml.datatype.XMLGregorianCalendar shipDate = null; - private String status = null; - private Boolean complete = null; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="Order") +@XmlEnum +public enum Order { + {values=[placed, approved, delivered], enumVars=[{name=PLACED, value="placed"}, {name=APPROVED, value="approved"}, {name=DELIVERED, value="delivered"}]}, + + public String value() { + return name(); + } + + public static Order fromValue(String v) { + return valueOf(v); + } +} + private StatusEnum status = null; + private Boolean complete = false; /** **/ @@ -83,17 +100,17 @@ public void setShipDate(javax.xml.datatype.XMLGregorianCalendar shipDate) { /** * Order Status **/ - public Order status(String status) { + public Order status(StatusEnum status) { this.status = status; return this; } @ApiModelProperty(example = "null", value = "Order Status") - public String getStatus() { + public StatusEnum getStatus() { return status; } - public void setStatus(String status) { + public void setStatus(StatusEnum status) { this.status = status; } diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/OuterEnum.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/OuterEnum.java new file mode 100644 index 00000000000..c1db34b0d9f --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/OuterEnum.java @@ -0,0 +1,21 @@ +package io.swagger.model; + + + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="OuterEnum") +@XmlEnum +public enum OuterEnum { + {values=[placed, approved, delivered], enumVars=[{name=PLACED, value="placed"}, {name=APPROVED, value="approved"}, {name=DELIVERED, value="delivered"}]}, + + public String value() { + return name(); + } + + public static OuterEnum fromValue(String v) { + return valueOf(v); + } +} + diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Pet.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Pet.java similarity index 82% rename from samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Pet.java rename to samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Pet.java index 30e81e1c988..a679539fe35 100644 --- a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Pet.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Pet.java @@ -1,7 +1,7 @@ -package com.ibm.ws.petstoresample.model; +package io.swagger.model; -import com.ibm.ws.petstoresample.model.Category; -import com.ibm.ws.petstoresample.model.Tag; +import io.swagger.model.Category; +import io.swagger.model.Tag; import java.util.ArrayList; import java.util.List; @@ -18,7 +18,24 @@ public class Pet { private String name = null; private List photoUrls = new ArrayList(); private List tags = new ArrayList(); - private String status = null; + +import javax.xml.bind.annotation.XmlEnum; +import javax.xml.bind.annotation.XmlType; + +@XmlType(name="Pet") +@XmlEnum +public enum Pet { + {values=[available, pending, sold], enumVars=[{name=AVAILABLE, value="available"}, {name=PENDING, value="pending"}, {name=SOLD, value="sold"}]}, + + public String value() { + return name(); + } + + public static Pet fromValue(String v) { + return valueOf(v); + } +} + private StatusEnum status = null; /** **/ @@ -103,17 +120,17 @@ public void setTags(List tags) { /** * pet status in the store **/ - public Pet status(String status) { + public Pet status(StatusEnum status) { this.status = status; return this; } @ApiModelProperty(example = "null", value = "pet status in the store") - public String getStatus() { + public StatusEnum getStatus() { return status; } - public void setStatus(String status) { + public void setStatus(StatusEnum status) { this.status = status; } diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ReadOnlyFirst.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ReadOnlyFirst.java new file mode 100644 index 00000000000..52b140917da --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/ReadOnlyFirst.java @@ -0,0 +1,87 @@ +package io.swagger.model; + + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class ReadOnlyFirst { + + private String bar = null; + private String baz = null; + + /** + **/ + public ReadOnlyFirst bar(String bar) { + this.bar = bar; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getBar() { + return bar; + } + public void setBar(String bar) { + this.bar = bar; + } + + /** + **/ + public ReadOnlyFirst baz(String baz) { + this.baz = baz; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public String getBaz() { + return baz; + } + public void setBaz(String baz) { + this.baz = baz; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReadOnlyFirst readOnlyFirst = (ReadOnlyFirst) o; + return Objects.equals(bar, readOnlyFirst.bar) && + Objects.equals(baz, readOnlyFirst.baz); + } + + @Override + public int hashCode() { + return Objects.hash(bar, baz); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReadOnlyFirst {\n"); + + sb.append(" bar: ").append(toIndentedString(bar)).append("\n"); + sb.append(" baz: ").append(toIndentedString(baz)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/SpecialModelName.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/SpecialModelName.java new file mode 100644 index 00000000000..2adfad37dc9 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/SpecialModelName.java @@ -0,0 +1,68 @@ +package io.swagger.model; + + + + +import io.swagger.annotations.*; +import java.util.Objects; + + +public class SpecialModelName { + + private Long specialPropertyName = null; + + /** + **/ + public SpecialModelName specialPropertyName(Long specialPropertyName) { + this.specialPropertyName = specialPropertyName; + return this; + } + + + @ApiModelProperty(example = "null", value = "") + public Long getSpecialPropertyName() { + return specialPropertyName; + } + public void setSpecialPropertyName(Long specialPropertyName) { + this.specialPropertyName = specialPropertyName; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SpecialModelName specialModelName = (SpecialModelName) o; + return Objects.equals(specialPropertyName, specialModelName.specialPropertyName); + } + + @Override + public int hashCode() { + return Objects.hash(specialPropertyName); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SpecialModelName {\n"); + + sb.append(" specialPropertyName: ").append(toIndentedString(specialPropertyName)).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 "); + } +} diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Tag.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Tag.java similarity index 97% rename from samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Tag.java rename to samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Tag.java index 351770bd7c5..4a2a6b5d165 100644 --- a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/Tag.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/Tag.java @@ -1,4 +1,4 @@ -package com.ibm.ws.petstoresample.model; +package io.swagger.model; diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/User.java b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/User.java similarity index 99% rename from samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/User.java rename to samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/User.java index 22369ba154d..5513a454d9a 100644 --- a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/model/User.java +++ b/samples/server/petstore/jaxrs-spec/src/gen/java/io/swagger/model/User.java @@ -1,4 +1,4 @@ -package com.ibm.ws.petstoresample.model; +package io.swagger.model; diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/PetsApi.java b/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/PetsApi.java deleted file mode 100644 index bb3beaf9f89..00000000000 --- a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/PetsApi.java +++ /dev/null @@ -1,140 +0,0 @@ -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 separated 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 status) { - return Response.ok().entity("magic!").build(); - } - - @GET - @Path("/findByTags") - - @Produces({ "application/json", "application/xml" }) - @ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated 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 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(); - } -} - diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/StoresApi.java b/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/StoresApi.java deleted file mode 100644 index 4f7613eed27..00000000000 --- a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/StoresApi.java +++ /dev/null @@ -1,58 +0,0 @@ -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(); - } -} - diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/UsersApi.java b/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/UsersApi.java deleted file mode 100644 index 4bf8701edbf..00000000000 --- a/samples/server/petstore/jaxrs-spec/src/main/java/com/ibm/ws/petstoresample/api/UsersApi.java +++ /dev/null @@ -1,115 +0,0 @@ -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 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 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(); - } -} - diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java b/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java new file mode 100644 index 00000000000..00fd34fb97c --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/FakeApiServiceImpl.java @@ -0,0 +1,39 @@ +package io.swagger.api.impl; + +import java.math.BigDecimal; +import io.swagger.model.Client; +import org.joda.time.LocalDate; + +import io.swagger.api.FakeApi; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.io.InputStream; + +import java.util.List; + +@Path("/fake") + +@Api(description = "the fake API") + + + + +public class FakeApiServiceImpl implements FakeApi { + + public Response testClientModel(Client body) { + return Response.ok().entity("magic!").build(); + } + + public Response testEndpointParameters(BigDecimal number, Double _double, String patternWithoutDelimiter, byte[] _byte, Integer integer, Integer int32, Long int64, Float _float, String string, byte[] binary, LocalDate date, javax.xml.datatype.XMLGregorianCalendar dateTime, String password, String paramCallback) { + return Response.ok().entity("magic!").build(); + } + + public Response testEnumParameters(List enumFormStringArray, String enumFormString, List enumHeaderStringArray, String enumHeaderString, List enumQueryStringArray, String enumQueryString, Integer enumQueryInteger, Double enumQueryDouble) { + return Response.ok().entity("magic!").build(); + } +} + diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/FakeClassnameTestApiServiceImpl.java b/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/FakeClassnameTestApiServiceImpl.java new file mode 100644 index 00000000000..ec8c051829e --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/FakeClassnameTestApiServiceImpl.java @@ -0,0 +1,29 @@ +package io.swagger.api.impl; + +import io.swagger.model.Client; + +import io.swagger.api.FakeClassnameTestApi; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.io.InputStream; + +import java.util.List; + +@Path("/fake_classname_test") + +@Api(description = "the fake_classname_test API") + + + + +public class FakeClassnameTestApiServiceImpl implements FakeClassnameTestApi { + + public Response testClassname(Client body) { + return Response.ok().entity("magic!").build(); + } +} + diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java b/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java new file mode 100644 index 00000000000..49d484aef93 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/PetApiServiceImpl.java @@ -0,0 +1,59 @@ +package io.swagger.api.impl; + +import java.io.File; +import io.swagger.model.ModelApiResponse; +import io.swagger.model.Pet; + +import io.swagger.api.PetApi; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.io.InputStream; + +import java.util.List; + +@Path("/pet") + +@Api(description = "the pet API") + + + + +public class PetApiServiceImpl implements PetApi { + + public Response addPet(Pet body) { + return Response.ok().entity("magic!").build(); + } + + public Response deletePet(Long petId, String apiKey) { + return Response.ok().entity("magic!").build(); + } + + public Response findPetsByStatus(List status) { + return Response.ok().entity("magic!").build(); + } + + public Response findPetsByTags(List tags) { + return Response.ok().entity("magic!").build(); + } + + public Response getPetById(Long petId) { + return Response.ok().entity("magic!").build(); + } + + public Response updatePet(Pet body) { + return Response.ok().entity("magic!").build(); + } + + public Response updatePetWithForm(Long petId, String name, String status) { + return Response.ok().entity("magic!").build(); + } + + public Response uploadFile(Long petId, String additionalMetadata, InputStream fileDetail) { + return Response.ok().entity("magic!").build(); + } +} + diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java b/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java new file mode 100644 index 00000000000..1d137c41a44 --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/StoreApiServiceImpl.java @@ -0,0 +1,42 @@ +package io.swagger.api.impl; + +import java.util.Map; +import io.swagger.model.Order; + +import io.swagger.api.StoreApi; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.io.InputStream; + +import java.util.List; + +@Path("/store") + +@Api(description = "the store API") + + + + +public class StoreApiServiceImpl implements StoreApi { + + public Response deleteOrder(String orderId) { + return Response.ok().entity("magic!").build(); + } + + public Response getInventory() { + return Response.ok().entity("magic!").build(); + } + + public Response getOrderById(Long orderId) { + return Response.ok().entity("magic!").build(); + } + + public Response placeOrder(Order body) { + return Response.ok().entity("magic!").build(); + } +} + diff --git a/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java b/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java new file mode 100644 index 00000000000..a232d659dec --- /dev/null +++ b/samples/server/petstore/jaxrs-spec/src/main/java/io/swagger/api/impl/UserApiServiceImpl.java @@ -0,0 +1,58 @@ +package io.swagger.api.impl; + +import java.util.List; +import io.swagger.model.User; + +import io.swagger.api.UserApi; + +import javax.ws.rs.*; +import javax.ws.rs.core.Response; + +import io.swagger.annotations.*; + +import java.io.InputStream; + +import java.util.List; + +@Path("/user") + +@Api(description = "the user API") + + + + +public class UserApiServiceImpl implements UserApi { + + public Response createUser(User body) { + return Response.ok().entity("magic!").build(); + } + + public Response createUsersWithArrayInput(List body) { + return Response.ok().entity("magic!").build(); + } + + public Response createUsersWithListInput(List body) { + return Response.ok().entity("magic!").build(); + } + + public Response deleteUser(String username) { + return Response.ok().entity("magic!").build(); + } + + public Response getUserByName(String username) { + return Response.ok().entity("magic!").build(); + } + + public Response loginUser(String username, String password) { + return Response.ok().entity("magic!").build(); + } + + public Response logoutUser() { + return Response.ok().entity("magic!").build(); + } + + public Response updateUser(String username, User body) { + return Response.ok().entity("magic!").build(); + } +} + diff --git a/samples/server/petstore/jaxrs-spec/swagger.json b/samples/server/petstore/jaxrs-spec/swagger.json index 4524933cd36..66f0d9edb19 100644 --- a/samples/server/petstore/jaxrs-spec/swagger.json +++ b/samples/server/petstore/jaxrs-spec/swagger.json @@ -1,12 +1,12 @@ { "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", + "description" : "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\", "version" : "1.0.0", "title" : "Swagger Petstore", - "termsOfService" : "http://helloreverb.com/terms/", + "termsOfService" : "http://swagger.io/terms/", "contact" : { - "name" : "apiteam@swagger.io" + "email" : "apiteam@swagger.io" }, "license" : { "name" : "Apache 2.0", @@ -15,21 +15,39 @@ }, "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" : { - "/pets" : { + "/pet" : { "post" : { "tags" : [ "pet" ], "summary" : "Add a new pet to the store", "description" : "", "operationId" : "addPet", "consumes" : [ "application/json", "application/xml" ], - "produces" : [ "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" : false, + "required" : true, "schema" : { "$ref" : "#/definitions/Pet" } @@ -40,7 +58,7 @@ } }, "security" : [ { - "petstore_auth" : [ "write_pets", "read_pets" ] + "petstore_auth" : [ "write:pets", "read:pets" ] } ] }, "put" : { @@ -49,12 +67,12 @@ "description" : "", "operationId" : "updatePet", "consumes" : [ "application/json", "application/xml" ], - "produces" : [ "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" : false, + "required" : true, "schema" : { "$ref" : "#/definitions/Pet" } @@ -71,27 +89,29 @@ } }, "security" : [ { - "petstore_auth" : [ "write_pets", "read_pets" ] + "petstore_auth" : [ "write:pets", "read:pets" ] } ] } }, - "/pets/findByStatus" : { + "/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/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "status", "in" : "query", "description" : "Status values that need to be considered for filter", - "required" : false, + "required" : true, "type" : "array", "items" : { - "type" : "string" + "type" : "string", + "default" : "available", + "enum" : [ "available", "pending", "sold" ] }, - "collectionFormat" : "multi" + "collectionFormat" : "csv" } ], "responses" : { "200" : { @@ -108,27 +128,27 @@ } }, "security" : [ { - "petstore_auth" : [ "write_pets", "read_pets" ] + "petstore_auth" : [ "write:pets", "read:pets" ] } ] } }, - "/pets/findByTags" : { + "/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/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "tags", "in" : "query", "description" : "Tags to filter by", - "required" : false, + "required" : true, "type" : "array", "items" : { "type" : "string" }, - "collectionFormat" : "multi" + "collectionFormat" : "csv" } ], "responses" : { "200" : { @@ -145,21 +165,21 @@ } }, "security" : [ { - "petstore_auth" : [ "write_pets", "read_pets" ] + "petstore_auth" : [ "write:pets", "read:pets" ] } ] } }, - "/pets/{petId}" : { + "/pet/{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", + "description" : "Returns a single pet", "operationId" : "getPetById", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "petId", "in" : "path", - "description" : "ID of pet that needs to be fetched", + "description" : "ID of pet to return", "required" : true, "type" : "integer", "format" : "int64" @@ -180,8 +200,6 @@ }, "security" : [ { "api_key" : [ ] - }, { - "petstore_auth" : [ "write_pets", "read_pets" ] } ] }, "post" : { @@ -190,24 +208,25 @@ "description" : "", "operationId" : "updatePetWithForm", "consumes" : [ "application/x-www-form-urlencoded" ], - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "petId", "in" : "path", "description" : "ID of pet that needs to be updated", "required" : true, - "type" : "string" + "type" : "integer", + "format" : "int64" }, { "name" : "name", "in" : "formData", "description" : "Updated name of the pet", - "required" : true, + "required" : false, "type" : "string" }, { "name" : "status", "in" : "formData", "description" : "Updated status of the pet", - "required" : true, + "required" : false, "type" : "string" } ], "responses" : { @@ -216,7 +235,7 @@ } }, "security" : [ { - "petstore_auth" : [ "write_pets", "read_pets" ] + "petstore_auth" : [ "write:pets", "read:pets" ] } ] }, "delete" : { @@ -224,12 +243,11 @@ "summary" : "Deletes a pet", "description" : "", "operationId" : "deletePet", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "api_key", "in" : "header", - "description" : "", - "required" : true, + "required" : false, "type" : "string" }, { "name" : "petId", @@ -245,22 +263,88 @@ } }, "security" : [ { - "petstore_auth" : [ "write_pets", "read_pets" ] + "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" : [ ] } ] } }, - "/stores/order" : { + "/store/order" : { "post" : { "tags" : [ "store" ], "summary" : "Place an order for a pet", "description" : "", "operationId" : "placeOrder", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "in" : "body", "name" : "body", "description" : "order placed for purchasing the pet", - "required" : false, + "required" : true, "schema" : { "$ref" : "#/definitions/Order" } @@ -278,19 +362,22 @@ } } }, - "/stores/order/{orderId}" : { + "/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/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "orderId", "in" : "path", "description" : "ID of pet that needs to be fetched", "required" : true, - "type" : "string" + "type" : "integer", + "maximum" : 5, + "minimum" : 1, + "format" : "int64" } ], "responses" : { "200" : { @@ -312,13 +399,14 @@ "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" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "orderId", "in" : "path", "description" : "ID of the order that needs to be deleted", "required" : true, - "type" : "string" + "type" : "string", + "minimum" : 1 } ], "responses" : { "400" : { @@ -330,18 +418,18 @@ } } }, - "/users" : { + "/user" : { "post" : { "tags" : [ "user" ], "summary" : "Create user", "description" : "This can only be done by the logged in user.", "operationId" : "createUser", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "in" : "body", "name" : "body", "description" : "Created user object", - "required" : false, + "required" : true, "schema" : { "$ref" : "#/definitions/User" } @@ -353,18 +441,18 @@ } } }, - "/users/createWithArray" : { + "/user/createWithArray" : { "post" : { "tags" : [ "user" ], "summary" : "Creates list of users with given input array", "description" : "", "operationId" : "createUsersWithArrayInput", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "in" : "body", "name" : "body", "description" : "List of user object", - "required" : false, + "required" : true, "schema" : { "type" : "array", "items" : { @@ -379,18 +467,18 @@ } } }, - "/users/createWithList" : { + "/user/createWithList" : { "post" : { "tags" : [ "user" ], "summary" : "Creates list of users with given input array", "description" : "", "operationId" : "createUsersWithListInput", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "in" : "body", "name" : "body", "description" : "List of user object", - "required" : false, + "required" : true, "schema" : { "type" : "array", "items" : { @@ -405,24 +493,24 @@ } } }, - "/users/login" : { + "/user/login" : { "get" : { "tags" : [ "user" ], "summary" : "Logs user into the system", "description" : "", "operationId" : "loginUser", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "username", "in" : "query", "description" : "The user name for login", - "required" : false, + "required" : true, "type" : "string" }, { "name" : "password", "in" : "query", "description" : "The password for login in clear text", - "required" : false, + "required" : true, "type" : "string" } ], "responses" : { @@ -430,6 +518,18 @@ "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" : { @@ -438,13 +538,13 @@ } } }, - "/users/logout" : { + "/user/logout" : { "get" : { "tags" : [ "user" ], "summary" : "Logs out current logged in user session", "description" : "", "operationId" : "logoutUser", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ ], "responses" : { "default" : { @@ -453,17 +553,17 @@ } } }, - "/users/{username}" : { + "/user/{username}" : { "get" : { "tags" : [ "user" ], "summary" : "Get user by user name", "description" : "", "operationId" : "getUserByName", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "username", "in" : "path", - "description" : "The name that needs to be fetched. Use user1 for testing.", + "description" : "The name that needs to be fetched. Use user1 for testing. ", "required" : true, "type" : "string" } ], @@ -487,7 +587,7 @@ "summary" : "Updated user", "description" : "This can only be done by the logged in user.", "operationId" : "updateUser", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "username", "in" : "path", @@ -498,7 +598,7 @@ "in" : "body", "name" : "body", "description" : "Updated user object", - "required" : false, + "required" : true, "schema" : { "$ref" : "#/definitions/User" } @@ -517,7 +617,7 @@ "summary" : "Delete user", "description" : "This can only be done by the logged in user.", "operationId" : "deleteUser", - "produces" : [ "application/json", "application/xml" ], + "produces" : [ "application/xml", "application/json" ], "parameters" : [ { "name" : "username", "in" : "path", @@ -534,6 +634,273 @@ } } } + }, + "/fake_classname_test" : { + "patch" : { + "tags" : [ "fake_classname_tags 123#$%^" ], + "summary" : "To test class name in snake case", + "operationId" : "testClassname", + "consumes" : [ "application/json" ], + "produces" : [ "application/json" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "client model", + "required" : true, + "schema" : { + "$ref" : "#/definitions/Client" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Client" + } + } + } + } + }, + "/fake" : { + "get" : { + "tags" : [ "fake" ], + "summary" : "To test enum parameters", + "description" : "To test enum parameters", + "operationId" : "testEnumParameters", + "consumes" : [ "*/*" ], + "produces" : [ "*/*" ], + "parameters" : [ { + "name" : "enum_form_string_array", + "in" : "formData", + "description" : "Form parameter enum test (string array)", + "required" : false, + "type" : "array", + "items" : { + "type" : "string", + "default" : "$", + "enum" : [ ">", "$" ] + } + }, { + "name" : "enum_form_string", + "in" : "formData", + "description" : "Form parameter enum test (string)", + "required" : false, + "type" : "string", + "default" : "-efg", + "enum" : [ "_abc", "-efg", "(xyz)" ] + }, { + "name" : "enum_header_string_array", + "in" : "header", + "description" : "Header parameter enum test (string array)", + "required" : false, + "type" : "array", + "items" : { + "type" : "string", + "default" : "$", + "enum" : [ ">", "$" ] + } + }, { + "name" : "enum_header_string", + "in" : "header", + "description" : "Header parameter enum test (string)", + "required" : false, + "type" : "string", + "default" : "-efg", + "enum" : [ "_abc", "-efg", "(xyz)" ] + }, { + "name" : "enum_query_string_array", + "in" : "query", + "description" : "Query parameter enum test (string array)", + "required" : false, + "type" : "array", + "items" : { + "type" : "string", + "default" : "$", + "enum" : [ ">", "$" ] + } + }, { + "name" : "enum_query_string", + "in" : "query", + "description" : "Query parameter enum test (string)", + "required" : false, + "type" : "string", + "default" : "-efg", + "enum" : [ "_abc", "-efg", "(xyz)" ] + }, { + "name" : "enum_query_integer", + "in" : "query", + "description" : "Query parameter enum test (double)", + "required" : false, + "type" : "integer", + "format" : "int32" + }, { + "name" : "enum_query_double", + "in" : "formData", + "description" : "Query parameter enum test (double)", + "required" : false, + "type" : "number", + "format" : "double" + } ], + "responses" : { + "400" : { + "description" : "Invalid request" + }, + "404" : { + "description" : "Not found" + } + } + }, + "post" : { + "tags" : [ "fake" ], + "summary" : "Fake endpoint for testing various parameters\n假端點\n偽のエンドポイント\n가짜 엔드 포인트\n", + "description" : "Fake endpoint for testing various parameters\n假端點\n偽のエンドポイント\n가짜 엔드 포인트\n", + "operationId" : "testEndpointParameters", + "consumes" : [ "application/xml; charset=utf-8", "application/json; charset=utf-8" ], + "produces" : [ "application/xml; charset=utf-8", "application/json; charset=utf-8" ], + "parameters" : [ { + "name" : "integer", + "in" : "formData", + "description" : "None", + "required" : false, + "type" : "integer", + "maximum" : 100, + "minimum" : 10 + }, { + "name" : "int32", + "in" : "formData", + "description" : "None", + "required" : false, + "type" : "integer", + "maximum" : 200, + "minimum" : 20, + "format" : "int32" + }, { + "name" : "int64", + "in" : "formData", + "description" : "None", + "required" : false, + "type" : "integer", + "format" : "int64" + }, { + "name" : "number", + "in" : "formData", + "description" : "None", + "required" : true, + "type" : "number", + "maximum" : 543.200000000000045474735088646411895751953125, + "minimum" : 32.10000000000000142108547152020037174224853515625 + }, { + "name" : "float", + "in" : "formData", + "description" : "None", + "required" : false, + "type" : "number", + "maximum" : 987.6000000000000227373675443232059478759765625, + "format" : "float" + }, { + "name" : "double", + "in" : "formData", + "description" : "None", + "required" : true, + "type" : "number", + "maximum" : 123.400000000000005684341886080801486968994140625, + "minimum" : 67.7999999999999971578290569595992565155029296875, + "format" : "double" + }, { + "name" : "string", + "in" : "formData", + "description" : "None", + "required" : false, + "type" : "string", + "pattern" : "/[a-z]/i" + }, { + "name" : "pattern_without_delimiter", + "in" : "formData", + "description" : "None", + "required" : true, + "type" : "string", + "pattern" : "^[A-Z].*" + }, { + "name" : "byte", + "in" : "formData", + "description" : "None", + "required" : true, + "type" : "string", + "format" : "byte" + }, { + "name" : "binary", + "in" : "formData", + "description" : "None", + "required" : false, + "type" : "string", + "format" : "binary" + }, { + "name" : "date", + "in" : "formData", + "description" : "None", + "required" : false, + "type" : "string", + "format" : "date" + }, { + "name" : "dateTime", + "in" : "formData", + "description" : "None", + "required" : false, + "type" : "string", + "format" : "date-time" + }, { + "name" : "password", + "in" : "formData", + "description" : "None", + "required" : false, + "type" : "string", + "maxLength" : 64, + "minLength" : 10, + "format" : "password" + }, { + "name" : "callback", + "in" : "formData", + "description" : "None", + "required" : false, + "type" : "string" + } ], + "responses" : { + "400" : { + "description" : "Invalid username supplied" + }, + "404" : { + "description" : "User not found" + } + }, + "security" : [ { + "http_basic_test" : [ ] + } ] + }, + "patch" : { + "tags" : [ "fake" ], + "summary" : "To test \"client\" model", + "description" : "To test \"client\" model", + "operationId" : "testClientModel", + "consumes" : [ "application/json" ], + "produces" : [ "application/json" ], + "parameters" : [ { + "in" : "body", + "name" : "body", + "description" : "client model", + "required" : true, + "schema" : { + "$ref" : "#/definitions/Client" + } + } ], + "responses" : { + "200" : { + "description" : "successful operation", + "schema" : { + "$ref" : "#/definitions/Client" + } + } + } + } } }, "securityDefinitions" : { @@ -542,10 +909,13 @@ "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", "flow" : "implicit", "scopes" : { - "write_pets" : "modify pets in your account", - "read_pets" : "read your pets" + "write:pets" : "modify pets in your account", + "read:pets" : "read your pets" } }, + "http_basic_test" : { + "type" : "basic" + }, "api_key" : { "type" : "apiKey", "name" : "api_key", @@ -553,13 +923,62 @@ } }, "definitions" : { - "User" : { + "Order" : { "type" : "object", "properties" : { "id" : { "type" : "integer", "format" : "int64" }, + "petId" : { + "type" : "integer", + "format" : "int64" + }, + "quantity" : { + "type" : "integer", + "format" : "int32" + }, + "shipDate" : { + "type" : "string", + "format" : "date-time" + }, + "status" : { + "type" : "string", + "description" : "Order Status", + "enum" : [ "placed", "approved", "delivered" ] + }, + "complete" : { + "type" : "boolean", + "default" : false + } + }, + "xml" : { + "name" : "Order" + } + }, + "Category" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64" + }, + "name" : { + "type" : "string" + } + }, + "xml" : { + "name" : "Category" + } + }, + "User" : { + "type" : "object", + "properties" : { + "id" : { + "type" : "integer", + "format" : "int64", + "x-is-unique" : true + }, "username" : { "type" : "string" }, @@ -583,9 +1002,12 @@ "format" : "int32", "description" : "User Status" } + }, + "xml" : { + "name" : "User" } }, - "Category" : { + "Tag" : { "type" : "object", "properties" : { "id" : { @@ -595,6 +1017,9 @@ "name" : { "type" : "string" } + }, + "xml" : { + "name" : "Tag" } }, "Pet" : { @@ -603,7 +1028,8 @@ "properties" : { "id" : { "type" : "integer", - "format" : "int64" + "format" : "int64", + "x-is-unique" : true }, "category" : { "$ref" : "#/definitions/Category" @@ -614,61 +1040,446 @@ }, "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" + "description" : "pet status in the store", + "enum" : [ "available", "pending", "sold" ] } + }, + "xml" : { + "name" : "Pet" } }, - "Tag" : { + "ApiResponse" : { "type" : "object", "properties" : { - "id" : { + "code" : { + "type" : "integer", + "format" : "int32" + }, + "type" : { + "type" : "string" + }, + "message" : { + "type" : "string" + } + } + }, + "$special[model.name]" : { + "properties" : { + "$special[property.name]" : { "type" : "integer", "format" : "int64" + } + }, + "xml" : { + "name" : "$special[model.name]" + } + }, + "Return" : { + "properties" : { + "return" : { + "type" : "integer", + "format" : "int32" + } + }, + "description" : "Model for testing reserved words", + "xml" : { + "name" : "Return" + } + }, + "Name" : { + "required" : [ "name" ], + "properties" : { + "name" : { + "type" : "integer", + "format" : "int32" + }, + "snake_case" : { + "type" : "integer", + "format" : "int32", + "readOnly" : true }, + "property" : { + "type" : "string" + }, + "123Number" : { + "type" : "integer", + "readOnly" : true + } + }, + "description" : "Model for testing model name same as property name", + "xml" : { + "name" : "Name" + } + }, + "200_response" : { + "properties" : { "name" : { + "type" : "integer", + "format" : "int32" + }, + "class" : { "type" : "string" } + }, + "description" : "Model for testing model name starting with number", + "xml" : { + "name" : "Name" } }, - "Order" : { + "ClassModel" : { + "properties" : { + "_class" : { + "type" : "string" + } + }, + "description" : "Model for testing model with \"_class\" property" + }, + "Dog" : { + "allOf" : [ { + "$ref" : "#/definitions/Animal" + }, { + "type" : "object", + "properties" : { + "breed" : { + "type" : "string" + } + } + } ] + }, + "Cat" : { + "allOf" : [ { + "$ref" : "#/definitions/Animal" + }, { + "type" : "object", + "properties" : { + "declawed" : { + "type" : "boolean" + } + } + } ] + }, + "Animal" : { "type" : "object", + "required" : [ "className" ], + "discriminator" : "className", "properties" : { - "id" : { + "className" : { + "type" : "string" + }, + "color" : { + "type" : "string", + "default" : "red" + } + } + }, + "AnimalFarm" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/Animal" + } + }, + "format_test" : { + "type" : "object", + "required" : [ "byte", "date", "number", "password" ], + "properties" : { + "integer" : { "type" : "integer", - "format" : "int64" + "minimum" : 10, + "maximum" : 100 }, - "petId" : { + "int32" : { + "type" : "integer", + "format" : "int32", + "minimum" : 20, + "maximum" : 200 + }, + "int64" : { "type" : "integer", "format" : "int64" }, - "quantity" : { + "number" : { + "type" : "number", + "minimum" : 32.1, + "maximum" : 543.2 + }, + "float" : { + "type" : "number", + "format" : "float", + "minimum" : 54.3, + "maximum" : 987.6 + }, + "double" : { + "type" : "number", + "format" : "double", + "minimum" : 67.8, + "maximum" : 123.4 + }, + "string" : { + "type" : "string", + "pattern" : "/[a-z]/i" + }, + "byte" : { + "type" : "string", + "format" : "byte" + }, + "binary" : { + "type" : "string", + "format" : "binary" + }, + "date" : { + "type" : "string", + "format" : "date" + }, + "dateTime" : { + "type" : "string", + "format" : "date-time" + }, + "uuid" : { + "type" : "string", + "format" : "uuid" + }, + "password" : { + "type" : "string", + "format" : "password", + "minLength" : 10, + "maxLength" : 64 + } + } + }, + "EnumClass" : { + "type" : "string", + "enum" : [ "_abc", "-efg", "(xyz)" ], + "default" : "-efg" + }, + "Enum_Test" : { + "type" : "object", + "properties" : { + "enum_string" : { + "type" : "string", + "enum" : [ "UPPER", "lower" ] + }, + "enum_integer" : { "type" : "integer", - "format" : "int32" + "format" : "int32", + "enum" : [ 1, -1 ] }, - "shipDate" : { + "enum_number" : { + "type" : "number", + "format" : "double", + "enum" : [ 1.1, -1.2 ] + }, + "outerEnum" : { + "$ref" : "#/definitions/OuterEnum" + } + } + }, + "AdditionalPropertiesClass" : { + "type" : "object", + "properties" : { + "map_property" : { + "type" : "object", + "additionalProperties" : { + "type" : "string" + } + }, + "map_of_map_property" : { + "type" : "object", + "additionalProperties" : { + "type" : "object", + "additionalProperties" : { + "type" : "string" + } + } + } + } + }, + "MixedPropertiesAndAdditionalPropertiesClass" : { + "type" : "object", + "properties" : { + "uuid" : { + "type" : "string", + "format" : "uuid" + }, + "dateTime" : { "type" : "string", "format" : "date-time" }, - "status" : { + "map" : { + "type" : "object", + "additionalProperties" : { + "$ref" : "#/definitions/Animal" + } + } + } + }, + "List" : { + "type" : "object", + "properties" : { + "123-list" : { + "type" : "string" + } + } + }, + "Client" : { + "type" : "object", + "properties" : { + "client" : { + "type" : "string" + } + } + }, + "ReadOnlyFirst" : { + "type" : "object", + "properties" : { + "bar" : { "type" : "string", - "description" : "Order Status" + "readOnly" : true }, - "complete" : { - "type" : "boolean" + "baz" : { + "type" : "string" } } + }, + "hasOnlyReadOnly" : { + "type" : "object", + "properties" : { + "bar" : { + "type" : "string", + "readOnly" : true + }, + "foo" : { + "type" : "string", + "readOnly" : true + } + } + }, + "MapTest" : { + "type" : "object", + "properties" : { + "map_map_of_string" : { + "type" : "object", + "additionalProperties" : { + "type" : "object", + "additionalProperties" : { + "type" : "string" + } + } + }, + "map_of_enum_string" : { + "type" : "object", + "additionalProperties" : { + "type" : "string", + "enum" : [ "UPPER", "lower" ] + } + } + } + }, + "ArrayTest" : { + "type" : "object", + "properties" : { + "array_of_string" : { + "type" : "array", + "items" : { + "type" : "string" + } + }, + "array_array_of_integer" : { + "type" : "array", + "items" : { + "type" : "array", + "items" : { + "type" : "integer", + "format" : "int64" + } + } + }, + "array_array_of_model" : { + "type" : "array", + "items" : { + "type" : "array", + "items" : { + "$ref" : "#/definitions/ReadOnlyFirst" + } + } + } + } + }, + "NumberOnly" : { + "type" : "object", + "properties" : { + "JustNumber" : { + "type" : "number" + } + } + }, + "ArrayOfNumberOnly" : { + "type" : "object", + "properties" : { + "ArrayNumber" : { + "type" : "array", + "items" : { + "type" : "number" + } + } + } + }, + "ArrayOfArrayOfNumberOnly" : { + "type" : "object", + "properties" : { + "ArrayArrayNumber" : { + "type" : "array", + "items" : { + "type" : "array", + "items" : { + "type" : "number" + } + } + } + } + }, + "EnumArrays" : { + "type" : "object", + "properties" : { + "just_symbol" : { + "type" : "string", + "enum" : [ ">=", "$" ] + }, + "array_enum" : { + "type" : "array", + "items" : { + "type" : "string", + "enum" : [ "fish", "crab" ] + } + } + } + }, + "OuterEnum" : { + "type" : "string", + "enum" : [ "placed", "approved", "delivered" ] } + }, + "externalDocs" : { + "description" : "Find out more about Swagger", + "url" : "http://swagger.io" } } \ No newline at end of file From e77afa6efc9232c98c74ee1efb42fd2a25f677ea Mon Sep 17 00:00:00 2001 From: "J. Fiala" Date: Wed, 8 Feb 2017 11:42:45 +0100 Subject: [PATCH 2/2] replace tabs with spaces --- .../languages/JavaJAXRSSpecServerCodegen.java | 45 +++++++++---------- .../JavaJaxRS/spec/RestApplication.mustache | 2 +- .../resources/JavaJaxRS/spec/pom.mustache | 30 ++++++------- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java index 3c21b5717b1..53cf590a88f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java @@ -20,9 +20,8 @@ import org.apache.commons.io.FileUtils; public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen -{ - public JavaJAXRSSpecServerCodegen() - { +{ + public JavaJAXRSSpecServerCodegen() { super(); invokerPackage = "io.swagger.api"; artifactId = "swagger-jaxrs-server"; @@ -69,26 +68,24 @@ public JavaJAXRSSpecServerCodegen() library.setEnum(supportedLibraries); cliOptions.add(library); - } - - @Override - public void processOpts() - { - super.processOpts(); - - supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen + } + + @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 String getName() { + return "jaxrs-spec"; + } @Override public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { @@ -129,16 +126,16 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert model.imports.remove("JsonProperty"); } - @Override + @Override public void preprocessSwagger(Swagger swagger) { - //copy input swagger to output folder - try { - String swaggerJson = Json.pretty(swagger); + // copy input swagger to output folder + try { + String swaggerJson = Json.pretty(swagger); FileUtils.writeStringToFile(new File(outputFolder + File.separator + "swagger.json"), swaggerJson); - } catch (IOException e) { + } catch (IOException e) { throw new RuntimeException(e.getMessage(), e.getCause()); - } - super.preprocessSwagger(swagger); + } + super.preprocessSwagger(swagger); } @Override diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/RestApplication.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/RestApplication.mustache index b6ba3b369b1..bb19dbd2a4f 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/RestApplication.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/RestApplication.mustache @@ -5,5 +5,5 @@ import javax.ws.rs.core.Application; @ApplicationPath("/") public class RestApplication extends Application { - + } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/pom.mustache b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/pom.mustache index 56675ed9109..6d34d7ed16c 100644 --- a/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/JavaJaxRS/spec/pom.mustache @@ -12,9 +12,9 @@ org.apache.maven.plugins maven-war-plugin 2.6 - - false - + + false + maven-failsafe-plugin @@ -50,18 +50,18 @@ - - javax.ws.rs - javax.ws.rs-api - 2.0 - provided - - - io.swagger - swagger-annotations - provided - 1.5.3 - + + javax.ws.rs + javax.ws.rs-api + 2.0 + provided + + + io.swagger + swagger-annotations + provided + 1.5.3 + junit junit