[JAX-RS] fix library setting "jersey2" (#3016)

* to fix #2981

* update sample, update ci to include jaxrs (jersey1, 2)

* avoid duplicated artifactId in pom (jaxrs jersey1)

* update jetty dependency for jersey1 jaxrs

* update bin to set proper artifact-id

* fix jersey1 jaxrs pom.xml

* fix dependency in jaxrs jersey2 pom

* downgrade jetty plugin to 9.3.0.v20150612

* update petstore sample for jaxrs jersey 1

* restore jetty to previous version. update test order

* downgrade jetty maven plugin version

* restore original version of jetty plugin
This commit is contained in:
wing328 2016-06-02 14:33:08 +08:00
parent 85550285a1
commit 23d2c56096
142 changed files with 2520 additions and 113 deletions

View File

@ -0,0 +1,31 @@
#!/bin/sh
SCRIPT="$0"
while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done
if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
if [ ! -f "$executable" ]
then
mvn clean package
fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs -o samples/server/petstore/jaxrs/jersey1 -DhideGenerationTimestamp=true --library=jersey1 --artifact-id=swagger-jaxrs-jersey1-server"
java $JAVA_OPTS -jar $executable $ags

View File

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

View File

@ -8,10 +8,12 @@ import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.Swagger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen
{
public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen {
/**
* Name of the sub-directory in "src/main/resource" where to find the
* Mustache template for the JAX-RS Codegen.
@ -19,6 +21,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen
protected static final String JAXRS_TEMPLATE_DIRECTORY_NAME = "JavaJaxRS";
protected String implFolder = "src/main/java";
protected String title = "Swagger Server";
static Logger LOGGER = LoggerFactory.getLogger(AbstractJavaJAXRSServerCodegen.class);
public AbstractJavaJAXRSServerCodegen()
{
@ -199,4 +202,5 @@ public abstract class AbstractJavaJAXRSServerCodegen extends JavaClientCodegen
public boolean shouldOverwrite(String filename) {
return super.shouldOverwrite(filename) && !filename.endsWith("ServiceImpl.java") && !filename.endsWith("ServiceFactory.java");
}
}

View File

@ -6,6 +6,8 @@ import io.swagger.models.Operation;
import java.io.File;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
public JavaJerseyServerCodegen() {
super();
@ -26,7 +28,7 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
additionalProperties.put("title", title);
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "jersey1_18";
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME;
for ( int i = 0; i < cliOptions.size(); i++ ) {
if ( CodegenConstants.LIBRARY.equals(cliOptions.get(i).getOpt()) ) {
@ -36,13 +38,11 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
}
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
library.setDefault(DEFAULT_LIBRARY);
Map<String, String> supportedLibraries = new LinkedHashMap<String, String>();
supportedLibraries.put(DEFAULT_LIBRARY, "Jersey core 1.18.1");
supportedLibraries.put("jersey2", "Jersey core 2.x");
supportedLibraries.put("jersey1", "Jersey core 1.x");
supportedLibraries.put("jersey2", "Jersey core 2.x (default)");
library.setEnum(supportedLibraries);
library.setDefault("jersey1");
cliOptions.add(library);
cliOptions.add(new CliOption(CodegenConstants.IMPL_FOLDER, CodegenConstants.IMPL_FOLDER_DESC));
@ -73,16 +73,35 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
public void processOpts() {
super.processOpts();
// set jersey2 as default
if (StringUtils.isEmpty(library)) {
setLibrary("jersey2");
}
supportingFiles.clear();
// clear model and api doc template as this codegen
// does not support auto-generated markdown doc at the moment
modelDocTemplateFiles.remove("model_doc.mustache");
apiDocTemplateFiles.remove("api_doc.mustache");
if ( additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER) ) {
if ( additionalProperties.containsKey(CodegenConstants.IMPL_FOLDER)) {
implFolder = (String) additionalProperties.get(CodegenConstants.IMPL_FOLDER);
}
supportingFiles.clear();
if (additionalProperties.containsKey("dateLibrary")) {
setDateLibrary(additionalProperties.get("dateLibrary").toString());
additionalProperties.put(dateLibrary, "true");
}
if ("joda".equals(dateLibrary)) {
supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java"));
supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaLocalDateProvider.java"));
} else if ( "java8".equals(dateLibrary) ) {
supportingFiles.add(new SupportingFile("LocalDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateTimeProvider.java"));
supportingFiles.add(new SupportingFile("LocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java"));
}
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("ApiException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "ApiException.java"));
@ -91,40 +110,8 @@ public class JavaJerseyServerCodegen extends AbstractJavaJAXRSServerCodegen {
supportingFiles.add(new SupportingFile("NotFoundException.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "NotFoundException.java"));
supportingFiles.add(new SupportingFile("jacksonJsonProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JacksonJsonProvider.java"));
writeOptional(outputFolder, new SupportingFile("bootstrap.mustache", (implFolder + '/' + apiPackage).replace(".", "/"), "Bootstrap.java"));
writeOptional(outputFolder, new SupportingFile("web.mustache", ("src/main/webapp/WEB-INF"), "web.xml"));
supportingFiles.add(new SupportingFile("StringUtil.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "StringUtil.java"));
if ( additionalProperties.containsKey("dateLibrary") ) {
setDateLibrary(additionalProperties.get("dateLibrary").toString());
additionalProperties.put(dateLibrary, "true");
}
if(DEFAULT_LIBRARY.equals(library) || library == null) {
if(templateDir.startsWith(JAXRS_TEMPLATE_DIRECTORY_NAME)) {
// set to the default location
templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "jersey1_18";
}
else {
templateDir += File.separator + "jersey1_18";
}
}
if("jersey2".equals(library)) {
if(templateDir.startsWith(JAXRS_TEMPLATE_DIRECTORY_NAME)) {
// set to the default location
templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "jersey2";
}
else {
templateDir += File.separator + "jersey2";
}
}
if ( "joda".equals(dateLibrary) ) {
supportingFiles.add(new SupportingFile("JodaDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaDateTimeProvider.java"));
supportingFiles.add(new SupportingFile("JodaLocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "JodaLocalDateProvider.java"));
} else if ( "java8".equals(dateLibrary) ) {
supportingFiles.add(new SupportingFile("LocalDateTimeProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateTimeProvider.java"));
supportingFiles.add(new SupportingFile("LocalDateProvider.mustache", (sourceFolder + '/' + apiPackage).replace(".", "/"), "LocalDateProvider.java"));
}
}
@Override

View File

@ -1,6 +1,8 @@
package {{package}};
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
{{#imports}}import {{import}};
{{/imports}}

View File

@ -168,11 +168,12 @@
</repository>
</repositories>
<properties>
<swagger-core-version>1.5.8</swagger-core-version>
<swagger-core-version>1.5.9</swagger-core-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<jersey-version>1.18.1</jersey-version>
<slf4j-version>1.6.3</slf4j-version>
<junit-version>4.8.1</junit-version>
<jersey-version>1.19.1</jersey-version>
<slf4j-version>1.7.21</slf4j-version>
<junit-version>4.12</junit-version>
<servlet-api-version>2.5</servlet-api-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
</project>

View File

@ -1,6 +1,6 @@
public enum {{{datatypeWithEnum}}} {
{{#allowableValues}}{{#enumVars}}{{{name}}}("{{{value}}}"){{^-last}},
{{#allowableValues}}{{#enumVars}}{{{name}}}({{{value}}}){{^-last}},
{{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}}
private String value;

View File

@ -134,12 +134,13 @@
</repository>
</repositories>
<properties>
<swagger-core-version>1.5.8</swagger-core-version>
<swagger-core-version>1.5.9</swagger-core-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<jersey2-version>2.6</jersey2-version>
<slf4j-version>1.6.3</slf4j-version>
<junit-version>4.8.1</junit-version>
<logback-version>1.0.1</logback-version>
<jersey2-version>2.22.2</jersey2-version>
<slf4j-version>1.7.21</slf4j-version>
<junit-version>4.12</junit-version>
<logback-version>1.1.7</logback-version>
<servlet-api-version>2.5</servlet-api-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
</project>

View File

@ -17,7 +17,7 @@ import java.nio.charset.StandardCharsets;
public class AllowableValuesTest {
private static final String TEMPLATE_FILE = "JavaJaxRS/jersey1_18/allowableValues.mustache";
private static final String TEMPLATE_FILE = "JavaJaxRS/libraries/jersey1/allowableValues.mustache";
private static final String PROVIDER_NAME = "operations";
private static String loadClassResource(Class<?> cls, String name) throws IOException {

View File

@ -46,7 +46,8 @@ public class JaxRSServerOptionsTest extends JavaClientOptionsTest {
times = 1;
clientCodegen.setSerializableModel(Boolean.valueOf(JaxRSServerOptionsProvider.SERIALIZABLE_MODEL_VALUE));
times = 1;
clientCodegen.setLibrary(JaxRSServerOptionsProvider.DEFAULT_LIBRARY_VALUE);
//clientCodegen.setLibrary(JaxRSServerOptionsProvider.JAXRS_LIBRARY_VALUE);
clientCodegen.setLibrary("jersey1");
times = 1;
clientCodegen.setFullJavaUtil(Boolean.valueOf(JaxRSServerOptionsProvider.FULL_JAVA_UTIL_VALUE));
times = 1;

View File

@ -2,12 +2,27 @@ package io.swagger.codegen.options;
import com.google.common.collect.ImmutableMap;
import io.swagger.codegen.CodegenConstants;
import io.swagger.codegen.languages.JavaClientCodegen;
import java.util.Map;
public class JaxRSServerOptionsProvider extends JavaOptionsProvider {
public class JaxRSServerOptionsProvider implements OptionsProvider {
public static final String ARTIFACT_ID_VALUE = "swagger-java-client-test";
public static final String MODEL_PACKAGE_VALUE = "package";
public static final String API_PACKAGE_VALUE = "apiPackage";
public static final String INVOKER_PACKAGE_VALUE = "io.swagger.client.test";
public static final String SORT_PARAMS_VALUE = "false";
public static final String GROUP_ID_VALUE = "io.swagger.test";
public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
public static final String SOURCE_FOLDER_VALUE = "src/main/java/test";
public static final String LOCAL_PREFIX_VALUE = "tst";
public static final String DEFAULT_LIBRARY_VALUE = "jersey2";
public static final String SERIALIZABLE_MODEL_VALUE = "false";
public static final String FULL_JAVA_UTIL_VALUE = "true";
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
public static final String JODA_DATE_LIBRARY = "joda";
public static final String IMPL_FOLDER_VALUE = "src/main/java/impl";
public static final String IMPL_FOLDER_VALUE = "src/main/java/impl";
public static final String JAXRS_DEFAULT_LIBRARY_VALUE = "jersey1";
@Override
public boolean isServer() {
@ -21,13 +36,27 @@ public class JaxRSServerOptionsProvider extends JavaOptionsProvider {
@Override
public Map<String, String> createOptions() {
Map<String, String> options = super.createOptions();
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>();
builder.putAll(options)
.put(CodegenConstants.IMPL_FOLDER, IMPL_FOLDER_VALUE)
//.put(JavaJaxRSJersey1ServerCodegen.DATE_LIBRARY, "joda") //java.lang.IllegalArgumentException: Multiple entries with same key: dateLibrary=joda and dateLibrary=joda
.put("title", "Test title");
builder.put(CodegenConstants.IMPL_FOLDER, IMPL_FOLDER_VALUE)
.put(JavaClientCodegen.DATE_LIBRARY, "joda") //java.lang.IllegalArgumentException: Multiple entries with same key: dateLibrary=joda and dateLibrary=joda
.put("title", "Test title")
.put(CodegenConstants.MODEL_PACKAGE, MODEL_PACKAGE_VALUE)
.put(CodegenConstants.API_PACKAGE, API_PACKAGE_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, SORT_PARAMS_VALUE)
.put(CodegenConstants.ENSURE_UNIQUE_PARAMS, ENSURE_UNIQUE_PARAMS_VALUE)
.put(CodegenConstants.INVOKER_PACKAGE, INVOKER_PACKAGE_VALUE)
.put(CodegenConstants.GROUP_ID, GROUP_ID_VALUE)
.put(CodegenConstants.ARTIFACT_ID, ARTIFACT_ID_VALUE)
.put(CodegenConstants.ARTIFACT_VERSION, ARTIFACT_VERSION_VALUE)
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
.put(CodegenConstants.LOCAL_VARIABLE_PREFIX, LOCAL_PREFIX_VALUE)
.put(CodegenConstants.SERIALIZABLE_MODEL, SERIALIZABLE_MODEL_VALUE)
.put(JavaClientCodegen.FULL_JAVA_UTIL, FULL_JAVA_UTIL_VALUE)
.put(CodegenConstants.LIBRARY, JAXRS_DEFAULT_LIBRARY_VALUE)
.put(CodegenConstants.SERIALIZE_BIG_DECIMAL_AS_STRING, "true")
.put(JavaClientCodegen.USE_RX_JAVA, "false")
//.put(JavaClientCodegen.DATE_LIBRARY, "joda")
.put("hideGenerationTimestamp", "true");
return builder.build();
}

17
pom.xml
View File

@ -435,7 +435,19 @@
</property>
</activation>
<modules>
<module>samples/server/petstore/jaxrs</module>
<module>samples/server/petstore/jaxrs/jersey2</module>
</modules>
</profile>
<profile>
<id>jaxrs-server-jersey1</id>
<activation>
<property>
<name>env</name>
<value>java</value>
</property>
</activation>
<modules>
<module>samples/server/petstore/jaxrs/jersey1</module>
</modules>
</profile>
<profile>
@ -564,7 +576,8 @@
<module>samples/client/petstore/javascript</module>
<module>samples/client/petstore/scala</module>
<module>samples/server/petstore/spring-mvc</module>
<module>samples/server/petstore/jaxrs</module>
<module>samples/server/petstore/jaxrs/jersey1</module>
<module>samples/server/petstore/jaxrs/jersey2</module>
<module>samples/server/petstore/jaxrs-resteasy</module>
<!--module>samples/client/petstore/objc/SwaggerClientTests</module-->
<!--module>samples/client/petstore/swift/SwaggerClientTests</module-->

View File

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

View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,9 +1,9 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs-server</artifactId>
<artifactId>swagger-jaxrs-jersey1-server</artifactId>
<packaging>jar</packaging>
<name>swagger-jaxrs-server</name>
<name>swagger-jaxrs-jersey1-server</name>
<version>1.0.0</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
@ -168,11 +168,12 @@
</repository>
</repositories>
<properties>
<swagger-core-version>1.5.8</swagger-core-version>
<swagger-core-version>1.5.9</swagger-core-version>
<jetty-version>9.2.9.v20150224</jetty-version>
<jersey-version>1.18.1</jersey-version>
<slf4j-version>1.6.3</slf4j-version>
<junit-version>4.8.1</junit-version>
<jersey-version>1.19.1</jersey-version>
<slf4j-version>1.7.21</slf4j-version>
<junit-version>4.12</junit-version>
<servlet-api-version>2.5</servlet-api-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
</project>

View File

@ -0,0 +1,94 @@
package io.swagger.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
public class Category {
private Long id = null;
private String name = null;
/**
**/
public Category id(Long id) {
this.id = id;
return this;
}
@ApiModelProperty(value = "")
@JsonProperty("id")
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
**/
public Category name(String name) {
this.name = name;
return this;
}
@ApiModelProperty(value = "")
@JsonProperty("name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Category category = (Category) o;
return Objects.equals(id, category.id) &&
Objects.equals(name, category.name);
}
@Override
public int hashCode() {
return Objects.hash(id, name);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Category {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -2,6 +2,7 @@ package io.swagger.model;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ -10,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
public class ApiResponse {
public class ModelApiResponse {
private Integer code = null;
private String type = null;
@ -18,7 +19,7 @@ public class ApiResponse {
/**
**/
public ApiResponse code(Integer code) {
public ModelApiResponse code(Integer code) {
this.code = code;
return this;
}
@ -35,7 +36,7 @@ public class ApiResponse {
/**
**/
public ApiResponse type(String type) {
public ModelApiResponse type(String type) {
this.type = type;
return this;
}
@ -52,7 +53,7 @@ public class ApiResponse {
/**
**/
public ApiResponse message(String message) {
public ModelApiResponse message(String message) {
this.message = message;
return this;
}
@ -76,10 +77,10 @@ public class ApiResponse {
if (o == null || getClass() != o.getClass()) {
return false;
}
ApiResponse apiResponse = (ApiResponse) o;
return Objects.equals(code, apiResponse.code) &&
Objects.equals(type, apiResponse.type) &&
Objects.equals(message, apiResponse.message);
ModelApiResponse _apiResponse = (ModelApiResponse) o;
return Objects.equals(code, _apiResponse.code) &&
Objects.equals(type, _apiResponse.type) &&
Objects.equals(message, _apiResponse.message);
}
@Override
@ -90,7 +91,7 @@ public class ApiResponse {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ApiResponse {\n");
sb.append("class ModelApiResponse {\n");
sb.append(" code: ").append(toIndentedString(code)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");

Some files were not shown because too many files have changed in this diff Show More