put spring-mvc and spring-boot under the same language gen

This commit is contained in:
cbornet
2016-06-14 13:53:15 +02:00
parent 79dc34266f
commit ec6a9257e2
70 changed files with 1891 additions and 746 deletions

View File

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

View File

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

View File

@@ -26,7 +26,7 @@ fi
# if you've executed sbt assembly previously it will use that instead. # if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpringBoot -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l springboot -o samples/server/petstore/springboot -DhideGenerationTimestamp=true" ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaSpringBoot -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l spring --library=spring-boot -o samples/server/petstore/springboot -DhideGenerationTimestamp=true"
echo "Removing files and folders under samples/server/petstore/springboot/src/main" echo "Removing files and folders under samples/server/petstore/springboot/src/main"
rm -rf samples/server/petstore/springboot/src/main rm -rf samples/server/petstore/springboot/src/main

View File

@@ -40,7 +40,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen {
supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.2.0. JSON processing: Gson 2.6.1 (Retrofit 2.0.2). Enable the RxJava adapter using '-DuseRxJava=true'. (RxJava 1.1.3)"); supportedLibraries.put(RETROFIT_2, "HTTP client: OkHttp 3.2.0. JSON processing: Gson 2.6.1 (Retrofit 2.0.2). Enable the RxJava adapter using '-DuseRxJava=true'. (RxJava 1.1.3)");
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
library.setDefault(DEFAULT_LIBRARY);
library.setEnum(supportedLibraries); library.setEnum(supportedLibraries);
library.setDefault(DEFAULT_LIBRARY); library.setDefault(DEFAULT_LIBRARY);
cliOptions.add(library); cliOptions.add(library);

View File

@@ -26,13 +26,13 @@ public class SpringBootServerCodegen extends AbstractJavaCodegen {
public SpringBootServerCodegen() { public SpringBootServerCodegen() {
super(); super();
outputFolder = "generated-code/javaSpringBoot"; outputFolder = "generated-code/javaSpring";
apiTestTemplateFiles.clear(); // TODO: add test template apiTestTemplateFiles.clear(); // TODO: add test template
embeddedTemplateDir = templateDir = "JavaSpringBoot"; embeddedTemplateDir = templateDir = "JavaSpringBoot";
apiPackage = "io.swagger.api"; apiPackage = "io.swagger.api";
modelPackage = "io.swagger.model"; modelPackage = "io.swagger.model";
invokerPackage = "io.swagger.api"; invokerPackage = "io.swagger.api";
artifactId = "swagger-springboot-server"; artifactId = "swagger-spring-server";
additionalProperties.put("title", title); additionalProperties.put("title", title);
additionalProperties.put(CONFIG_PACKAGE, configPackage); additionalProperties.put(CONFIG_PACKAGE, configPackage);
@@ -45,17 +45,14 @@ public class SpringBootServerCodegen extends AbstractJavaCodegen {
cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface")); cliOptions.add(CliOption.newBoolean(JAVA_8, "use java8 default interface"));
cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers")); cliOptions.add(CliOption.newBoolean(ASYNC, "use async Callable controllers"));
supportedLibraries.put(DEFAULT_LIBRARY, "Default Spring Boot server stub."); supportedLibraries.put(DEFAULT_LIBRARY, "Spring-boot Server application using the SpringFox integration.");
supportedLibraries.put("j8-async", "Use async servlet feature and Java 8's default interface. Generating interface with service " + supportedLibraries.put("spring-mvc", "Spring-MVC Server application using the SpringFox integration.");
"declaration is useful when using Maven plugin. Just provide a implementation with @Controller to instantiate service." +
"(DEPRECATED: use -Djava8=true,async=true instead)");
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
library.setDefault(DEFAULT_LIBRARY); library.setDefault(DEFAULT_LIBRARY);
library.setEnum(supportedLibraries); library.setEnum(supportedLibraries);
library.setDefault(DEFAULT_LIBRARY); library.setDefault(DEFAULT_LIBRARY);
cliOptions.add(library); cliOptions.add(library);
} }
@Override @Override
@@ -65,7 +62,7 @@ public class SpringBootServerCodegen extends AbstractJavaCodegen {
@Override @Override
public String getName() { public String getName() {
return "springboot"; return "spring";
} }
@Override @Override
@@ -122,17 +119,24 @@ public class SpringBootServerCodegen extends AbstractJavaCodegen {
(sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "NotFoundException.java")); (sourceFolder + File.separator + apiPackage).replace(".", java.io.File.separator), "NotFoundException.java"));
supportingFiles.add(new SupportingFile("swaggerDocumentationConfig.mustache", supportingFiles.add(new SupportingFile("swaggerDocumentationConfig.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerDocumentationConfig.java")); (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerDocumentationConfig.java"));
supportingFiles.add(new SupportingFile("homeController.mustache", if (library.equals(DEFAULT_LIBRARY)) {
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java")); supportingFiles.add(new SupportingFile("homeController.mustache",
supportingFiles.add(new SupportingFile("swagger2SpringBoot.mustache", (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HomeController.java"));
(sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "Swagger2SpringBoot.java")); supportingFiles.add(new SupportingFile("swagger2SpringBoot.mustache",
supportingFiles.add(new SupportingFile("application.properties", (sourceFolder + File.separator + basePackage).replace(".", java.io.File.separator), "Swagger2SpringBoot.java"));
("src.main.resources").replace(".", java.io.File.separator), "application.properties")); supportingFiles.add(new SupportingFile("application.properties",
} ("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
}
if ("j8-async".equals(getLibrary())) { if (library.equals("mvc")) {
setJava8(true); supportingFiles.add(new SupportingFile("webApplication.mustache",
setAsync(true); (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebApplication.java"));
supportingFiles.add(new SupportingFile("webMvcConfiguration.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "WebMvcConfiguration.java"));
supportingFiles.add(new SupportingFile("swaggerUiConfiguration.mustache",
(sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "SwaggerUiConfiguration.java"));
supportingFiles.add(new SupportingFile("application.properties",
("src.main.resources").replace(".", java.io.File.separator), "swagger.properties"));
}
} }
if (this.java8) { if (this.java8) {

View File

@@ -2,8 +2,8 @@ package {{apiPackage}};
import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement
{{>generatedAnnotation}} {{>generatedAnnotation}}
@javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;

View File

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

View File

@@ -0,0 +1,12 @@
# Swagger generated server
Spring MVC Server
## Overview
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [OpenAPI-Spec](https://github.com/swagger-api/swagger-core), you can easily generate a server stub. This is an example of building a swagger-enabled server in Java using the Spring MVC framework.
The underlying library integrating swagger to Spring-MVC is [springfox](https://github.com/springfox/springfox)
You can view the server in swagger-ui by pointing to
http://localhost:8002{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}/swagger-ui.html

View File

@@ -0,0 +1,130 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<packaging>jar</packaging>
<name>{{artifactId}}</name>
<version>{{artifactVersion}}</version>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-version}</version>
<configuration>
<webAppConfig>
<contextPath>{{^contextPath}}/{{/contextPath}}{{#contextPath}}{{contextPath}}{{/contextPath}}</contextPath>
</webAppConfig>
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
<stopPort>8079</stopPort>
<stopKey>stopit</stopKey>
<httpConnector>
<port>8002</port>
<idleTimeout>60000</idleTimeout>
</httpConnector>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
<configuration>
<scanIntervalSeconds>0</scanIntervalSeconds>
<daemon>true</daemon>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey-jaxrs</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-version}</version>
</dependency>
<!--Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-version}</version>
</dependency>
<!--SpringFox dependencies-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api-version}</version>
</dependency>
</dependencies>
<properties>
<swagger-core-version>1.5.8</swagger-core-version>
<jetty-version>9.2.15.v20160210</jetty-version>
<jersey-version>1.13</jersey-version>
<slf4j-version>1.7.21</slf4j-version>
<junit-version>4.12</junit-version>
<servlet-api-version>2.5</servlet-api-version>
<springfox-version>2.4.0</springfox-version>
<spring-version>4.2.5.RELEASE</spring-version>
</properties>
</project>

View File

@@ -0,0 +1,50 @@
package {{configPackage}};
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
{{>generatedAnnotation}}
@Configuration
@ComponentScan(basePackages = "{{apiPackage}}")
@EnableWebMvc
@EnableSwagger2 //Loads the spring beans required by the framework
@PropertySource("classpath:swagger.properties")
@Import(SwaggerDocumentationConfig.class)
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };
private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
"classpath:/META-INF/resources/", "classpath:/resources/",
"classpath:/static/", "classpath:/public/" };
private static final String[] RESOURCE_LOCATIONS;
static {
RESOURCE_LOCATIONS = new String[CLASSPATH_RESOURCE_LOCATIONS.length
+ SERVLET_RESOURCE_LOCATIONS.length];
System.arraycopy(SERVLET_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS, 0,
SERVLET_RESOURCE_LOCATIONS.length);
System.arraycopy(CLASSPATH_RESOURCE_LOCATIONS, 0, RESOURCE_LOCATIONS,
SERVLET_RESOURCE_LOCATIONS.length, CLASSPATH_RESOURCE_LOCATIONS.length);
}
private static final String[] STATIC_INDEX_HTML_RESOURCES;
static {
STATIC_INDEX_HTML_RESOURCES = new String[RESOURCE_LOCATIONS.length];
for (int i = 0; i < STATIC_INDEX_HTML_RESOURCES.length; i++) {
STATIC_INDEX_HTML_RESOURCES[i] = RESOURCE_LOCATIONS[i] + "index.html";
}
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
if (!registry.hasMappingForPattern("/webjars/**")) {
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
if (!registry.hasMappingForPattern("/**")) {
registry.addResourceHandler("/**").addResourceLocations(RESOURCE_LOCATIONS);
}
}
}

View File

@@ -0,0 +1,22 @@
package {{configPackage}};
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
{{>generatedAnnotation}}
public class WebApplication extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class[] { SwaggerUiConfiguration.class };
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class<?>[] { WebMvcConfiguration.class };
}
@Override
protected String[] getServletMappings() {
return new String[] { "/" };
}
}

View File

@@ -0,0 +1,12 @@
package {{configPackage}};
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
{{>generatedAnnotation}}
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
}

View File

@@ -13,8 +13,8 @@ import java.util.Objects;
/** /**
* {{description}} * {{description}}
**/{{/description}} **/{{/description}}
@ApiModel(description = "{{{description}}}")
{{>generatedAnnotation}} {{>generatedAnnotation}}
@ApiModel(description = "{{{description}}}")
public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} { public class {{classname}} {{#parent}}extends {{{parent}}}{{/parent}} {
{{#vars}}{{#isEnum}} {{#vars}}{{#isEnum}}
public enum {{datatypeWithEnum}} { public enum {{datatypeWithEnum}} {

View File

@@ -10,10 +10,8 @@ import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
@Configuration
{{>generatedAnnotation}} {{>generatedAnnotation}}
@Configuration
public class SwaggerDocumentationConfig { public class SwaggerDocumentationConfig {
ApiInfo apiInfo() { ApiInfo apiInfo() {

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"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-spring-mvc-server</artifactId> <artifactId>swagger-spring-server</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>swagger-spring-mvc-server</name> <name>swagger-spring-server</name>
<version>1.0.0</version> <version>1.0.0</version>
<build> <build>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>
@@ -11,7 +11,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version> <version>2.6</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-failsafe-plugin</artifactId> <artifactId>maven-failsafe-plugin</artifactId>
@@ -62,15 +62,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies> <dependencies>
@@ -84,31 +75,6 @@
<artifactId>slf4j-log4j12</artifactId> <artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-version}</version> <version>${slf4j-version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey-version}</version>
</dependency>
<!--Spring dependencies --> <!--Spring dependencies -->
<dependency> <dependency>
@@ -151,21 +117,14 @@
<version>${servlet-api-version}</version> <version>${servlet-api-version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
<repositories>
<repository>
<id>jcenter-snapshots</id>
<name>jcenter</name>
<url>http://oss.jfrog.org/artifactory/oss-snapshot-local/</url>
</repository>
</repositories>
<properties> <properties>
<swagger-core-version>1.5.8</swagger-core-version> <swagger-core-version>1.5.8</swagger-core-version>
<jetty-version>9.2.9.v20150224</jetty-version> <jetty-version>9.2.15.v20160210</jetty-version>
<jersey-version>1.13</jersey-version> <jersey-version>1.13</jersey-version>
<slf4j-version>1.6.3</slf4j-version> <slf4j-version>1.7.21</slf4j-version>
<junit-version>4.8.1</junit-version> <junit-version>4.12</junit-version>
<servlet-api-version>2.5</servlet-api-version> <servlet-api-version>2.5</servlet-api-version>
<springfox-version>2.4.0</springfox-version> <springfox-version>2.4.0</springfox-version>
<spring-version>4.2.5.RELEASE</spring-version> <spring-version>4.2.5.RELEASE</spring-version>
</properties> </properties>
</project> </project>

View File

@@ -1,6 +1,6 @@
package io.swagger.api; package io.swagger.api;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class ApiException extends Exception{ public class ApiException extends Exception{
private int code; private int code;
public ApiException (int code, String msg) { public ApiException (int code, String msg) {

View File

@@ -5,7 +5,7 @@ import java.io.IOException;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class ApiOriginFilter implements javax.servlet.Filter { public class ApiOriginFilter implements javax.servlet.Filter {
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, public void doFilter(ServletRequest request, ServletResponse response,

View File

@@ -3,7 +3,7 @@ package io.swagger.api;
import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement @javax.xml.bind.annotation.XmlRootElement
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;

View File

@@ -1,6 +1,6 @@
package io.swagger.api; package io.swagger.api;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class NotFoundException extends ApiException { public class NotFoundException extends ApiException {
private int code; private int code;
public NotFoundException (int code, String msg) { public NotFoundException (int code, String msg) {

View File

@@ -6,12 +6,9 @@ import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse; import io.swagger.model.ModelApiResponse;
import java.io.File; import java.io.File;
import java.util.concurrent.Callable;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization; import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope; import io.swagger.annotations.AuthorizationScope;
@@ -35,8 +32,8 @@ import static org.springframework.http.MediaType.*;
@Controller @Controller
@RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/pet", description = "the pet API") @Api(value = "/pet", description = "the pet API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public interface PetApi { public class PetApi {
@ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = {
@Authorization(value = "petstore_auth", scopes = { @Authorization(value = "petstore_auth", scopes = {
@@ -44,19 +41,19 @@ public interface PetApi {
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input") }) @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
@RequestMapping(value = "", @RequestMapping(value = "/pet",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" }, consumes = { "application/json", "application/xml" },
method = RequestMethod.POST) method = RequestMethod.POST)
default Callable<ResponseEntity<Void>> addPet( public ResponseEntity<Void> addPet(
@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body @ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@@ -66,13 +63,13 @@ public interface PetApi {
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid pet value") }) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) })
@RequestMapping(value = "/{petId}", @RequestMapping(value = "/pet/{petId}",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE) method = RequestMethod.DELETE)
default Callable<ResponseEntity<Void>> deletePet( public ResponseEntity<Void> deletePet(
@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId @ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId
, ,
@@ -82,7 +79,7 @@ public interface PetApi {
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@@ -92,20 +89,20 @@ public interface PetApi {
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation"), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@ApiResponse(code = 400, message = "Invalid status value") }) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) })
@RequestMapping(value = "/findByStatus", @RequestMapping(value = "/pet/findByStatus",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET) method = RequestMethod.GET)
default Callable<ResponseEntity<List<Pet>>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true) @RequestParam(value = "status", required = true) List<String> status public ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true) @RequestParam(value = "status", required = true) List<String> status
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<List<Pet>>(HttpStatus.OK); return new ResponseEntity<List<Pet>>(HttpStatus.OK);
} }
@@ -115,41 +112,41 @@ public interface PetApi {
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation"), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@ApiResponse(code = 400, message = "Invalid tag value") }) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) })
@RequestMapping(value = "/findByTags", @RequestMapping(value = "/pet/findByTags",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET) method = RequestMethod.GET)
default Callable<ResponseEntity<List<Pet>>> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags public ResponseEntity<List<Pet>> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<List<Pet>>(HttpStatus.OK); return new ResponseEntity<List<Pet>>(HttpStatus.OK);
} }
@ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
@Authorization(value = "api_key") @Authorization(value = "api_key")
}) })
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation"), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@ApiResponse(code = 400, message = "Invalid ID supplied"), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class),
@ApiResponse(code = 404, message = "Pet not found") }) @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Pet.class) })
@RequestMapping(value = "/{petId}", @RequestMapping(value = "/pet/{petId}",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET) method = RequestMethod.GET)
default Callable<ResponseEntity<Pet>> getPetById( public ResponseEntity<Pet> getPetById(
@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId @ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Pet>(HttpStatus.OK); return new ResponseEntity<Pet>(HttpStatus.OK);
} }
@@ -159,21 +156,21 @@ public interface PetApi {
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid ID supplied"), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
@ApiResponse(code = 404, message = "Pet not found"), @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Void.class),
@ApiResponse(code = 405, message = "Validation exception") }) @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = Void.class) })
@RequestMapping(value = "", @RequestMapping(value = "/pet",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" }, consumes = { "application/json", "application/xml" },
method = RequestMethod.PUT) method = RequestMethod.PUT)
default Callable<ResponseEntity<Void>> updatePet( public ResponseEntity<Void> updatePet(
@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body @ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@@ -183,13 +180,13 @@ public interface PetApi {
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 405, message = "Invalid input") }) @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
@RequestMapping(value = "/{petId}", @RequestMapping(value = "/pet/{petId}",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
consumes = { "application/x-www-form-urlencoded" }, consumes = { "application/x-www-form-urlencoded" },
method = RequestMethod.POST) method = RequestMethod.POST)
default Callable<ResponseEntity<Void>> updatePetWithForm( public ResponseEntity<Void> updatePetWithForm(
@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId @ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId
, ,
@@ -205,7 +202,7 @@ public interface PetApi {
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@@ -215,13 +212,13 @@ public interface PetApi {
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
@RequestMapping(value = "/{petId}/uploadImage", @RequestMapping(value = "/pet/{petId}/uploadImage",
produces = { "application/json" }, produces = { "application/json" },
consumes = { "multipart/form-data" }, consumes = { "multipart/form-data" },
method = RequestMethod.POST) method = RequestMethod.POST)
default Callable<ResponseEntity<ModelApiResponse>> uploadFile( public ResponseEntity<ModelApiResponse> uploadFile(
@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId @ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId
, ,
@@ -236,7 +233,7 @@ public interface PetApi {
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<ModelApiResponse>(HttpStatus.OK); return new ResponseEntity<ModelApiResponse>(HttpStatus.OK);
} }
} }

View File

@@ -0,0 +1,239 @@
package io.swagger.api;
import io.swagger.model.*;
import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import static org.springframework.http.MediaType.*;
@Controller
@RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/pet", description = "the pet API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class PetApi {
@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")
})
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
@RequestMapping(value = "/pet",
produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" },
method = RequestMethod.POST)
public ResponseEntity<Void> addPet(
@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@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")
})
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) })
@RequestMapping(value = "/pet/{petId}",
produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE)
public ResponseEntity<Void> deletePet(
@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId
,
@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@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")
})
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) })
@RequestMapping(value = "/pet/findByStatus",
produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true) @RequestParam(value = "status", required = true) List<String> status
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
}
@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")
})
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) })
@RequestMapping(value = "/pet/findByTags",
produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity<List<Pet>> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
}
@ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
@Authorization(value = "api_key")
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Pet.class) })
@RequestMapping(value = "/pet/{petId}",
produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity<Pet> getPetById(
@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Pet>(HttpStatus.OK);
}
@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")
})
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = Void.class) })
@RequestMapping(value = "/pet",
produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" },
method = RequestMethod.PUT)
public ResponseEntity<Void> updatePet(
@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@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")
})
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
@RequestMapping(value = "/pet/{petId}",
produces = { "application/xml", "application/json" },
consumes = { "application/x-www-form-urlencoded" },
method = RequestMethod.POST)
public ResponseEntity<Void> updatePetWithForm(
@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId
,
@ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name
,
@ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@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")
})
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
@RequestMapping(value = "/pet/{petId}/uploadImage",
produces = { "application/json" },
consumes = { "multipart/form-data" },
method = RequestMethod.POST)
public ResponseEntity<ModelApiResponse> uploadFile(
@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId
,
@ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata
,
@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<ModelApiResponse>(HttpStatus.OK);
}
}

View File

@@ -5,12 +5,9 @@ import io.swagger.model.*;
import java.util.Map; import java.util.Map;
import io.swagger.model.Order; import io.swagger.model.Order;
import java.util.concurrent.Callable;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization; import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope; import io.swagger.annotations.AuthorizationScope;
@@ -34,77 +31,77 @@ import static org.springframework.http.MediaType.*;
@Controller @Controller
@RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/store", description = "the store API") @Api(value = "/store", description = "the store API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public interface StoreApi { public class StoreApi {
@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) @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)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid ID supplied"), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
@ApiResponse(code = 404, message = "Order not found") }) @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Void.class) })
@RequestMapping(value = "/order/{orderId}", @RequestMapping(value = "/store/order/{orderId}",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE) method = RequestMethod.DELETE)
default Callable<ResponseEntity<Void>> deleteOrder( public ResponseEntity<Void> deleteOrder(
@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId @ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @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") @Authorization(value = "api_key")
}) })
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Integer.class) })
@RequestMapping(value = "/inventory", @RequestMapping(value = "/store/inventory",
produces = { "application/json" }, produces = { "application/json" },
method = RequestMethod.GET) method = RequestMethod.GET)
default Callable<ResponseEntity<Map<String, Integer>>> getInventory() public ResponseEntity<Map<String, Integer>> getInventory()
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Map<String, Integer>>(HttpStatus.OK); return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
} }
@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) @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)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation"), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class),
@ApiResponse(code = 400, message = "Invalid ID supplied"), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class),
@ApiResponse(code = 404, message = "Order not found") }) @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Order.class) })
@RequestMapping(value = "/order/{orderId}", @RequestMapping(value = "/store/order/{orderId}",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET) method = RequestMethod.GET)
default Callable<ResponseEntity<Order>> getOrderById( public ResponseEntity<Order> getOrderById(
@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId @ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Order>(HttpStatus.OK); return new ResponseEntity<Order>(HttpStatus.OK);
} }
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation"), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class),
@ApiResponse(code = 400, message = "Invalid Order") }) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order", response = Order.class) })
@RequestMapping(value = "/order", @RequestMapping(value = "/store/order",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.POST) method = RequestMethod.POST)
default Callable<ResponseEntity<Order>> placeOrder( public ResponseEntity<Order> placeOrder(
@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body @ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Order>(HttpStatus.OK); return new ResponseEntity<Order>(HttpStatus.OK);
} }
} }

View File

@@ -0,0 +1,107 @@
package io.swagger.api;
import io.swagger.model.*;
import java.util.Map;
import io.swagger.model.Order;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import static org.springframework.http.MediaType.*;
@Controller
@RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/store", description = "the store API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class StoreApi {
@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)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Void.class) })
@RequestMapping(value = "/store/order/{orderId}",
produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE)
public ResponseEntity<Void> deleteOrder(
@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@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")
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Integer.class) })
@RequestMapping(value = "/store/inventory",
produces = { "application/json" },
method = RequestMethod.GET)
public ResponseEntity<Map<String, Integer>> getInventory()
throws NotFoundException {
// do some magic!
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
}
@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)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Order.class) })
@RequestMapping(value = "/store/order/{orderId}",
produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity<Order> getOrderById(
@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Order>(HttpStatus.OK);
}
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order", response = Order.class) })
@RequestMapping(value = "/store/order",
produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
public ResponseEntity<Order> placeOrder(
@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Order>(HttpStatus.OK);
}
}

View File

@@ -5,12 +5,9 @@ import io.swagger.model.*;
import io.swagger.model.User; import io.swagger.model.User;
import java.util.List; import java.util.List;
import java.util.concurrent.Callable;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization; import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope; import io.swagger.annotations.AuthorizationScope;
@@ -34,106 +31,106 @@ import static org.springframework.http.MediaType.*;
@Controller @Controller
@RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE}) @RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/user", description = "the user API") @Api(value = "/user", description = "the user API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public interface UserApi { public class UserApi {
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "", @RequestMapping(value = "/user",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.POST) method = RequestMethod.POST)
default Callable<ResponseEntity<Void>> createUser( public ResponseEntity<Void> createUser(
@ApiParam(value = "Created user object" ,required=true ) @RequestBody User body @ApiParam(value = "Created user object" ,required=true ) @RequestBody User body
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/createWithArray", @RequestMapping(value = "/user/createWithArray",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.POST) method = RequestMethod.POST)
default Callable<ResponseEntity<Void>> createUsersWithArrayInput( public ResponseEntity<Void> createUsersWithArrayInput(
@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body @ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/createWithList", @RequestMapping(value = "/user/createWithList",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.POST) method = RequestMethod.POST)
default Callable<ResponseEntity<Void>> createUsersWithListInput( public ResponseEntity<Void> createUsersWithListInput(
@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body @ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid username supplied"), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class),
@ApiResponse(code = 404, message = "User not found") }) @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class) })
@RequestMapping(value = "/{username}", @RequestMapping(value = "/user/{username}",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE) method = RequestMethod.DELETE)
default Callable<ResponseEntity<Void>> deleteUser( public ResponseEntity<Void> deleteUser(
@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username @ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@ApiOperation(value = "Get user by user name", notes = "", response = User.class) @ApiOperation(value = "Get user by user name", notes = "", response = User.class)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation"), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = User.class),
@ApiResponse(code = 400, message = "Invalid username supplied"), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = User.class),
@ApiResponse(code = 404, message = "User not found") }) @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = User.class) })
@RequestMapping(value = "/{username}", @RequestMapping(value = "/user/{username}",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET) method = RequestMethod.GET)
default Callable<ResponseEntity<User>> getUserByName( public ResponseEntity<User> getUserByName(
@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username @ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<User>(HttpStatus.OK); return new ResponseEntity<User>(HttpStatus.OK);
} }
@ApiOperation(value = "Logs user into the system", notes = "", response = String.class) @ApiOperation(value = "Logs user into the system", notes = "", response = String.class)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation"), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = String.class),
@ApiResponse(code = 400, message = "Invalid username/password supplied") }) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) })
@RequestMapping(value = "/login", @RequestMapping(value = "/user/login",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET) method = RequestMethod.GET)
default Callable<ResponseEntity<String>> loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username public ResponseEntity<String> loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username
, ,
@@ -143,33 +140,33 @@ public interface UserApi {
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<String>(HttpStatus.OK); return new ResponseEntity<String>(HttpStatus.OK);
} }
@ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation") }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/logout", @RequestMapping(value = "/user/logout",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET) method = RequestMethod.GET)
default Callable<ResponseEntity<Void>> logoutUser() public ResponseEntity<Void> logoutUser()
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
@ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class) @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
@ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@ApiResponse(code = 400, message = "Invalid user supplied"), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class),
@ApiResponse(code = 404, message = "User not found") }) @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class) })
@RequestMapping(value = "/{username}", @RequestMapping(value = "/user/{username}",
produces = { "application/xml", "application/json" }, produces = { "application/xml", "application/json" },
method = RequestMethod.PUT) method = RequestMethod.PUT)
default Callable<ResponseEntity<Void>> updateUser( public ResponseEntity<Void> updateUser(
@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username @ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username
, ,
@@ -179,7 +176,7 @@ public interface UserApi {
) )
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return () -> new ResponseEntity<Void>(HttpStatus.OK); return new ResponseEntity<Void>(HttpStatus.OK);
} }
} }

View File

@@ -0,0 +1,182 @@
package io.swagger.api;
import io.swagger.model.*;
import io.swagger.model.User;
import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
import static org.springframework.http.MediaType.*;
@Controller
@RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/user", description = "the user API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class UserApi {
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/user",
produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
public ResponseEntity<Void> createUser(
@ApiParam(value = "Created user object" ,required=true ) @RequestBody User body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/user/createWithArray",
produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
public ResponseEntity<Void> createUsersWithArrayInput(
@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/user/createWithList",
produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
public ResponseEntity<Void> createUsersWithListInput(
@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class) })
@RequestMapping(value = "/user/{username}",
produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE)
public ResponseEntity<Void> deleteUser(
@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Get user by user name", notes = "", response = User.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = User.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = User.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = User.class) })
@RequestMapping(value = "/user/{username}",
produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity<User> getUserByName(
@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<User>(HttpStatus.OK);
}
@ApiOperation(value = "Logs user into the system", notes = "", response = String.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = String.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) })
@RequestMapping(value = "/user/login",
produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity<String> loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username
,
@ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<String>(HttpStatus.OK);
}
@ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/user/logout",
produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
public ResponseEntity<Void> logoutUser()
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class) })
@RequestMapping(value = "/user/{username}",
produces = { "application/xml", "application/json" },
method = RequestMethod.PUT)
public ResponseEntity<Void> updateUser(
@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username
,
@ApiParam(value = "Updated user object" ,required=true ) @RequestBody User body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
}

View File

@@ -0,0 +1,40 @@
package io.swagger.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
@Configuration
public class SwaggerDocumentationConfig {
ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Swagger Petstore")
.description("This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.")
.license("Apache 2.0")
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
.termsOfServiceUrl("")
.version("1.0.0")
.contact(new Contact("","", "apiteam@swagger.io"))
.build();
}
@Bean
public Docket customImplementation(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("io.swagger.api"))
.build()
.directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
.apiInfo(apiInfo());
}
}

View File

@@ -10,7 +10,7 @@ import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class Category { public class Category {
private Long id = null; private Long id = null;

View File

@@ -10,7 +10,7 @@ import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class ModelApiResponse { public class ModelApiResponse {
private Integer code = null; private Integer code = null;

View File

@@ -2,7 +2,7 @@ package io.swagger.model;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.Date; import java.time.OffsetDateTime;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@@ -11,13 +11,13 @@ import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class Order { public class Order {
private Long id = null; private Long id = null;
private Long petId = null; private Long petId = null;
private Integer quantity = null; private Integer quantity = null;
private Date shipDate = null; private OffsetDateTime shipDate = null;
public enum StatusEnum { public enum StatusEnum {
placed, approved, delivered, placed, approved, delivered,
}; };
@@ -62,10 +62,10 @@ public class Order {
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@JsonProperty("shipDate") @JsonProperty("shipDate")
public Date getShipDate() { public OffsetDateTime getShipDate() {
return shipDate; return shipDate;
} }
public void setShipDate(Date shipDate) { public void setShipDate(OffsetDateTime shipDate) {
this.shipDate = shipDate; this.shipDate = shipDate;
} }

View File

@@ -14,7 +14,7 @@ import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class Pet { public class Pet {
private Long id = null; private Long id = null;

View File

@@ -10,7 +10,7 @@ import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class Tag { public class Tag {
private Long id = null; private Long id = null;

View File

@@ -10,7 +10,7 @@ import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-11T18:25:35.092+08:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringBootServerCodegen", date = "2016-06-14T14:20:46.451+02:00")
public class User { public class User {
private Long id = null; private Long id = null;

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"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-spring-mvc-server</artifactId> <artifactId>swagger-spring-server</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>swagger-spring-mvc-server</name> <name>swagger-spring-server</name>
<version>1.0.0</version> <version>1.0.0</version>
<build> <build>
<sourceDirectory>src/main/java</sourceDirectory> <sourceDirectory>src/main/java</sourceDirectory>

View File

@@ -1,6 +1,6 @@
package io.swagger.api; package io.swagger.api;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class ApiException extends Exception{ public class ApiException extends Exception{
private int code; private int code;
public ApiException (int code, String msg) { public ApiException (int code, String msg) {

View File

@@ -5,7 +5,7 @@ import java.io.IOException;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class ApiOriginFilter implements javax.servlet.Filter { public class ApiOriginFilter implements javax.servlet.Filter {
@Override @Override
public void doFilter(ServletRequest request, ServletResponse response, public void doFilter(ServletRequest request, ServletResponse response,

View File

@@ -2,8 +2,8 @@ package io.swagger.api;
import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement @javax.xml.bind.annotation.XmlRootElement
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;

View File

@@ -1,6 +1,6 @@
package io.swagger.api; package io.swagger.api;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class NotFoundException extends ApiException { public class NotFoundException extends ApiException {
private int code; private int code;
public NotFoundException (int code, String msg) { public NotFoundException (int code, String msg) {

View File

@@ -1,20 +1,11 @@
package io.swagger.api; package io.swagger.api;
import io.swagger.model.*;
import io.swagger.model.Pet; import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File; import java.io.File;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
@@ -26,217 +17,131 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
import static org.springframework.http.MediaType.*;
@Controller @Api(value = "pet", description = "the pet API")
@RequestMapping(value = "/pet", produces = {APPLICATION_JSON_VALUE}) public interface PetApi {
@Api(value = "/pet", description = "the pet API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class PetApi {
@ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = { @ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class, authorizations = {
@Authorization(value = "petstore_auth", scopes = { @Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) }) @ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
@RequestMapping(value = "", @RequestMapping(value = "/pet",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" }, consumes = { "application/json", "application/xml" },
method = RequestMethod.POST) method = RequestMethod.POST)
public ResponseEntity<Void> addPet( ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body);
@ApiParam(value = "Pet object that needs to be added to the store" ) @RequestBody Pet body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = { @ApiOperation(value = "Deletes a pet", notes = "", response = Void.class, authorizations = {
@Authorization(value = "petstore_auth", scopes = { @Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) }) @ApiResponse(code = 400, message = "Invalid pet value", response = Void.class) })
@RequestMapping(value = "/{petId}", @RequestMapping(value = "/pet/{petId}",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE)
method = RequestMethod.DELETE) ResponseEntity<Void> deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,
public ResponseEntity<Void> deletePet( @ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey);
@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId
,
@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List", authorizations = { @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 = { @Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class), @ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) }) @ApiResponse(code = 400, message = "Invalid status value", response = Pet.class) })
@RequestMapping(value = "/findByStatus", @RequestMapping(value = "/pet/findByStatus",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
method = RequestMethod.GET) ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true) @RequestParam(value = "status", required = true) List<String> status);
public ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue = "available") @RequestParam(value = "status", required = false, defaultValue="available") List<String> status
) @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 = {
throws NotFoundException { @Authorization(value = "petstore_auth", scopes = {
// do some magic! @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
return new ResponseEntity<List<Pet>>(HttpStatus.OK); @AuthorizationScope(scope = "read:pets", description = "read your pets")
} })
})
@ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Pet.class),
@ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) })
@RequestMapping(value = "/pet/findByTags",
produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
ResponseEntity<List<Pet>> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags);
@ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
@Authorization(value = "petstore_auth", scopes = { @Authorization(value = "api_key")
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), })
@AuthorizationScope(scope = "read:pets", description = "read your pets") @ApiResponses(value = {
}) @ApiResponse(code = 200, message = "successful operation", response = Pet.class),
}) @ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class),
@io.swagger.annotations.ApiResponses(value = { @ApiResponse(code = 404, message = "Pet not found", response = Pet.class) })
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class), @RequestMapping(value = "/pet/{petId}",
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class) }) produces = { "application/xml", "application/json" },
@RequestMapping(value = "/findByTags", method = RequestMethod.GET)
produces = { "application/json", "application/xml" }, ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId);
method = RequestMethod.GET)
public ResponseEntity<List<Pet>> findPetsByTags(@ApiParam(value = "Tags to filter by") @RequestParam(value = "tags", required = false) List<String> tags
) @ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = {
throws NotFoundException { @Authorization(value = "petstore_auth", scopes = {
// do some magic! @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
return new ResponseEntity<List<Pet>>(HttpStatus.OK); @AuthorizationScope(scope = "read:pets", description = "read your pets")
} })
})
@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) })
@RequestMapping(value = "/pet",
produces = { "application/xml", "application/json" },
consumes = { "application/json", "application/xml" },
method = RequestMethod.PUT)
ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body);
@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 = { @ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class, authorizations = {
@Authorization(value = "petstore_auth", scopes = { @Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}), })
@Authorization(value = "api_key") })
}) @ApiResponses(value = {
@io.swagger.annotations.ApiResponses(value = { @ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class), @RequestMapping(value = "/pet/{petId}",
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), produces = { "application/xml", "application/json" },
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) consumes = { "application/x-www-form-urlencoded" },
@RequestMapping(value = "/{petId}", method = RequestMethod.POST)
produces = { "application/json", "application/xml" }, ResponseEntity<Void> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,
@ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name,
method = RequestMethod.GET) @ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status);
public ResponseEntity<Pet> getPetById(
@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("petId") Long petId
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Pet>(HttpStatus.OK);
}
@ApiOperation(value = "Update an existing pet", notes = "", response = Void.class, authorizations = { @ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = {
@Authorization(value = "petstore_auth", scopes = { @Authorization(value = "petstore_auth", scopes = {
@AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@AuthorizationScope(scope = "read:pets", description = "read your pets") @AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}) })
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), @ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Void.class), @RequestMapping(value = "/pet/{petId}/uploadImage",
@io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = Void.class) }) produces = { "application/json" },
@RequestMapping(value = "", consumes = { "multipart/form-data" },
produces = { "application/json", "application/xml" }, method = RequestMethod.POST)
consumes = { "application/json", "application/xml" }, ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,
method = RequestMethod.PUT) @ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,
public ResponseEntity<Void> updatePet( @ApiParam(value = "file detail") @RequestPart("file") MultipartFile file);
@ApiParam(value = "Pet object that needs to be added to the store" ) @RequestBody Pet body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@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")
})
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = Void.class) })
@RequestMapping(value = "/{petId}",
produces = { "application/json", "application/xml" },
consumes = { "application/x-www-form-urlencoded" },
method = RequestMethod.POST)
public ResponseEntity<Void> updatePetWithForm(
@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") String petId
,
@ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name
,
@ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "uploads an image", 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")
})
})
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/{petId}/uploadImage",
produces = { "application/json", "application/xml" },
consumes = { "multipart/form-data" },
method = RequestMethod.POST)
public ResponseEntity<Void> uploadFile(
@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId
,
@ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata
,
@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
} }

View File

@@ -0,0 +1,71 @@
package io.swagger.api;
import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Controller
public class PetApiController implements PetApi {
public ResponseEntity<Void> addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
public ResponseEntity<Void> deletePet(@ApiParam(value = "Pet id to delete",required=true ) @PathVariable("petId") Long petId,
@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) String apiKey) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
public ResponseEntity<List<Pet>> findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", required = true) @RequestParam(value = "status", required = true) List<String> status) {
// do some magic!
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
}
public ResponseEntity<List<Pet>> findPetsByTags(@ApiParam(value = "Tags to filter by", required = true) @RequestParam(value = "tags", required = true) List<String> tags) {
// do some magic!
return new ResponseEntity<List<Pet>>(HttpStatus.OK);
}
public ResponseEntity<Pet> getPetById(@ApiParam(value = "ID of pet to return",required=true ) @PathVariable("petId") Long petId) {
// do some magic!
return new ResponseEntity<Pet>(HttpStatus.OK);
}
public ResponseEntity<Void> updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @RequestBody Pet body) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
public ResponseEntity<Void> updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathVariable("petId") Long petId,
@ApiParam(value = "Updated name of the pet" ) @RequestPart(value="name", required=false) String name,
@ApiParam(value = "Updated status of the pet" ) @RequestPart(value="status", required=false) String status) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
public ResponseEntity<ModelApiResponse> uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathVariable("petId") Long petId,
@ApiParam(value = "Additional data to pass to server" ) @RequestPart(value="additionalMetadata", required=false) String additionalMetadata,
@ApiParam(value = "file detail") @RequestPart("file") MultipartFile file) {
// do some magic!
return new ResponseEntity<ModelApiResponse>(HttpStatus.OK);
}
}

View File

@@ -1,20 +1,10 @@
package io.swagger.api; package io.swagger.api;
import io.swagger.model.*;
import java.util.Map; import java.util.Map;
import io.swagger.model.Order; import io.swagger.model.Order;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
@@ -26,82 +16,49 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
import static org.springframework.http.MediaType.*;
@Controller @Api(value = "store", description = "the store API")
@RequestMapping(value = "/store", produces = {APPLICATION_JSON_VALUE}) public interface StoreApi {
@Api(value = "/store", description = "the store API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class StoreApi {
@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) @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)
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class), @ApiResponse(code = 400, message = "Invalid ID supplied", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Void.class) }) @ApiResponse(code = 404, message = "Order not found", response = Void.class) })
@RequestMapping(value = "/order/{orderId}", @RequestMapping(value = "/store/order/{orderId}",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE)
method = RequestMethod.DELETE) ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId);
public ResponseEntity<Void> deleteOrder(
@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @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") @Authorization(value = "api_key")
}) })
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Integer.class) }) @ApiResponse(code = 200, message = "successful operation", response = Integer.class) })
@RequestMapping(value = "/inventory", @RequestMapping(value = "/store/inventory",
produces = { "application/json", "application/xml" }, produces = { "application/json" },
method = RequestMethod.GET)
method = RequestMethod.GET) ResponseEntity<Map<String, Integer>> getInventory();
public ResponseEntity<Map<String, Integer>> getInventory()
throws NotFoundException {
// do some magic!
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
}
@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) @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)
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 200, message = "successful operation", response = Order.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), @ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Order.class) }) @ApiResponse(code = 404, message = "Order not found", response = Order.class) })
@RequestMapping(value = "/order/{orderId}", @RequestMapping(value = "/store/order/{orderId}",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
method = RequestMethod.GET) ResponseEntity<Order> getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId);
public ResponseEntity<Order> getOrderById(
@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") String orderId
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Order>(HttpStatus.OK);
}
@ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class) @ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class), @ApiResponse(code = 200, message = "successful operation", response = Order.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) @ApiResponse(code = 400, message = "Invalid Order", response = Order.class) })
@RequestMapping(value = "/order", @RequestMapping(value = "/store/order",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
method = RequestMethod.POST) ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body);
public ResponseEntity<Order> placeOrder(
@ApiParam(value = "order placed for purchasing the pet" ) @RequestBody Order body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Order>(HttpStatus.OK);
}
} }

View File

@@ -0,0 +1,45 @@
package io.swagger.api;
import java.util.Map;
import io.swagger.model.Order;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Controller
public class StoreApiController implements StoreApi {
public ResponseEntity<Void> deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathVariable("orderId") String orderId) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
public ResponseEntity<Map<String, Integer>> getInventory() {
// do some magic!
return new ResponseEntity<Map<String, Integer>>(HttpStatus.OK);
}
public ResponseEntity<Order> getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathVariable("orderId") Long orderId) {
// do some magic!
return new ResponseEntity<Order>(HttpStatus.OK);
}
public ResponseEntity<Order> placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @RequestBody Order body) {
// do some magic!
return new ResponseEntity<Order>(HttpStatus.OK);
}
}

View File

@@ -1,20 +1,10 @@
package io.swagger.api; package io.swagger.api;
import io.swagger.model.*;
import io.swagger.model.User; import io.swagger.model.User;
import java.util.List; import java.util.List;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestHeader;
@@ -26,157 +16,86 @@ import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
import static org.springframework.http.MediaType.*;
@Controller @Api(value = "user", description = "the user API")
@RequestMapping(value = "/user", produces = {APPLICATION_JSON_VALUE}) public interface UserApi {
@Api(value = "/user", description = "the user API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class UserApi {
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class) @ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = Void.class)
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) @ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "", @RequestMapping(value = "/user",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
method = RequestMethod.POST) ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @RequestBody User body);
public ResponseEntity<Void> createUser(
@ApiParam(value = "Created user object" ) @RequestBody User body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) @ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/createWithArray", @RequestMapping(value = "/user/createWithArray",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
method = RequestMethod.POST) ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body);
public ResponseEntity<Void> createUsersWithArrayInput(
@ApiParam(value = "List of user object" ) @RequestBody List<User> body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class) @ApiOperation(value = "Creates list of users with given input array", notes = "", response = Void.class)
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) }) @ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/createWithList", @RequestMapping(value = "/user/createWithList",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.POST)
method = RequestMethod.POST) ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body);
public ResponseEntity<Void> createUsersWithListInput(
@ApiParam(value = "List of user object" ) @RequestBody List<User> body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class) @ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = Void.class)
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class), @ApiResponse(code = 400, message = "Invalid username supplied", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class) }) @ApiResponse(code = 404, message = "User not found", response = Void.class) })
@RequestMapping(value = "/{username}", @RequestMapping(value = "/user/{username}",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.DELETE)
method = RequestMethod.DELETE) ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username);
public ResponseEntity<Void> deleteUser(
@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Get user by user name", notes = "", response = User.class) @ApiOperation(value = "Get user by user name", notes = "", response = User.class)
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = User.class), @ApiResponse(code = 200, message = "successful operation", response = User.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), @ApiResponse(code = 400, message = "Invalid username supplied", response = User.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = User.class) }) @ApiResponse(code = 404, message = "User not found", response = User.class) })
@RequestMapping(value = "/{username}", @RequestMapping(value = "/user/{username}",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
method = RequestMethod.GET) ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username);
public ResponseEntity<User> getUserByName(
@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<User>(HttpStatus.OK);
}
@ApiOperation(value = "Logs user into the system", notes = "", response = String.class) @ApiOperation(value = "Logs user into the system", notes = "", response = String.class)
@io.swagger.annotations.ApiResponses(value = { @ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = String.class), @ApiResponse(code = 200, message = "successful operation", response = String.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) @ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) })
@RequestMapping(value = "/login", @RequestMapping(value = "/user/login",
produces = { "application/json", "application/xml" }, produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
method = RequestMethod.GET) ResponseEntity<String> loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
public ResponseEntity<String> loginUser(@ApiParam(value = "The user name for login") @RequestParam(value = "username", required = false) String username @ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password);
, @ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class)
@ApiParam(value = "The password for login in clear text") @RequestParam(value = "password", required = false) String password @ApiResponses(value = {
@ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/user/logout",
produces = { "application/xml", "application/json" },
method = RequestMethod.GET)
ResponseEntity<Void> logoutUser();
) @ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
throws NotFoundException { @ApiResponses(value = {
// do some magic! @ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class),
return new ResponseEntity<String>(HttpStatus.OK); @ApiResponse(code = 404, message = "User not found", response = Void.class) })
} @RequestMapping(value = "/user/{username}",
produces = { "application/xml", "application/json" },
method = RequestMethod.PUT)
@ApiOperation(value = "Logs out current logged in user session", notes = "", response = Void.class) ResponseEntity<Void> updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,
@io.swagger.annotations.ApiResponses(value = { @ApiParam(value = "Updated user object" ,required=true ) @RequestBody User body);
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Void.class) })
@RequestMapping(value = "/logout",
produces = { "application/json", "application/xml" },
method = RequestMethod.GET)
public ResponseEntity<Void> logoutUser()
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
@ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = Void.class)
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied", response = Void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = Void.class) })
@RequestMapping(value = "/{username}",
produces = { "application/json", "application/xml" },
method = RequestMethod.PUT)
public ResponseEntity<Void> updateUser(
@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username
,
@ApiParam(value = "Updated user object" ) @RequestBody User body
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
} }

View File

@@ -0,0 +1,67 @@
package io.swagger.api;
import io.swagger.model.User;
import java.util.List;
import io.swagger.annotations.*;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
@Controller
public class UserApiController implements UserApi {
public ResponseEntity<Void> createUser(@ApiParam(value = "Created user object" ,required=true ) @RequestBody User body) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
public ResponseEntity<Void> createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
public ResponseEntity<Void> createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @RequestBody List<User> body) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
public ResponseEntity<Void> deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true ) @PathVariable("username") String username) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
public ResponseEntity<User> getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true ) @PathVariable("username") String username) {
// do some magic!
return new ResponseEntity<User>(HttpStatus.OK);
}
public ResponseEntity<String> loginUser(@ApiParam(value = "The user name for login", required = true) @RequestParam(value = "username", required = true) String username,
@ApiParam(value = "The password for login in clear text", required = true) @RequestParam(value = "password", required = true) String password) {
// do some magic!
return new ResponseEntity<String>(HttpStatus.OK);
}
public ResponseEntity<Void> logoutUser() {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
public ResponseEntity<Void> updateUser(@ApiParam(value = "name that need to be deleted",required=true ) @PathVariable("username") String username,
@ApiParam(value = "Updated user object" ,required=true ) @RequestBody User body) {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
}

View File

@@ -1,43 +0,0 @@
package io.swagger.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@ComponentScan(basePackages = "io.swagger.api")
@EnableWebMvc
@EnableSwagger2 //Loads the spring beans required by the framework
@PropertySource("classpath:swagger.properties")
@Import(SwaggerUiConfiguration.class)
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class SwaggerConfig {
@Bean
ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Swagger Petstore")
.description("This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters")
.license("Apache 2.0")
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
.termsOfServiceUrl("")
.version("1.0.0")
.contact(new Contact("","", "apiteam@wordnik.com"))
.build();
}
@Bean
public Docket customImplementation(){
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo());
}
}

View File

@@ -0,0 +1,40 @@
package io.swagger.configuration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
@Configuration
public class SwaggerDocumentationConfig {
ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Swagger Petstore")
.description("This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.")
.license("Apache 2.0")
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
.termsOfServiceUrl("")
.version("1.0.0")
.contact(new Contact("","", "apiteam@swagger.io"))
.build();
}
@Bean
public Docket customImplementation(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("io.swagger.api"))
.build()
.directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class)
.apiInfo(apiInfo());
}
}

View File

@@ -1,14 +1,21 @@
package io.swagger.configuration; package io.swagger.configuration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableWebMvc
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00") @javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
@Configuration
@ComponentScan(basePackages = "io.swagger.api")
@EnableWebMvc
@EnableSwagger2 //Loads the spring beans required by the framework
@PropertySource("classpath:swagger.properties")
@Import(SwaggerDocumentationConfig.class)
public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter { public class SwaggerUiConfiguration extends WebMvcConfigurerAdapter {
private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" }; private static final String[] SERVLET_RESOURCE_LOCATIONS = { "/" };

View File

@@ -7,7 +7,7 @@ public class WebApplication extends AbstractAnnotationConfigDispatcherServletIni
@Override @Override
protected Class<?>[] getRootConfigClasses() { protected Class<?>[] getRootConfigClasses() {
return new Class[] { SwaggerConfig.class }; return new Class[] { SwaggerUiConfiguration.class };
} }
@Override @Override

View File

@@ -1,6 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -10,8 +9,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class Category { public class Category {
private Long id = null; private Long id = null;

View File

@@ -1,6 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -10,8 +9,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-04-22T17:54:58.453+08:00")
public class ModelApiResponse { public class ModelApiResponse {
private Integer code = null; private Integer code = null;

View File

@@ -1,10 +1,8 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.Date; import org.joda.time.DateTime;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@@ -12,20 +10,20 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class Order { public class Order {
private Long id = null; private Long id = null;
private Long petId = null; private Long petId = null;
private Integer quantity = null; private Integer quantity = null;
private Date shipDate = null; private DateTime shipDate = null;
public enum StatusEnum { public enum StatusEnum {
placed, approved, delivered, placed, approved, delivered,
}; };
private StatusEnum status = null; private StatusEnum status = null;
private Boolean complete = null; private Boolean complete = false;
/** /**
**/ **/
@@ -64,10 +62,10 @@ public class Order {
**/ **/
@ApiModelProperty(value = "") @ApiModelProperty(value = "")
@JsonProperty("shipDate") @JsonProperty("shipDate")
public Date getShipDate() { public DateTime getShipDate() {
return shipDate; return shipDate;
} }
public void setShipDate(Date shipDate) { public void setShipDate(DateTime shipDate) {
this.shipDate = shipDate; this.shipDate = shipDate;
} }

View File

@@ -1,7 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.model.Category; import io.swagger.model.Category;
@@ -15,8 +13,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class Pet { public class Pet {
private Long id = null; private Long id = null;

View File

@@ -1,6 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -10,8 +9,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class Tag { public class Tag {
private Long id = null; private Long id = null;

View File

@@ -1,6 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -10,8 +9,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "") @ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-05-03T13:43:02.966+02:00")
public class User { public class User {
private Long id = null; private Long id = null;

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"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-springboot-server</artifactId> <artifactId>swagger-spring-server</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>swagger-springboot-server</name> <name>swagger-spring-server</name>
<version>1.0.0</version> <version>1.0.0</version>
<properties> <properties>
<springfox-version>2.4.0</springfox-version> <springfox-version>2.4.0</springfox-version>

View File

@@ -2,8 +2,8 @@ package io.swagger.api;
import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.XmlTransient;
@javax.xml.bind.annotation.XmlRootElement
@javax.xml.bind.annotation.XmlRootElement
public class ApiResponseMessage { public class ApiResponseMessage {
public static final int ERROR = 1; public static final int ERROR = 1;
public static final int WARNING = 2; public static final int WARNING = 2;

View File

@@ -11,9 +11,7 @@ import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
@Configuration @Configuration
public class SwaggerDocumentationConfig { public class SwaggerDocumentationConfig {
ApiInfo apiInfo() { ApiInfo apiInfo() {

View File

@@ -1,6 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -10,8 +9,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "")
@ApiModel(description = "")
public class Category { public class Category {
private Long id = null; private Long id = null;

View File

@@ -1,6 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -10,8 +9,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "")
@ApiModel(description = "")
public class ModelApiResponse { public class ModelApiResponse {
private Integer code = null; private Integer code = null;

View File

@@ -1,7 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.joda.time.DateTime; import org.joda.time.DateTime;
@@ -12,8 +10,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "")
@ApiModel(description = "")
public class Order { public class Order {
private Long id = null; private Long id = null;

View File

@@ -1,7 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.model.Category; import io.swagger.model.Category;
@@ -15,8 +13,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "")
@ApiModel(description = "")
public class Pet { public class Pet {
private Long id = null; private Long id = null;

View File

@@ -1,6 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -10,8 +9,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "")
@ApiModel(description = "")
public class Tag { public class Tag {
private Long id = null; private Long id = null;

View File

@@ -1,6 +1,5 @@
package io.swagger.model; package io.swagger.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
@@ -10,8 +9,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Objects; import java.util.Objects;
@ApiModel(description = "")
@ApiModel(description = "")
public class User { public class User {
private Long id = null; private Long id = null;