forked from loafle/openapi-generator-original
add lombok model support on spring (#17622)
* add lombok model support on spring * use regex to adapt annotation with parenthesis * add ut case * add samples * add samples * fix github workflow * fix github workflow
This commit is contained in:
parent
a092bbd83b
commit
66a6af5ca4
5
.github/workflows/samples-spring-jdk17.yaml
vendored
5
.github/workflows/samples-spring-jdk17.yaml
vendored
@ -7,6 +7,8 @@ on:
|
||||
pull_request:
|
||||
paths:
|
||||
- samples/openapi3/client/petstore/spring-cloud-3-with-optional
|
||||
- samples/server/petstore/springboot-lombok-data
|
||||
- samples/server/petstore/springboot-lombok-tostring
|
||||
jobs:
|
||||
build:
|
||||
name: Build Java Spring (JDK17)
|
||||
@ -17,6 +19,9 @@ jobs:
|
||||
sample:
|
||||
# clients
|
||||
- samples/openapi3/client/petstore/spring-cloud-3-with-optional
|
||||
# servers
|
||||
- samples/server/petstore/springboot-lombok-data
|
||||
- samples/server/petstore/springboot-lombok-tostring
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
|
1
.github/workflows/samples-spring.yaml
vendored
1
.github/workflows/samples-spring.yaml
vendored
@ -57,6 +57,7 @@ jobs:
|
||||
- samples/server/petstore/springboot-spring-pageable-without-j8
|
||||
- samples/server/petstore/springboot-spring-pageable
|
||||
- samples/server/petstore/springboot-spring-provide-args
|
||||
- samples/server/petstore/springboot-lombok-data
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-java@v4
|
||||
|
9
bin/configs/spring-boot-lombok-data.yaml
Normal file
9
bin/configs/spring-boot-lombok-data.yaml
Normal file
@ -0,0 +1,9 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-lombok-data
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
artifactId: springboot-lombok-data
|
||||
hideGenerationTimestamp: "true"
|
||||
additionalModelTypeAnnotations: "@lombok.Data;@lombok.Builder;@lombok.NoArgsConstructor;@lombok.AllArgsConstructor"
|
11
bin/configs/spring-boot-lombok-tostring.yaml
Normal file
11
bin/configs/spring-boot-lombok-tostring.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
generatorName: spring
|
||||
outputDir: samples/server/petstore/springboot-lombok-tostring
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
|
||||
additionalProperties:
|
||||
groupId: org.openapitools.openapi3
|
||||
artifactId: springboot-lombok-tostring
|
||||
hideGenerationTimestamp: "true"
|
||||
performBeanValidation: "true"
|
||||
useSpringBoot3: "true"
|
||||
additionalModelTypeAnnotations: "@lombok.Getter;@lombok.Setter;@lombok.ToString;@lombok.EqualsAndHashCode"
|
@ -53,6 +53,7 @@ import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentSkipListSet;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@ -89,7 +90,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
public static final String CAMEL_CASE_DOLLAR_SIGN = "camelCaseDollarSign";
|
||||
public static final String USE_ONE_OF_INTERFACES = "useOneOfInterfaces";
|
||||
|
||||
public static final String LOMBOK = "lombok";
|
||||
public static final String DEFAULT_TEST_FOLDER = "${project.build.directory}/generated-test-sources/openapi";
|
||||
|
||||
protected String dateLibrary = "java8";
|
||||
@ -128,6 +129,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
protected String parentVersion = "";
|
||||
protected boolean parentOverridden = false;
|
||||
protected List<String> additionalModelTypeAnnotations = new LinkedList<>();
|
||||
protected Map<String, Boolean> lombokAnnotations = null;
|
||||
protected List<String> additionalOneOfTypeAnnotations = new LinkedList<>();
|
||||
protected List<String> additionalEnumTypeAnnotations = new LinkedList<>();
|
||||
protected boolean openApiNullable = true;
|
||||
@ -1677,6 +1679,22 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
}
|
||||
}
|
||||
|
||||
// parse lombok additional model type annotations
|
||||
Map<String, Boolean> lombokOptions = new HashMap<>();
|
||||
String regexp = "@lombok.(\\w+\\.)*(?<ClassName>\\w+)(\\(.*?\\))?";
|
||||
Pattern pattern = Pattern.compile(regexp);
|
||||
for (String annotation : additionalModelTypeAnnotations) {
|
||||
Matcher matcher = pattern.matcher(annotation);
|
||||
if (matcher.find()) {
|
||||
String className = matcher.group("ClassName");
|
||||
lombokOptions.put(className, true);
|
||||
}
|
||||
}
|
||||
if (!lombokOptions.isEmpty()) {
|
||||
lombokAnnotations = lombokOptions;
|
||||
writePropertyBack(LOMBOK, lombokOptions);
|
||||
}
|
||||
|
||||
return postProcessModelsEnum(objs);
|
||||
}
|
||||
|
||||
|
@ -62,11 +62,19 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
{{#classifier}}
|
||||
<configuration>
|
||||
{{#classifier}}
|
||||
<classifier>{{{classifier}}}</classifier>
|
||||
{{/classifier}}
|
||||
{{#lombok}}
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
{{/lombok}}
|
||||
</configuration>
|
||||
{{/classifier}}
|
||||
</plugin>
|
||||
{{#apiFirst}}
|
||||
<plugin>
|
||||
@ -217,6 +225,13 @@
|
||||
<artifactId>spring-boot-starter-hateoas</artifactId>
|
||||
</dependency>
|
||||
{{/hateoas}}
|
||||
{{#lombok}}
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
{{/lombok}}
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
|
@ -55,11 +55,19 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
{{#classifier}}
|
||||
<configuration>
|
||||
{{#classifier}}
|
||||
<classifier>{{{classifier}}}</classifier>
|
||||
</configuration>
|
||||
{{/classifier}}
|
||||
{{#lombok}}
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
{{/lombok}}
|
||||
</configuration>
|
||||
</plugin>
|
||||
{{#apiFirst}}
|
||||
<plugin>
|
||||
@ -227,6 +235,13 @@
|
||||
<artifactId>spring-boot-starter-hateoas</artifactId>
|
||||
</dependency>
|
||||
{{/hateoas}}
|
||||
{{#lombok}}
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
{{/lombok}}
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
|
@ -130,6 +130,13 @@
|
||||
<artifactId>spring-boot-starter-hateoas</artifactId>
|
||||
</dependency>
|
||||
{{/hateoas}}
|
||||
{{#lombok}}
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
{{/lombok}}
|
||||
{{#useBeanValidation}}
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -146,6 +146,13 @@
|
||||
<artifactId>spring-boot-starter-hateoas</artifactId>
|
||||
</dependency>
|
||||
{{/hateoas}}
|
||||
{{#lombok}}
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
{{/lombok}}
|
||||
{{#useBeanValidation}}
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -89,6 +89,13 @@
|
||||
<version>0.2.6</version>
|
||||
</dependency>
|
||||
{{/openApiNullable}}
|
||||
{{#lombok}}
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
{{/lombok}}
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
@ -51,6 +51,14 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
|
||||
{{#gson}}
|
||||
@SerializedName("{{baseName}}")
|
||||
{{/gson}}
|
||||
{{#lombok}}
|
||||
{{#required}}
|
||||
@lombok.NonNull
|
||||
{{/required}}
|
||||
{{#isPassword}}
|
||||
@lombok.ToString.Exclude
|
||||
{{/isPassword}}
|
||||
{{/lombok}}
|
||||
{{#vendorExtensions.x-field-extra-annotation}}
|
||||
{{{vendorExtensions.x-field-extra-annotation}}}
|
||||
{{/vendorExtensions.x-field-extra-annotation}}
|
||||
@ -81,13 +89,17 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
|
||||
{{/openApiNullable}}
|
||||
{{/isContainer}}
|
||||
{{/vars}}
|
||||
{{^lombok.Data}}
|
||||
{{^lombok.RequiredArgsConstructor}}
|
||||
{{#generatedConstructorWithRequiredArgs}}
|
||||
{{#hasRequired}}
|
||||
|
||||
{{^lombok.NoArgsConstructor}}
|
||||
public {{classname}}() {
|
||||
super();
|
||||
}
|
||||
|
||||
{{/lombok.NoArgsConstructor}}
|
||||
/**
|
||||
* Constructor with only required parameters
|
||||
*/
|
||||
@ -108,7 +120,10 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
|
||||
}
|
||||
{{/hasRequired}}
|
||||
{{/generatedConstructorWithRequiredArgs}}
|
||||
{{/lombok.RequiredArgsConstructor}}
|
||||
{{/lombok.Data}}
|
||||
{{#vars}}
|
||||
{{^lombok.Data}}
|
||||
|
||||
{{! begin feature: fluent setter methods }}
|
||||
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
@ -158,6 +173,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
|
||||
{{/isMap}}
|
||||
{{! end feature: fluent setter methods }}
|
||||
{{! begin feature: getter and setter }}
|
||||
{{^lombok.Getter}}
|
||||
|
||||
/**
|
||||
{{#description}}
|
||||
@ -204,7 +220,9 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
|
||||
public {{>nullableDataTypeBeanValidation}} {{getter}}() {
|
||||
return {{name}};
|
||||
}
|
||||
{{/lombok.Getter}}
|
||||
|
||||
{{^lombok.Setter}}
|
||||
{{#deprecated}}
|
||||
/**
|
||||
* @deprecated
|
||||
@ -219,11 +237,15 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
|
||||
public void {{setter}}({{>nullableDataType}} {{name}}) {
|
||||
this.{{name}} = {{name}};
|
||||
}
|
||||
{{/lombok.Setter}}
|
||||
{{/lombok.Data}}
|
||||
{{! end feature: getter and setter }}
|
||||
{{/vars}}
|
||||
{{>additionalProperties}}
|
||||
{{^lombok.Data}}
|
||||
{{#parentVars}}
|
||||
|
||||
{{^lombok.Setter}}
|
||||
{{! begin feature: fluent setter methods for inherited properties }}
|
||||
public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) {
|
||||
super.{{name}}({{name}});
|
||||
@ -243,8 +265,10 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
|
||||
return this;
|
||||
}
|
||||
{{/isMap}}
|
||||
{{/lombok.Setter}}
|
||||
{{! end feature: fluent setter methods for inherited properties }}
|
||||
{{/parentVars}}
|
||||
{{^lombok.EqualsAndHashCode}}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
@ -276,7 +300,9 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
|
||||
}
|
||||
return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
|
||||
}{{/vendorExtensions.x-jackson-optional-nullable-helpers}}
|
||||
{{/lombok.EqualsAndHashCode}}
|
||||
|
||||
{{^lombok.ToString}}
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@ -301,4 +327,6 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{^parent}}
|
||||
}
|
||||
return o.toString().replace("\n", "\n ");
|
||||
}
|
||||
{{/lombok.ToString}}
|
||||
{{/lombok.Data}}
|
||||
}
|
||||
|
@ -4427,4 +4427,48 @@ public class SpringCodegenTest {
|
||||
.hasParameter("race").toConstructor()
|
||||
;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLombokAnnotations() throws IOException {
|
||||
final Map<String, Object> additionalProperties = new HashMap<>();
|
||||
additionalProperties.put(AbstractJavaCodegen.ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "@lombok.Data;@lombok.NoArgsConstructor;@lombok.AllArgsConstructor");
|
||||
Map<String, File> output = generateFromContract("src/test/resources/3_0/petstore.yaml", SPRING_BOOT, additionalProperties);
|
||||
JavaFileAssert.assertThat(output.get("Pet.java"))
|
||||
.assertNoConstructor()
|
||||
.assertNoMethod("toString")
|
||||
.assertNoMethod("hashCode")
|
||||
.assertNoMethod("equals")
|
||||
.assertNoMethod("getId")
|
||||
.assertNoMethod("setId")
|
||||
.assertNoMethod("getName")
|
||||
.assertNoMethod("setName")
|
||||
;
|
||||
additionalProperties.put(AbstractJavaCodegen.ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "@lombok.ToString");
|
||||
output = generateFromContract("src/test/resources/3_0/petstore.yaml", SPRING_BOOT, additionalProperties);
|
||||
JavaFileAssert.assertThat(output.get("Pet.java"))
|
||||
.assertConstructor().toFileAssert()
|
||||
.assertNoMethod("toString")
|
||||
.assertMethod("hashCode")
|
||||
.toFileAssert()
|
||||
.assertMethod("equals")
|
||||
.toFileAssert()
|
||||
.assertMethod("getId")
|
||||
.toFileAssert()
|
||||
.assertMethod("setId")
|
||||
.toFileAssert()
|
||||
.assertMethod("getName")
|
||||
.toFileAssert()
|
||||
.assertMethod("setName")
|
||||
;
|
||||
additionalProperties.put(AbstractJavaCodegen.ADDITIONAL_MODEL_TYPE_ANNOTATIONS, "@lombok.Getter;@lombok.Setter");
|
||||
output = generateFromContract("src/test/resources/3_0/petstore.yaml", SPRING_BOOT, additionalProperties);
|
||||
JavaFileAssert.assertThat(output.get("Pet.java"))
|
||||
.assertConstructor().toFileAssert()
|
||||
.assertMethod("toString")
|
||||
.toFileAssert()
|
||||
.assertMethod("hashCode")
|
||||
.toFileAssert()
|
||||
.assertMethod("equals")
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -24,6 +24,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -40,6 +40,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -24,6 +24,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -24,6 +24,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -23,6 +23,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# 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 OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1,19 @@
|
||||
README.md
|
||||
pom.xml
|
||||
src/main/java/org/openapitools/OpenApiGeneratorApplication.java
|
||||
src/main/java/org/openapitools/RFC3339DateFormat.java
|
||||
src/main/java/org/openapitools/api/ApiUtil.java
|
||||
src/main/java/org/openapitools/api/PetApi.java
|
||||
src/main/java/org/openapitools/api/StoreApi.java
|
||||
src/main/java/org/openapitools/api/UserApi.java
|
||||
src/main/java/org/openapitools/configuration/HomeController.java
|
||||
src/main/java/org/openapitools/configuration/SpringDocConfiguration.java
|
||||
src/main/java/org/openapitools/model/Category.java
|
||||
src/main/java/org/openapitools/model/ModelApiResponse.java
|
||||
src/main/java/org/openapitools/model/Order.java
|
||||
src/main/java/org/openapitools/model/Pet.java
|
||||
src/main/java/org/openapitools/model/Tag.java
|
||||
src/main/java/org/openapitools/model/User.java
|
||||
src/main/resources/application.properties
|
||||
src/main/resources/openapi.yaml
|
||||
src/test/java/org/openapitools/OpenApiGeneratorApplicationTests.java
|
@ -0,0 +1 @@
|
||||
7.3.0-SNAPSHOT
|
21
samples/server/petstore/springboot-lombok-data/README.md
Normal file
21
samples/server/petstore/springboot-lombok-data/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# OpenAPI generated server
|
||||
|
||||
Spring Boot Server
|
||||
|
||||
## Overview
|
||||
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
|
||||
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework.
|
||||
|
||||
|
||||
The underlying library integrating OpenAPI to Spring Boot is [springdoc](https://springdoc.org).
|
||||
Springdoc will generate an OpenAPI v3 specification based on the generated Controller and Model classes.
|
||||
The specification is available to download using the following url:
|
||||
http://localhost:8080/v3/api-docs/
|
||||
|
||||
Start your server as a simple java application
|
||||
|
||||
You can view the api documentation in swagger-ui by pointing to
|
||||
http://localhost:8080/swagger-ui.html
|
||||
|
||||
Change default port value in application.properties
|
93
samples/server/petstore/springboot-lombok-data/pom.xml
Normal file
93
samples/server/petstore/springboot-lombok-data/pom.xml
Normal file
@ -0,0 +1,93 @@
|
||||
<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>org.openapitools.openapi3</groupId>
|
||||
<artifactId>springboot-lombok-data</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>springboot-lombok-data</name>
|
||||
<version>1.0.0</version>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<springdoc.version>1.6.14</springdoc.version>
|
||||
<swagger-ui.version>5.3.1</swagger-ui.version>
|
||||
</properties>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.15</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-commons</artifactId>
|
||||
</dependency>
|
||||
<!--SpringDoc dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-ui</artifactId>
|
||||
<version>${springdoc.version}</version>
|
||||
</dependency>
|
||||
<!-- @Nullable annotation -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>0.2.6</version>
|
||||
</dependency>
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,30 @@
|
||||
package org.openapitools;
|
||||
|
||||
import com.fasterxml.jackson.databind.Module;
|
||||
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
|
||||
|
||||
@SpringBootApplication(
|
||||
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
|
||||
)
|
||||
@ComponentScan(
|
||||
basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"},
|
||||
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
|
||||
)
|
||||
public class OpenApiGeneratorApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OpenApiGeneratorApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean(name = "org.openapitools.OpenApiGeneratorApplication.jsonNullableModule")
|
||||
public Module jsonNullableModule() {
|
||||
return new JsonNullableModule();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package org.openapitools;
|
||||
|
||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class RFC3339DateFormat extends DateFormat {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
|
||||
|
||||
private final StdDateFormat fmt = new StdDateFormat()
|
||||
.withTimeZone(TIMEZONE_Z)
|
||||
.withColonInTimeZone(true);
|
||||
|
||||
public RFC3339DateFormat() {
|
||||
this.calendar = new GregorianCalendar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date parse(String source, ParsePosition pos) {
|
||||
return fmt.parse(source, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
|
||||
return fmt.format(date, toAppendTo, fieldPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ApiUtil {
|
||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||
try {
|
||||
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
res.addHeader("Content-Type", contentType);
|
||||
res.getWriter().print(example);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,438 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.model.ModelApiResponse;
|
||||
import org.openapitools.model.Pet;
|
||||
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Validated
|
||||
@Tag(name = "pet", description = "Everything about your Pets")
|
||||
public interface PetApi {
|
||||
|
||||
default Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /pet : Add a new pet to the store
|
||||
*
|
||||
*
|
||||
* @param pet Pet object that needs to be added to the store (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid input (status code 405)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "addPet",
|
||||
summary = "Add a new pet to the store",
|
||||
description = "",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = Pet.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "405", description = "Invalid input")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/pet",
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Pet> addPet(
|
||||
@Parameter(name = "Pet", description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DELETE /pet/{petId} : Deletes a pet
|
||||
*
|
||||
*
|
||||
* @param petId Pet id to delete (required)
|
||||
* @param apiKey (optional)
|
||||
* @return Invalid pet value (status code 400)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "deletePet",
|
||||
summary = "Deletes a pet",
|
||||
description = "",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid pet value")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.DELETE,
|
||||
value = "/pet/{petId}"
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> deletePet(
|
||||
@Parameter(name = "petId", description = "Pet id to delete", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
|
||||
@Parameter(name = "api_key", description = "", in = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) String apiKey
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /pet/findByStatus : Finds Pets by status
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
*
|
||||
* @param status Status values that need to be considered for filter (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid status value (status code 400)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "findPetsByStatus",
|
||||
summary = "Finds Pets by status",
|
||||
description = "Multiple status values can be provided with comma separated strings",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = Pet.class))),
|
||||
@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = Pet.class)))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid status value")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/pet/findByStatus",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<List<Pet>> findPetsByStatus(
|
||||
@NotNull @Parameter(name = "status", deprecated = true, description = "Status values that need to be considered for filter", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "status", required = true) @Deprecated List<String> status
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /pet/findByTags : Finds Pets by tags
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
*
|
||||
* @param tags Tags to filter by (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid tag value (status code 400)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
@Operation(
|
||||
operationId = "findPetsByTags",
|
||||
summary = "Finds Pets by tags",
|
||||
description = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
|
||||
deprecated = true,
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = Pet.class))),
|
||||
@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = Pet.class)))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid tag value")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/pet/findByTags",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<List<Pet>> findPetsByTags(
|
||||
@NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "tags", required = true) List<String> tags
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /pet/{petId} : Find pet by ID
|
||||
* Returns a single pet
|
||||
*
|
||||
* @param petId ID of pet to return (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid ID supplied (status code 400)
|
||||
* or Pet not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "getPetById",
|
||||
summary = "Find pet by ID",
|
||||
description = "Returns a single pet",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = Pet.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Pet not found")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Pet> getPetById(
|
||||
@Parameter(name = "petId", description = "ID of pet to return", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PUT /pet : Update an existing pet
|
||||
*
|
||||
*
|
||||
* @param pet Pet object that needs to be added to the store (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid ID supplied (status code 400)
|
||||
* or Pet not found (status code 404)
|
||||
* or Validation exception (status code 405)
|
||||
* API documentation for the updatePet operation
|
||||
* @see <a href="http://petstore.swagger.io/v2/doc/updatePet">Update an existing pet Documentation</a>
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "updatePet",
|
||||
summary = "Update an existing pet",
|
||||
description = "",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = Pet.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Pet not found"),
|
||||
@ApiResponse(responseCode = "405", description = "Validation exception")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" })
|
||||
},
|
||||
externalDocs = @ExternalDocumentation(description = "API documentation for the updatePet operation", url = "http://petstore.swagger.io/v2/doc/updatePet")
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.PUT,
|
||||
value = "/pet",
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Pet> updatePet(
|
||||
@Parameter(name = "Pet", description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status> </Pet>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /pet/{petId} : Updates a pet in the store with form data
|
||||
*
|
||||
*
|
||||
* @param petId ID of pet that needs to be updated (required)
|
||||
* @param name Updated name of the pet (optional)
|
||||
* @param status Updated status of the pet (optional)
|
||||
* @return Invalid input (status code 405)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "updatePetWithForm",
|
||||
summary = "Updates a pet in the store with form data",
|
||||
description = "",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "405", description = "Invalid input")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/pet/{petId}",
|
||||
consumes = { "application/x-www-form-urlencoded" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> updatePetWithForm(
|
||||
@Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
|
||||
@Parameter(name = "name", description = "Updated name of the pet") @Valid @RequestParam(value = "name", required = false) String name,
|
||||
@Parameter(name = "status", description = "Updated status of the pet") @Valid @RequestParam(value = "status", required = false) String status
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /pet/{petId}/uploadImage : uploads an image
|
||||
*
|
||||
*
|
||||
* @param petId ID of pet to update (required)
|
||||
* @param additionalMetadata Additional data to pass to server (optional)
|
||||
* @param file file to upload (optional)
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "uploadFile",
|
||||
summary = "uploads an image",
|
||||
description = "",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))
|
||||
})
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/pet/{petId}/uploadImage",
|
||||
produces = { "application/json" },
|
||||
consumes = { "multipart/form-data" }
|
||||
)
|
||||
|
||||
default ResponseEntity<ModelApiResponse> uploadFile(
|
||||
@Parameter(name = "petId", description = "ID of pet to update", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
|
||||
@Parameter(name = "additionalMetadata", description = "Additional data to pass to server") @Valid @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata,
|
||||
@Parameter(name = "file", description = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.model.ModelApiResponse;
|
||||
import org.openapitools.model.Pet;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
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.CookieValue;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Controller
|
||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||
public class PetApiController implements PetApi {
|
||||
|
||||
private final NativeWebRequest request;
|
||||
|
||||
@Autowired
|
||||
public PetApiController(NativeWebRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,210 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.openapitools.model.Order;
|
||||
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Validated
|
||||
@Tag(name = "store", description = "Access to Petstore orders")
|
||||
public interface StoreApi {
|
||||
|
||||
default Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE /store/order/{orderId} : Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
*
|
||||
* @param orderId ID of the order that needs to be deleted (required)
|
||||
* @return Invalid ID supplied (status code 400)
|
||||
* or Order not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "deleteOrder",
|
||||
summary = "Delete purchase order by ID",
|
||||
description = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
|
||||
tags = { "store" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Order not found")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.DELETE,
|
||||
value = "/store/order/{orderId}"
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> deleteOrder(
|
||||
@Parameter(name = "orderId", description = "ID of the order that needs to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("orderId") String orderId
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /store/inventory : Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
*
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "getInventory",
|
||||
summary = "Returns pet inventories by status",
|
||||
description = "Returns a map of status codes to quantities",
|
||||
tags = { "store" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))
|
||||
})
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/store/inventory",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Map<String, Integer>> getInventory(
|
||||
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /store/order/{orderId} : Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
*
|
||||
* @param orderId ID of pet that needs to be fetched (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid ID supplied (status code 400)
|
||||
* or Order not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "getOrderById",
|
||||
summary = "Find purchase order by ID",
|
||||
description = "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions",
|
||||
tags = { "store" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = Order.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Order not found")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/store/order/{orderId}",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Order> getOrderById(
|
||||
@Min(1L) @Max(5L) @Parameter(name = "orderId", description = "ID of pet that needs to be fetched", required = true, in = ParameterIn.PATH) @PathVariable("orderId") Long orderId
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /store/order : Place an order for a pet
|
||||
*
|
||||
*
|
||||
* @param order order placed for purchasing the pet (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid Order (status code 400)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "placeOrder",
|
||||
summary = "Place an order for a pet",
|
||||
description = "",
|
||||
tags = { "store" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = Order.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid Order")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/store/order",
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Order> placeOrder(
|
||||
@Parameter(name = "Order", description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.openapitools.model.Order;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
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.CookieValue;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Controller
|
||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||
public class StoreApiController implements StoreApi {
|
||||
|
||||
private final NativeWebRequest request;
|
||||
|
||||
@Autowired
|
||||
public StoreApiController(NativeWebRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,333 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import org.openapitools.model.User;
|
||||
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Validated
|
||||
@Tag(name = "user", description = "Operations about user")
|
||||
public interface UserApi {
|
||||
|
||||
default Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /user : Create user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param user Created user object (required)
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "createUser",
|
||||
summary = "Create user",
|
||||
description = "This can only be done by the logged in user.",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "default", description = "successful operation")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/user",
|
||||
consumes = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> createUser(
|
||||
@Parameter(name = "User", description = "Created user object", required = true) @Valid @RequestBody User user
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /user/createWithArray : Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* @param user List of user object (required)
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "createUsersWithArrayInput",
|
||||
summary = "Creates list of users with given input array",
|
||||
description = "",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "default", description = "successful operation")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/user/createWithArray",
|
||||
consumes = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> createUsersWithArrayInput(
|
||||
@Parameter(name = "User", description = "List of user object", required = true) @Valid @RequestBody List<@Valid User> user
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /user/createWithList : Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* @param user List of user object (required)
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "createUsersWithListInput",
|
||||
summary = "Creates list of users with given input array",
|
||||
description = "",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "default", description = "successful operation")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/user/createWithList",
|
||||
consumes = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> createUsersWithListInput(
|
||||
@Parameter(name = "User", description = "List of user object", required = true) @Valid @RequestBody List<@Valid User> user
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DELETE /user/{username} : Delete user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param username The name that needs to be deleted (required)
|
||||
* @return Invalid username supplied (status code 400)
|
||||
* or User not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "deleteUser",
|
||||
summary = "Delete user",
|
||||
description = "This can only be done by the logged in user.",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid username supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "User not found")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.DELETE,
|
||||
value = "/user/{username}"
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> deleteUser(
|
||||
@Parameter(name = "username", description = "The name that needs to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("username") String username
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /user/{username} : Get user by user name
|
||||
*
|
||||
*
|
||||
* @param username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid username supplied (status code 400)
|
||||
* or User not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "getUserByName",
|
||||
summary = "Get user by user name",
|
||||
description = "",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = User.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = User.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid username supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "User not found")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<User> getUserByName(
|
||||
@Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, in = ParameterIn.PATH) @PathVariable("username") String username
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<User> <id>123456789</id> <username>aeiou</username> <firstName>aeiou</firstName> <lastName>aeiou</lastName> <email>aeiou</email> <password>aeiou</password> <phone>aeiou</phone> <userStatus>123</userStatus> </User>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /user/login : Logs user into the system
|
||||
*
|
||||
*
|
||||
* @param username The user name for login (required)
|
||||
* @param password The password for login in clear text (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid username/password supplied (status code 400)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "loginUser",
|
||||
summary = "Logs user into the system",
|
||||
description = "",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = String.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = String.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid username/password supplied")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/user/login",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<String> loginUser(
|
||||
@NotNull @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Parameter(name = "username", description = "The user name for login", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "password", required = true) String password
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /user/logout : Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "logoutUser",
|
||||
summary = "Logs out current logged in user session",
|
||||
description = "",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "default", description = "successful operation")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/user/logout"
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> logoutUser(
|
||||
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PUT /user/{username} : Updated user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param username name that need to be deleted (required)
|
||||
* @param user Updated user object (required)
|
||||
* @return Invalid user supplied (status code 400)
|
||||
* or User not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "updateUser",
|
||||
summary = "Updated user",
|
||||
description = "This can only be done by the logged in user.",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid user supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "User not found")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.PUT,
|
||||
value = "/user/{username}",
|
||||
consumes = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> updateUser(
|
||||
@Parameter(name = "username", description = "name that need to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("username") String username,
|
||||
@Parameter(name = "User", description = "Updated user object", required = true) @Valid @RequestBody User user
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import org.openapitools.model.User;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
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.CookieValue;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Controller
|
||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||
public class UserApiController implements UserApi {
|
||||
|
||||
private final NativeWebRequest request;
|
||||
|
||||
@Autowired
|
||||
public UserApiController(NativeWebRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.openapitools.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* Home redirection to OpenAPI api documentation
|
||||
*/
|
||||
@Controller
|
||||
public class HomeController {
|
||||
|
||||
@RequestMapping("/")
|
||||
public String index() {
|
||||
return "redirect:swagger-ui.html";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package org.openapitools.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
|
||||
@Configuration
|
||||
public class SpringDocConfiguration {
|
||||
|
||||
@Bean(name = "org.openapitools.configuration.SpringDocConfiguration.apiInfo")
|
||||
OpenAPI apiInfo() {
|
||||
return new OpenAPI()
|
||||
.info(
|
||||
new Info()
|
||||
.title("OpenAPI Petstore")
|
||||
.description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.")
|
||||
.license(
|
||||
new License()
|
||||
.name("Apache-2.0")
|
||||
.url("https://www.apache.org/licenses/LICENSE-2.0.html")
|
||||
)
|
||||
.version("1.0.0")
|
||||
)
|
||||
.components(
|
||||
new Components()
|
||||
.addSecuritySchemes("petstore_auth", new SecurityScheme()
|
||||
.type(SecurityScheme.Type.OAUTH2)
|
||||
)
|
||||
.addSecuritySchemes("api_key", new SecurityScheme()
|
||||
.type(SecurityScheme.Type.APIKEY)
|
||||
.in(SecurityScheme.In.HEADER)
|
||||
.name("api_key")
|
||||
)
|
||||
)
|
||||
;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
*/
|
||||
@lombok.Data
|
||||
@lombok.Builder
|
||||
@lombok.NoArgsConstructor
|
||||
@lombok.AllArgsConstructor
|
||||
|
||||
@Schema(name = "Category", description = "A category for a pet")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Category {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,38 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
*/
|
||||
@lombok.Data
|
||||
@lombok.Builder
|
||||
@lombok.NoArgsConstructor
|
||||
@lombok.AllArgsConstructor
|
||||
|
||||
@Schema(name = "ApiResponse", description = "Describes the result of uploading an image resource")
|
||||
@JsonTypeName("ApiResponse")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class ModelApiResponse {
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String type;
|
||||
|
||||
private String message;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,83 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.time.OffsetDateTime;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
*/
|
||||
@lombok.Data
|
||||
@lombok.Builder
|
||||
@lombok.NoArgsConstructor
|
||||
@lombok.AllArgsConstructor
|
||||
|
||||
@Schema(name = "Order", description = "An order for a pets from the pet store")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Order {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long petId;
|
||||
|
||||
private Integer quantity;
|
||||
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
||||
private OffsetDateTime shipDate;
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
public enum StatusEnum {
|
||||
PLACED("placed"),
|
||||
|
||||
APPROVED("approved"),
|
||||
|
||||
DELIVERED("delivered");
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static StatusEnum fromValue(String value) {
|
||||
for (StatusEnum b : StatusEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private StatusEnum status;
|
||||
|
||||
private Boolean complete = false;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,90 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.openapitools.model.Category;
|
||||
import org.openapitools.model.Tag;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
*/
|
||||
@lombok.Data
|
||||
@lombok.Builder
|
||||
@lombok.NoArgsConstructor
|
||||
@lombok.AllArgsConstructor
|
||||
|
||||
@Schema(name = "Pet", description = "A pet for sale in the pet store")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Pet {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Category category;
|
||||
|
||||
@lombok.NonNull
|
||||
private String name;
|
||||
|
||||
@lombok.NonNull
|
||||
@Valid
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
@Valid
|
||||
private List<@Valid Tag> tags;
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
public enum StatusEnum {
|
||||
AVAILABLE("available"),
|
||||
|
||||
PENDING("pending"),
|
||||
|
||||
SOLD("sold");
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static StatusEnum fromValue(String value) {
|
||||
for (StatusEnum b : StatusEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private StatusEnum status;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
*/
|
||||
@lombok.Data
|
||||
@lombok.Builder
|
||||
@lombok.NoArgsConstructor
|
||||
@lombok.AllArgsConstructor
|
||||
|
||||
@Schema(name = "Tag", description = "A tag for a pet")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Tag {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
*/
|
||||
@lombok.Data
|
||||
@lombok.Builder
|
||||
@lombok.NoArgsConstructor
|
||||
@lombok.AllArgsConstructor
|
||||
|
||||
@Schema(name = "User", description = "A User who is purchasing from the pet store")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class User {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String username;
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
private String email;
|
||||
|
||||
private String password;
|
||||
|
||||
private String phone;
|
||||
|
||||
private Integer userStatus;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
server.port=8080
|
||||
spring.jackson.date-format=org.openapitools.RFC3339DateFormat
|
||||
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
|
@ -0,0 +1,880 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
description: "This is a sample server Petstore server. For this sample, you can\
|
||||
\ use the api key `special-key` to test the authorization filters."
|
||||
license:
|
||||
name: Apache-2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
title: OpenAPI Petstore
|
||||
version: 1.0.0
|
||||
externalDocs:
|
||||
description: Find out more about Swagger
|
||||
url: http://swagger.io
|
||||
servers:
|
||||
- url: http://petstore.swagger.io/v2
|
||||
tags:
|
||||
- description: Everything about your Pets
|
||||
name: pet
|
||||
- description: Access to Petstore orders
|
||||
name: store
|
||||
- description: Operations about user
|
||||
name: user
|
||||
paths:
|
||||
/pet:
|
||||
post:
|
||||
description: ""
|
||||
operationId: addPet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
"405":
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Add a new pet to the store
|
||||
tags:
|
||||
- pet
|
||||
x-content-type: application/json
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: pet
|
||||
put:
|
||||
description: ""
|
||||
externalDocs:
|
||||
description: API documentation for the updatePet operation
|
||||
url: http://petstore.swagger.io/v2/doc/updatePet
|
||||
operationId: updatePet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Pet not found
|
||||
"405":
|
||||
description: Validation exception
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Update an existing pet
|
||||
tags:
|
||||
- pet
|
||||
x-content-type: application/json
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: pet
|
||||
/pet/findByStatus:
|
||||
get:
|
||||
description: Multiple status values can be provided with comma separated strings
|
||||
operationId: findPetsByStatus
|
||||
parameters:
|
||||
- deprecated: true
|
||||
description: Status values that need to be considered for filter
|
||||
explode: false
|
||||
in: query
|
||||
name: status
|
||||
required: true
|
||||
schema:
|
||||
items:
|
||||
default: available
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
type: string
|
||||
type: array
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid status value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- read:pets
|
||||
summary: Finds Pets by status
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: pet
|
||||
/pet/findByTags:
|
||||
get:
|
||||
deprecated: true
|
||||
description: "Multiple tags can be provided with comma separated strings. Use\
|
||||
\ tag1, tag2, tag3 for testing."
|
||||
operationId: findPetsByTags
|
||||
parameters:
|
||||
- description: Tags to filter by
|
||||
explode: false
|
||||
in: query
|
||||
name: tags
|
||||
required: true
|
||||
schema:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid tag value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- read:pets
|
||||
summary: Finds Pets by tags
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: pet
|
||||
/pet/{petId}:
|
||||
delete:
|
||||
description: ""
|
||||
operationId: deletePet
|
||||
parameters:
|
||||
- explode: false
|
||||
in: header
|
||||
name: api_key
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
- description: Pet id to delete
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid pet value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Deletes a pet
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: pet
|
||||
get:
|
||||
description: Returns a single pet
|
||||
operationId: getPetById
|
||||
parameters:
|
||||
- description: ID of pet to return
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Pet not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Find pet by ID
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: pet
|
||||
post:
|
||||
description: ""
|
||||
operationId: updatePetWithForm
|
||||
parameters:
|
||||
- description: ID of pet that needs to be updated
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
requestBody:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/updatePetWithForm_request'
|
||||
responses:
|
||||
"405":
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Updates a pet in the store with form data
|
||||
tags:
|
||||
- pet
|
||||
x-content-type: application/x-www-form-urlencoded
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: pet
|
||||
/pet/{petId}/uploadImage:
|
||||
post:
|
||||
description: ""
|
||||
operationId: uploadFile
|
||||
parameters:
|
||||
- description: ID of pet to update
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
$ref: '#/components/schemas/uploadFile_request'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
description: successful operation
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: uploads an image
|
||||
tags:
|
||||
- pet
|
||||
x-content-type: multipart/form-data
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: pet
|
||||
/store/inventory:
|
||||
get:
|
||||
description: Returns a map of status codes to quantities
|
||||
operationId: getInventory
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
additionalProperties:
|
||||
format: int32
|
||||
type: integer
|
||||
type: object
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Returns pet inventories by status
|
||||
tags:
|
||||
- store
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: store
|
||||
/store/order:
|
||||
post:
|
||||
description: ""
|
||||
operationId: placeOrder
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: order placed for purchasing the pet
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid Order
|
||||
summary: Place an order for a pet
|
||||
tags:
|
||||
- store
|
||||
x-content-type: application/json
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: store
|
||||
/store/order/{orderId}:
|
||||
delete:
|
||||
description: For valid response try integer IDs with value < 1000. Anything
|
||||
above 1000 or nonintegers will generate API errors
|
||||
operationId: deleteOrder
|
||||
parameters:
|
||||
- description: ID of the order that needs to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: orderId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Order not found
|
||||
summary: Delete purchase order by ID
|
||||
tags:
|
||||
- store
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: store
|
||||
get:
|
||||
description: For valid response try integer IDs with value <= 5 or > 10. Other
|
||||
values will generate exceptions
|
||||
operationId: getOrderById
|
||||
parameters:
|
||||
- description: ID of pet that needs to be fetched
|
||||
explode: false
|
||||
in: path
|
||||
name: orderId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
maximum: 5
|
||||
minimum: 1
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Order not found
|
||||
summary: Find purchase order by ID
|
||||
tags:
|
||||
- store
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: store
|
||||
/user:
|
||||
post:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: createUser
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: Created user object
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Create user
|
||||
tags:
|
||||
- user
|
||||
x-content-type: application/json
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
/user/createWithArray:
|
||||
post:
|
||||
description: ""
|
||||
operationId: createUsersWithArrayInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Creates list of users with given input array
|
||||
tags:
|
||||
- user
|
||||
x-content-type: application/json
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
/user/createWithList:
|
||||
post:
|
||||
description: ""
|
||||
operationId: createUsersWithListInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Creates list of users with given input array
|
||||
tags:
|
||||
- user
|
||||
x-content-type: application/json
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
/user/login:
|
||||
get:
|
||||
description: ""
|
||||
operationId: loginUser
|
||||
parameters:
|
||||
- description: The user name for login
|
||||
explode: true
|
||||
in: query
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$"
|
||||
type: string
|
||||
style: form
|
||||
- description: The password for login in clear text
|
||||
explode: true
|
||||
in: query
|
||||
name: password
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: string
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
description: successful operation
|
||||
headers:
|
||||
Set-Cookie:
|
||||
description: Cookie authentication key for use with the `api_key` apiKey
|
||||
authentication.
|
||||
explode: false
|
||||
schema:
|
||||
example: AUTH_KEY=abcde12345; Path=/; HttpOnly
|
||||
type: string
|
||||
style: simple
|
||||
X-Rate-Limit:
|
||||
description: calls per hour allowed by the user
|
||||
explode: false
|
||||
schema:
|
||||
format: int32
|
||||
type: integer
|
||||
style: simple
|
||||
X-Expires-After:
|
||||
description: date in UTC when token expires
|
||||
explode: false
|
||||
schema:
|
||||
format: date-time
|
||||
type: string
|
||||
style: simple
|
||||
"400":
|
||||
description: Invalid username/password supplied
|
||||
summary: Logs user into the system
|
||||
tags:
|
||||
- user
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: user
|
||||
/user/logout:
|
||||
get:
|
||||
description: ""
|
||||
operationId: logoutUser
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Logs out current logged in user session
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
/user/{username}:
|
||||
delete:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: deleteUser
|
||||
parameters:
|
||||
- description: The name that needs to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid username supplied
|
||||
"404":
|
||||
description: User not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Delete user
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
get:
|
||||
description: ""
|
||||
operationId: getUserByName
|
||||
parameters:
|
||||
- description: The name that needs to be fetched. Use user1 for testing.
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid username supplied
|
||||
"404":
|
||||
description: User not found
|
||||
summary: Get user by user name
|
||||
tags:
|
||||
- user
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: user
|
||||
put:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: updateUser
|
||||
parameters:
|
||||
- description: name that need to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: Updated user object
|
||||
required: true
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid user supplied
|
||||
"404":
|
||||
description: User not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Updated user
|
||||
tags:
|
||||
- user
|
||||
x-content-type: application/json
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
components:
|
||||
requestBodies:
|
||||
UserArray:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
type: array
|
||||
description: List of user object
|
||||
required: true
|
||||
Pet:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: Pet object that needs to be added to the store
|
||||
required: true
|
||||
schemas:
|
||||
Order:
|
||||
description: An order for a pets from the pet store
|
||||
example:
|
||||
petId: 6
|
||||
quantity: 1
|
||||
id: 0
|
||||
shipDate: 2000-01-23T04:56:07.000+00:00
|
||||
complete: false
|
||||
status: placed
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
petId:
|
||||
format: int64
|
||||
type: integer
|
||||
quantity:
|
||||
format: int32
|
||||
type: integer
|
||||
shipDate:
|
||||
format: date-time
|
||||
type: string
|
||||
status:
|
||||
description: Order Status
|
||||
enum:
|
||||
- placed
|
||||
- approved
|
||||
- delivered
|
||||
type: string
|
||||
complete:
|
||||
default: false
|
||||
type: boolean
|
||||
title: Pet Order
|
||||
type: object
|
||||
xml:
|
||||
name: Order
|
||||
Category:
|
||||
description: A category for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 6
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
name:
|
||||
pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$"
|
||||
type: string
|
||||
title: Pet category
|
||||
type: object
|
||||
xml:
|
||||
name: Category
|
||||
User:
|
||||
description: A User who is purchasing from the pet store
|
||||
example:
|
||||
firstName: firstName
|
||||
lastName: lastName
|
||||
password: password
|
||||
userStatus: 6
|
||||
phone: phone
|
||||
id: 0
|
||||
email: email
|
||||
username: username
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
username:
|
||||
type: string
|
||||
firstName:
|
||||
type: string
|
||||
lastName:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
phone:
|
||||
type: string
|
||||
userStatus:
|
||||
description: User Status
|
||||
format: int32
|
||||
type: integer
|
||||
title: a User
|
||||
type: object
|
||||
xml:
|
||||
name: User
|
||||
Tag:
|
||||
description: A tag for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 1
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
title: Pet Tag
|
||||
type: object
|
||||
xml:
|
||||
name: Tag
|
||||
Pet:
|
||||
description: A pet for sale in the pet store
|
||||
example:
|
||||
photoUrls:
|
||||
- photoUrls
|
||||
- photoUrls
|
||||
name: doggie
|
||||
id: 0
|
||||
category:
|
||||
name: name
|
||||
id: 6
|
||||
tags:
|
||||
- name: name
|
||||
id: 1
|
||||
- name: name
|
||||
id: 1
|
||||
status: available
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
category:
|
||||
$ref: '#/components/schemas/Category'
|
||||
name:
|
||||
example: doggie
|
||||
type: string
|
||||
photoUrls:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
xml:
|
||||
name: photoUrl
|
||||
wrapped: true
|
||||
tags:
|
||||
items:
|
||||
$ref: '#/components/schemas/Tag'
|
||||
type: array
|
||||
xml:
|
||||
name: tag
|
||||
wrapped: true
|
||||
status:
|
||||
deprecated: true
|
||||
description: pet status in the store
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
- photoUrls
|
||||
title: a Pet
|
||||
type: object
|
||||
xml:
|
||||
name: Pet
|
||||
ApiResponse:
|
||||
description: Describes the result of uploading an image resource
|
||||
example:
|
||||
code: 0
|
||||
type: type
|
||||
message: message
|
||||
properties:
|
||||
code:
|
||||
format: int32
|
||||
type: integer
|
||||
type:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
title: An uploaded response
|
||||
type: object
|
||||
updatePetWithForm_request:
|
||||
properties:
|
||||
name:
|
||||
description: Updated name of the pet
|
||||
type: string
|
||||
status:
|
||||
description: Updated status of the pet
|
||||
type: string
|
||||
type: object
|
||||
uploadFile_request:
|
||||
properties:
|
||||
additionalMetadata:
|
||||
description: Additional data to pass to server
|
||||
type: string
|
||||
file:
|
||||
description: file to upload
|
||||
format: binary
|
||||
type: string
|
||||
type: object
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
flows:
|
||||
implicit:
|
||||
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
||||
scopes:
|
||||
write:pets: modify pets in your account
|
||||
read:pets: read your pets
|
||||
type: oauth2
|
||||
api_key:
|
||||
in: header
|
||||
name: api_key
|
||||
type: apiKey
|
@ -0,0 +1,13 @@
|
||||
package org.openapitools;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class OpenApiGeneratorApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# 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 OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
@ -0,0 +1,19 @@
|
||||
README.md
|
||||
pom.xml
|
||||
src/main/java/org/openapitools/OpenApiGeneratorApplication.java
|
||||
src/main/java/org/openapitools/RFC3339DateFormat.java
|
||||
src/main/java/org/openapitools/api/ApiUtil.java
|
||||
src/main/java/org/openapitools/api/PetApi.java
|
||||
src/main/java/org/openapitools/api/StoreApi.java
|
||||
src/main/java/org/openapitools/api/UserApi.java
|
||||
src/main/java/org/openapitools/configuration/HomeController.java
|
||||
src/main/java/org/openapitools/configuration/SpringDocConfiguration.java
|
||||
src/main/java/org/openapitools/model/Category.java
|
||||
src/main/java/org/openapitools/model/ModelApiResponse.java
|
||||
src/main/java/org/openapitools/model/Order.java
|
||||
src/main/java/org/openapitools/model/Pet.java
|
||||
src/main/java/org/openapitools/model/Tag.java
|
||||
src/main/java/org/openapitools/model/User.java
|
||||
src/main/resources/application.properties
|
||||
src/main/resources/openapi.yaml
|
||||
src/test/java/org/openapitools/OpenApiGeneratorApplicationTests.java
|
@ -0,0 +1 @@
|
||||
7.3.0-SNAPSHOT
|
21
samples/server/petstore/springboot-lombok-tostring/README.md
Normal file
21
samples/server/petstore/springboot-lombok-tostring/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# OpenAPI generated server
|
||||
|
||||
Spring Boot Server
|
||||
|
||||
## Overview
|
||||
This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project.
|
||||
By using the [OpenAPI-Spec](https://openapis.org), you can easily generate a server stub.
|
||||
This is an example of building a OpenAPI-enabled server in Java using the SpringBoot framework.
|
||||
|
||||
|
||||
The underlying library integrating OpenAPI to Spring Boot is [springdoc](https://springdoc.org).
|
||||
Springdoc will generate an OpenAPI v3 specification based on the generated Controller and Model classes.
|
||||
The specification is available to download using the following url:
|
||||
http://localhost:8080/v3/api-docs/
|
||||
|
||||
Start your server as a simple java application
|
||||
|
||||
You can view the api documentation in swagger-ui by pointing to
|
||||
http://localhost:8080/swagger-ui.html
|
||||
|
||||
Change default port value in application.properties
|
108
samples/server/petstore/springboot-lombok-tostring/pom.xml
Normal file
108
samples/server/petstore/springboot-lombok-tostring/pom.xml
Normal file
@ -0,0 +1,108 @@
|
||||
<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>org.openapitools.openapi3</groupId>
|
||||
<artifactId>springboot-lombok-tostring</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>springboot-lombok-tostring</name>
|
||||
<version>1.0.0</version>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<springdoc.version>2.2.0</springdoc.version>
|
||||
<swagger-ui.version>5.3.1</swagger-ui.version>
|
||||
</properties>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.1.3</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>repository.spring.milestone</id>
|
||||
<name>Spring Milestone Repository</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-commons</artifactId>
|
||||
</dependency>
|
||||
<!--SpringDoc dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>${springdoc.version}</version>
|
||||
</dependency>
|
||||
<!-- @Nullable annotation -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>jackson-databind-nullable</artifactId>
|
||||
<version>0.2.6</version>
|
||||
</dependency>
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,30 @@
|
||||
package org.openapitools;
|
||||
|
||||
import com.fasterxml.jackson.databind.Module;
|
||||
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.FilterType;
|
||||
import org.springframework.context.annotation.FullyQualifiedAnnotationBeanNameGenerator;
|
||||
|
||||
@SpringBootApplication(
|
||||
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
|
||||
)
|
||||
@ComponentScan(
|
||||
basePackages = {"org.openapitools", "org.openapitools.api" , "org.openapitools.configuration"},
|
||||
nameGenerator = FullyQualifiedAnnotationBeanNameGenerator.class
|
||||
)
|
||||
public class OpenApiGeneratorApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OpenApiGeneratorApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean(name = "org.openapitools.OpenApiGeneratorApplication.jsonNullableModule")
|
||||
public Module jsonNullableModule() {
|
||||
return new JsonNullableModule();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package org.openapitools;
|
||||
|
||||
import com.fasterxml.jackson.databind.util.StdDateFormat;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.FieldPosition;
|
||||
import java.text.ParsePosition;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
public class RFC3339DateFormat extends DateFormat {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
|
||||
|
||||
private final StdDateFormat fmt = new StdDateFormat()
|
||||
.withTimeZone(TIMEZONE_Z)
|
||||
.withColonInTimeZone(true);
|
||||
|
||||
public RFC3339DateFormat() {
|
||||
this.calendar = new GregorianCalendar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date parse(String source, ParsePosition pos) {
|
||||
return fmt.parse(source, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
|
||||
return fmt.format(date, toAppendTo, fieldPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public class ApiUtil {
|
||||
public static void setExampleResponse(NativeWebRequest req, String contentType, String example) {
|
||||
try {
|
||||
HttpServletResponse res = req.getNativeResponse(HttpServletResponse.class);
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
res.addHeader("Content-Type", contentType);
|
||||
res.getWriter().print(example);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,438 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.model.ModelApiResponse;
|
||||
import org.openapitools.model.Pet;
|
||||
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Validated
|
||||
@Tag(name = "pet", description = "Everything about your Pets")
|
||||
public interface PetApi {
|
||||
|
||||
default Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /pet : Add a new pet to the store
|
||||
*
|
||||
*
|
||||
* @param pet Pet object that needs to be added to the store (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid input (status code 405)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "addPet",
|
||||
summary = "Add a new pet to the store",
|
||||
description = "",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = Pet.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "405", description = "Invalid input")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/pet",
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Pet> addPet(
|
||||
@Parameter(name = "Pet", description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DELETE /pet/{petId} : Deletes a pet
|
||||
*
|
||||
*
|
||||
* @param petId Pet id to delete (required)
|
||||
* @param apiKey (optional)
|
||||
* @return Invalid pet value (status code 400)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "deletePet",
|
||||
summary = "Deletes a pet",
|
||||
description = "",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid pet value")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.DELETE,
|
||||
value = "/pet/{petId}"
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> deletePet(
|
||||
@Parameter(name = "petId", description = "Pet id to delete", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
|
||||
@Parameter(name = "api_key", description = "", in = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) String apiKey
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /pet/findByStatus : Finds Pets by status
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
*
|
||||
* @param status Status values that need to be considered for filter (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid status value (status code 400)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "findPetsByStatus",
|
||||
summary = "Finds Pets by status",
|
||||
description = "Multiple status values can be provided with comma separated strings",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = Pet.class))),
|
||||
@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = Pet.class)))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid status value")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/pet/findByStatus",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<List<Pet>> findPetsByStatus(
|
||||
@NotNull @Parameter(name = "status", deprecated = true, description = "Status values that need to be considered for filter", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "status", required = true) @Deprecated List<String> status
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /pet/findByTags : Finds Pets by tags
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
*
|
||||
* @param tags Tags to filter by (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid tag value (status code 400)
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
@Operation(
|
||||
operationId = "findPetsByTags",
|
||||
summary = "Finds Pets by tags",
|
||||
description = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
|
||||
deprecated = true,
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", array = @ArraySchema(schema = @Schema(implementation = Pet.class))),
|
||||
@Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = Pet.class)))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid tag value")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/pet/findByTags",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<List<Pet>> findPetsByTags(
|
||||
@NotNull @Parameter(name = "tags", description = "Tags to filter by", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "tags", required = true) List<String> tags
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "[ { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }, { \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" } ]";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /pet/{petId} : Find pet by ID
|
||||
* Returns a single pet
|
||||
*
|
||||
* @param petId ID of pet to return (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid ID supplied (status code 400)
|
||||
* or Pet not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "getPetById",
|
||||
summary = "Find pet by ID",
|
||||
description = "Returns a single pet",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = Pet.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Pet not found")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/pet/{petId}",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Pet> getPetById(
|
||||
@Parameter(name = "petId", description = "ID of pet to return", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <Category> <id>123456789</id> <name>aeiou</name> </Category> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> <Tag> <id>123456789</id> <name>aeiou</name> </Tag> </tags> <status>aeiou</status> </Pet>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PUT /pet : Update an existing pet
|
||||
*
|
||||
*
|
||||
* @param pet Pet object that needs to be added to the store (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid ID supplied (status code 400)
|
||||
* or Pet not found (status code 404)
|
||||
* or Validation exception (status code 405)
|
||||
* API documentation for the updatePet operation
|
||||
* @see <a href="http://petstore.swagger.io/v2/doc/updatePet">Update an existing pet Documentation</a>
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "updatePet",
|
||||
summary = "Update an existing pet",
|
||||
description = "",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = Pet.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Pet.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Pet not found"),
|
||||
@ApiResponse(responseCode = "405", description = "Validation exception")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" })
|
||||
},
|
||||
externalDocs = @ExternalDocumentation(description = "API documentation for the updatePet operation", url = "http://petstore.swagger.io/v2/doc/updatePet")
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.PUT,
|
||||
value = "/pet",
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json", "application/xml" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Pet> updatePet(
|
||||
@Parameter(name = "Pet", description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Pet> <id>123456789</id> <name>doggie</name> <photoUrls> <photoUrls>aeiou</photoUrls> </photoUrls> <tags> </tags> <status>aeiou</status> </Pet>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /pet/{petId} : Updates a pet in the store with form data
|
||||
*
|
||||
*
|
||||
* @param petId ID of pet that needs to be updated (required)
|
||||
* @param name Updated name of the pet (optional)
|
||||
* @param status Updated status of the pet (optional)
|
||||
* @return Invalid input (status code 405)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "updatePetWithForm",
|
||||
summary = "Updates a pet in the store with form data",
|
||||
description = "",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "405", description = "Invalid input")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/pet/{petId}",
|
||||
consumes = { "application/x-www-form-urlencoded" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> updatePetWithForm(
|
||||
@Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
|
||||
@Parameter(name = "name", description = "Updated name of the pet") @Valid @RequestParam(value = "name", required = false) String name,
|
||||
@Parameter(name = "status", description = "Updated status of the pet") @Valid @RequestParam(value = "status", required = false) String status
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /pet/{petId}/uploadImage : uploads an image
|
||||
*
|
||||
*
|
||||
* @param petId ID of pet to update (required)
|
||||
* @param additionalMetadata Additional data to pass to server (optional)
|
||||
* @param file file to upload (optional)
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "uploadFile",
|
||||
summary = "uploads an image",
|
||||
description = "",
|
||||
tags = { "pet" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = ModelApiResponse.class))
|
||||
})
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "petstore_auth", scopes={ "write:pets", "read:pets" })
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/pet/{petId}/uploadImage",
|
||||
produces = { "application/json" },
|
||||
consumes = { "multipart/form-data" }
|
||||
)
|
||||
|
||||
default ResponseEntity<ModelApiResponse> uploadFile(
|
||||
@Parameter(name = "petId", description = "ID of pet to update", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
|
||||
@Parameter(name = "additionalMetadata", description = "Additional data to pass to server") @Valid @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata,
|
||||
@Parameter(name = "file", description = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import org.openapitools.model.ModelApiResponse;
|
||||
import org.openapitools.model.Pet;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
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.CookieValue;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Controller
|
||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||
public class PetApiController implements PetApi {
|
||||
|
||||
private final NativeWebRequest request;
|
||||
|
||||
@Autowired
|
||||
public PetApiController(NativeWebRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,210 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.openapitools.model.Order;
|
||||
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Validated
|
||||
@Tag(name = "store", description = "Access to Petstore orders")
|
||||
public interface StoreApi {
|
||||
|
||||
default Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* DELETE /store/order/{orderId} : Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
*
|
||||
* @param orderId ID of the order that needs to be deleted (required)
|
||||
* @return Invalid ID supplied (status code 400)
|
||||
* or Order not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "deleteOrder",
|
||||
summary = "Delete purchase order by ID",
|
||||
description = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
|
||||
tags = { "store" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Order not found")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.DELETE,
|
||||
value = "/store/order/{orderId}"
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> deleteOrder(
|
||||
@Parameter(name = "orderId", description = "ID of the order that needs to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("orderId") String orderId
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /store/inventory : Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
*
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "getInventory",
|
||||
summary = "Returns pet inventories by status",
|
||||
description = "Returns a map of status codes to quantities",
|
||||
tags = { "store" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Map.class))
|
||||
})
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/store/inventory",
|
||||
produces = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Map<String, Integer>> getInventory(
|
||||
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /store/order/{orderId} : Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
*
|
||||
* @param orderId ID of pet that needs to be fetched (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid ID supplied (status code 400)
|
||||
* or Order not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "getOrderById",
|
||||
summary = "Find purchase order by ID",
|
||||
description = "For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions",
|
||||
tags = { "store" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = Order.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "Order not found")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/store/order/{orderId}",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Order> getOrderById(
|
||||
@Min(1L) @Max(5L) @Parameter(name = "orderId", description = "ID of pet that needs to be fetched", required = true, in = ParameterIn.PATH) @PathVariable("orderId") Long orderId
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /store/order : Place an order for a pet
|
||||
*
|
||||
*
|
||||
* @param order order placed for purchasing the pet (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid Order (status code 400)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "placeOrder",
|
||||
summary = "Place an order for a pet",
|
||||
description = "",
|
||||
tags = { "store" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = Order.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = Order.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid Order")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/store/order",
|
||||
produces = { "application/xml", "application/json" },
|
||||
consumes = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Order> placeOrder(
|
||||
@Parameter(name = "Order", description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<Order> <id>123456789</id> <petId>123456789</petId> <quantity>123</quantity> <shipDate>2000-01-23T04:56:07.000Z</shipDate> <status>aeiou</status> <complete>true</complete> </Order>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.util.Map;
|
||||
import org.openapitools.model.Order;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
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.CookieValue;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Controller
|
||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||
public class StoreApiController implements StoreApi {
|
||||
|
||||
private final NativeWebRequest request;
|
||||
|
||||
@Autowired
|
||||
public StoreApiController(NativeWebRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,333 @@
|
||||
/**
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (7.3.0-SNAPSHOT).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import org.openapitools.model.User;
|
||||
import io.swagger.v3.oas.annotations.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.media.ArraySchema;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Validated
|
||||
@Tag(name = "user", description = "Operations about user")
|
||||
public interface UserApi {
|
||||
|
||||
default Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* POST /user : Create user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param user Created user object (required)
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "createUser",
|
||||
summary = "Create user",
|
||||
description = "This can only be done by the logged in user.",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "default", description = "successful operation")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/user",
|
||||
consumes = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> createUser(
|
||||
@Parameter(name = "User", description = "Created user object", required = true) @Valid @RequestBody User user
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /user/createWithArray : Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* @param user List of user object (required)
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "createUsersWithArrayInput",
|
||||
summary = "Creates list of users with given input array",
|
||||
description = "",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "default", description = "successful operation")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/user/createWithArray",
|
||||
consumes = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> createUsersWithArrayInput(
|
||||
@Parameter(name = "User", description = "List of user object", required = true) @Valid @RequestBody List<@Valid User> user
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* POST /user/createWithList : Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* @param user List of user object (required)
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "createUsersWithListInput",
|
||||
summary = "Creates list of users with given input array",
|
||||
description = "",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "default", description = "successful operation")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.POST,
|
||||
value = "/user/createWithList",
|
||||
consumes = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> createUsersWithListInput(
|
||||
@Parameter(name = "User", description = "List of user object", required = true) @Valid @RequestBody List<@Valid User> user
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DELETE /user/{username} : Delete user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param username The name that needs to be deleted (required)
|
||||
* @return Invalid username supplied (status code 400)
|
||||
* or User not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "deleteUser",
|
||||
summary = "Delete user",
|
||||
description = "This can only be done by the logged in user.",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid username supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "User not found")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.DELETE,
|
||||
value = "/user/{username}"
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> deleteUser(
|
||||
@Parameter(name = "username", description = "The name that needs to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("username") String username
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /user/{username} : Get user by user name
|
||||
*
|
||||
*
|
||||
* @param username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid username supplied (status code 400)
|
||||
* or User not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "getUserByName",
|
||||
summary = "Get user by user name",
|
||||
description = "",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = User.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = User.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid username supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "User not found")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/user/{username}",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<User> getUserByName(
|
||||
@Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, in = ParameterIn.PATH) @PathVariable("username") String username
|
||||
) {
|
||||
getRequest().ifPresent(request -> {
|
||||
for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
|
||||
String exampleString = "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\" }";
|
||||
ApiUtil.setExampleResponse(request, "application/json", exampleString);
|
||||
break;
|
||||
}
|
||||
if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) {
|
||||
String exampleString = "<User> <id>123456789</id> <username>aeiou</username> <firstName>aeiou</firstName> <lastName>aeiou</lastName> <email>aeiou</email> <password>aeiou</password> <phone>aeiou</phone> <userStatus>123</userStatus> </User>";
|
||||
ApiUtil.setExampleResponse(request, "application/xml", exampleString);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /user/login : Logs user into the system
|
||||
*
|
||||
*
|
||||
* @param username The user name for login (required)
|
||||
* @param password The password for login in clear text (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid username/password supplied (status code 400)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "loginUser",
|
||||
summary = "Logs user into the system",
|
||||
description = "",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "successful operation", content = {
|
||||
@Content(mediaType = "application/xml", schema = @Schema(implementation = String.class)),
|
||||
@Content(mediaType = "application/json", schema = @Schema(implementation = String.class))
|
||||
}),
|
||||
@ApiResponse(responseCode = "400", description = "Invalid username/password supplied")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/user/login",
|
||||
produces = { "application/xml", "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<String> loginUser(
|
||||
@NotNull @Pattern(regexp = "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @Parameter(name = "username", description = "The user name for login", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "username", required = true) String username,
|
||||
@NotNull @Parameter(name = "password", description = "The password for login in clear text", required = true, in = ParameterIn.QUERY) @Valid @RequestParam(value = "password", required = true) String password
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET /user/logout : Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
* @return successful operation (status code 200)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "logoutUser",
|
||||
summary = "Logs out current logged in user session",
|
||||
description = "",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "default", description = "successful operation")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.GET,
|
||||
value = "/user/logout"
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> logoutUser(
|
||||
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* PUT /user/{username} : Updated user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param username name that need to be deleted (required)
|
||||
* @param user Updated user object (required)
|
||||
* @return Invalid user supplied (status code 400)
|
||||
* or User not found (status code 404)
|
||||
*/
|
||||
@Operation(
|
||||
operationId = "updateUser",
|
||||
summary = "Updated user",
|
||||
description = "This can only be done by the logged in user.",
|
||||
tags = { "user" },
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "400", description = "Invalid user supplied"),
|
||||
@ApiResponse(responseCode = "404", description = "User not found")
|
||||
},
|
||||
security = {
|
||||
@SecurityRequirement(name = "api_key")
|
||||
}
|
||||
)
|
||||
@RequestMapping(
|
||||
method = RequestMethod.PUT,
|
||||
value = "/user/{username}",
|
||||
consumes = { "application/json" }
|
||||
)
|
||||
|
||||
default ResponseEntity<Void> updateUser(
|
||||
@Parameter(name = "username", description = "name that need to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("username") String username,
|
||||
@Parameter(name = "User", description = "Updated user object", required = true) @Valid @RequestBody User user
|
||||
) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package org.openapitools.api;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import org.openapitools.model.User;
|
||||
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
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.CookieValue;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.context.request.NativeWebRequest;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
@Controller
|
||||
@RequestMapping("${openapi.openAPIPetstore.base-path:/v2}")
|
||||
public class UserApiController implements UserApi {
|
||||
|
||||
private final NativeWebRequest request;
|
||||
|
||||
@Autowired
|
||||
public UserApiController(NativeWebRequest request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<NativeWebRequest> getRequest() {
|
||||
return Optional.ofNullable(request);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.openapitools.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
/**
|
||||
* Home redirection to OpenAPI api documentation
|
||||
*/
|
||||
@Controller
|
||||
public class HomeController {
|
||||
|
||||
@RequestMapping("/")
|
||||
public String index() {
|
||||
return "redirect:swagger-ui.html";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package org.openapitools.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
|
||||
@Configuration
|
||||
public class SpringDocConfiguration {
|
||||
|
||||
@Bean(name = "org.openapitools.configuration.SpringDocConfiguration.apiInfo")
|
||||
OpenAPI apiInfo() {
|
||||
return new OpenAPI()
|
||||
.info(
|
||||
new Info()
|
||||
.title("OpenAPI Petstore")
|
||||
.description("This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.")
|
||||
.license(
|
||||
new License()
|
||||
.name("Apache-2.0")
|
||||
.url("https://www.apache.org/licenses/LICENSE-2.0.html")
|
||||
)
|
||||
.version("1.0.0")
|
||||
)
|
||||
.components(
|
||||
new Components()
|
||||
.addSecuritySchemes("petstore_auth", new SecurityScheme()
|
||||
.type(SecurityScheme.Type.OAUTH2)
|
||||
)
|
||||
.addSecuritySchemes("api_key", new SecurityScheme()
|
||||
.type(SecurityScheme.Type.APIKEY)
|
||||
.in(SecurityScheme.In.HEADER)
|
||||
.name("api_key")
|
||||
)
|
||||
)
|
||||
;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.hibernate.validator.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
*/
|
||||
@lombok.Getter
|
||||
@lombok.Setter
|
||||
@lombok.ToString
|
||||
@lombok.EqualsAndHashCode
|
||||
|
||||
@Schema(name = "Category", description = "A category for a pet")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Category {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
public Category id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Category name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.hibernate.validator.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
*/
|
||||
@lombok.Getter
|
||||
@lombok.Setter
|
||||
@lombok.ToString
|
||||
@lombok.EqualsAndHashCode
|
||||
|
||||
@Schema(name = "ApiResponse", description = "Describes the result of uploading an image resource")
|
||||
@JsonTypeName("ApiResponse")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class ModelApiResponse {
|
||||
|
||||
private Integer code;
|
||||
|
||||
private String type;
|
||||
|
||||
private String message;
|
||||
|
||||
public ModelApiResponse code(Integer code) {
|
||||
this.code = code;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ModelApiResponse type(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ModelApiResponse message(String message) {
|
||||
this.message = message;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,121 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.time.OffsetDateTime;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.hibernate.validator.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
*/
|
||||
@lombok.Getter
|
||||
@lombok.Setter
|
||||
@lombok.ToString
|
||||
@lombok.EqualsAndHashCode
|
||||
|
||||
@Schema(name = "Order", description = "An order for a pets from the pet store")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Order {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long petId;
|
||||
|
||||
private Integer quantity;
|
||||
|
||||
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
|
||||
private OffsetDateTime shipDate;
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
public enum StatusEnum {
|
||||
PLACED("placed"),
|
||||
|
||||
APPROVED("approved"),
|
||||
|
||||
DELIVERED("delivered");
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static StatusEnum fromValue(String value) {
|
||||
for (StatusEnum b : StatusEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
private StatusEnum status;
|
||||
|
||||
private Boolean complete = false;
|
||||
|
||||
public Order id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Order petId(Long petId) {
|
||||
this.petId = petId;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Order quantity(Integer quantity) {
|
||||
this.quantity = quantity;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Order shipDate(OffsetDateTime shipDate) {
|
||||
this.shipDate = shipDate;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Order status(StatusEnum status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Order complete(Boolean complete) {
|
||||
this.complete = complete;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,156 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.openapitools.model.Category;
|
||||
import org.openapitools.model.Tag;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.hibernate.validator.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
*/
|
||||
@lombok.Getter
|
||||
@lombok.Setter
|
||||
@lombok.ToString
|
||||
@lombok.EqualsAndHashCode
|
||||
|
||||
@Schema(name = "Pet", description = "A pet for sale in the pet store")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Pet {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Category category;
|
||||
|
||||
@lombok.NonNull
|
||||
private String name;
|
||||
|
||||
@lombok.NonNull
|
||||
@Valid
|
||||
private List<String> photoUrls = new ArrayList<>();
|
||||
|
||||
@Valid
|
||||
private List<@Valid Tag> tags;
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
public enum StatusEnum {
|
||||
AVAILABLE("available"),
|
||||
|
||||
PENDING("pending"),
|
||||
|
||||
SOLD("sold");
|
||||
|
||||
private String value;
|
||||
|
||||
StatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@JsonValue
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
public static StatusEnum fromValue(String value) {
|
||||
for (StatusEnum b : StatusEnum.values()) {
|
||||
if (b.value.equals(value)) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("Unexpected value '" + value + "'");
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private StatusEnum status;
|
||||
|
||||
public Pet() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with only required parameters
|
||||
*/
|
||||
public Pet(String name, List<String> photoUrls) {
|
||||
this.name = name;
|
||||
this.photoUrls = photoUrls;
|
||||
}
|
||||
|
||||
public Pet id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Pet category(Category category) {
|
||||
this.category = category;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Pet name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Pet photoUrls(List<String> photoUrls) {
|
||||
this.photoUrls = photoUrls;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Pet addPhotoUrlsItem(String photoUrlsItem) {
|
||||
if (this.photoUrls == null) {
|
||||
this.photoUrls = new ArrayList<>();
|
||||
}
|
||||
this.photoUrls.add(photoUrlsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Pet tags(List<@Valid Tag> tags) {
|
||||
this.tags = tags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Pet addTagsItem(Tag tagsItem) {
|
||||
if (this.tags == null) {
|
||||
this.tags = new ArrayList<>();
|
||||
}
|
||||
this.tags.add(tagsItem);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Pet status(StatusEnum status) {
|
||||
this.status = status;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.hibernate.validator.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
*/
|
||||
@lombok.Getter
|
||||
@lombok.Setter
|
||||
@lombok.ToString
|
||||
@lombok.EqualsAndHashCode
|
||||
|
||||
@Schema(name = "Tag", description = "A tag for a pet")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class Tag {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
public Tag id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Tag name(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,96 @@
|
||||
package org.openapitools.model;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Objects;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import org.openapitools.jackson.nullable.JsonNullable;
|
||||
import java.time.OffsetDateTime;
|
||||
import jakarta.validation.Valid;
|
||||
import jakarta.validation.constraints.*;
|
||||
import org.hibernate.validator.constraints.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
import jakarta.annotation.Generated;
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
*/
|
||||
@lombok.Getter
|
||||
@lombok.Setter
|
||||
@lombok.ToString
|
||||
@lombok.EqualsAndHashCode
|
||||
|
||||
@Schema(name = "User", description = "A User who is purchasing from the pet store")
|
||||
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
|
||||
public class User {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String username;
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
private String email;
|
||||
|
||||
private String password;
|
||||
|
||||
private String phone;
|
||||
|
||||
private Integer userStatus;
|
||||
|
||||
public User id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public User username(String username) {
|
||||
this.username = username;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public User firstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public User lastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public User email(String email) {
|
||||
this.email = email;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public User password(String password) {
|
||||
this.password = password;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public User phone(String phone) {
|
||||
this.phone = phone;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public User userStatus(Integer userStatus) {
|
||||
this.userStatus = userStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
server.port=8080
|
||||
spring.jackson.date-format=org.openapitools.RFC3339DateFormat
|
||||
spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS=false
|
@ -0,0 +1,880 @@
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
description: "This is a sample server Petstore server. For this sample, you can\
|
||||
\ use the api key `special-key` to test the authorization filters."
|
||||
license:
|
||||
name: Apache-2.0
|
||||
url: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
title: OpenAPI Petstore
|
||||
version: 1.0.0
|
||||
externalDocs:
|
||||
description: Find out more about Swagger
|
||||
url: http://swagger.io
|
||||
servers:
|
||||
- url: http://petstore.swagger.io/v2
|
||||
tags:
|
||||
- description: Everything about your Pets
|
||||
name: pet
|
||||
- description: Access to Petstore orders
|
||||
name: store
|
||||
- description: Operations about user
|
||||
name: user
|
||||
paths:
|
||||
/pet:
|
||||
post:
|
||||
description: ""
|
||||
operationId: addPet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
"405":
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Add a new pet to the store
|
||||
tags:
|
||||
- pet
|
||||
x-content-type: application/json
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: pet
|
||||
put:
|
||||
description: ""
|
||||
externalDocs:
|
||||
description: API documentation for the updatePet operation
|
||||
url: http://petstore.swagger.io/v2/doc/updatePet
|
||||
operationId: updatePet
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/Pet'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Pet not found
|
||||
"405":
|
||||
description: Validation exception
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Update an existing pet
|
||||
tags:
|
||||
- pet
|
||||
x-content-type: application/json
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: pet
|
||||
/pet/findByStatus:
|
||||
get:
|
||||
description: Multiple status values can be provided with comma separated strings
|
||||
operationId: findPetsByStatus
|
||||
parameters:
|
||||
- deprecated: true
|
||||
description: Status values that need to be considered for filter
|
||||
explode: false
|
||||
in: query
|
||||
name: status
|
||||
required: true
|
||||
schema:
|
||||
items:
|
||||
default: available
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
type: string
|
||||
type: array
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid status value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- read:pets
|
||||
summary: Finds Pets by status
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: pet
|
||||
/pet/findByTags:
|
||||
get:
|
||||
deprecated: true
|
||||
description: "Multiple tags can be provided with comma separated strings. Use\
|
||||
\ tag1, tag2, tag3 for testing."
|
||||
operationId: findPetsByTags
|
||||
parameters:
|
||||
- description: Tags to filter by
|
||||
explode: false
|
||||
in: query
|
||||
name: tags
|
||||
required: true
|
||||
schema:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
type: array
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid tag value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- read:pets
|
||||
summary: Finds Pets by tags
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: pet
|
||||
/pet/{petId}:
|
||||
delete:
|
||||
description: ""
|
||||
operationId: deletePet
|
||||
parameters:
|
||||
- explode: false
|
||||
in: header
|
||||
name: api_key
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
- description: Pet id to delete
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid pet value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Deletes a pet
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: pet
|
||||
get:
|
||||
description: Returns a single pet
|
||||
operationId: getPetById
|
||||
parameters:
|
||||
- description: ID of pet to return
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Pet not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Find pet by ID
|
||||
tags:
|
||||
- pet
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: pet
|
||||
post:
|
||||
description: ""
|
||||
operationId: updatePetWithForm
|
||||
parameters:
|
||||
- description: ID of pet that needs to be updated
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
requestBody:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
$ref: '#/components/schemas/updatePetWithForm_request'
|
||||
responses:
|
||||
"405":
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Updates a pet in the store with form data
|
||||
tags:
|
||||
- pet
|
||||
x-content-type: application/x-www-form-urlencoded
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: pet
|
||||
/pet/{petId}/uploadImage:
|
||||
post:
|
||||
description: ""
|
||||
operationId: uploadFile
|
||||
parameters:
|
||||
- description: ID of pet to update
|
||||
explode: false
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
style: simple
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
$ref: '#/components/schemas/uploadFile_request'
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ApiResponse'
|
||||
description: successful operation
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: uploads an image
|
||||
tags:
|
||||
- pet
|
||||
x-content-type: multipart/form-data
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: pet
|
||||
/store/inventory:
|
||||
get:
|
||||
description: Returns a map of status codes to quantities
|
||||
operationId: getInventory
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
additionalProperties:
|
||||
format: int32
|
||||
type: integer
|
||||
type: object
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Returns pet inventories by status
|
||||
tags:
|
||||
- store
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: store
|
||||
/store/order:
|
||||
post:
|
||||
description: ""
|
||||
operationId: placeOrder
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: order placed for purchasing the pet
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid Order
|
||||
summary: Place an order for a pet
|
||||
tags:
|
||||
- store
|
||||
x-content-type: application/json
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: store
|
||||
/store/order/{orderId}:
|
||||
delete:
|
||||
description: For valid response try integer IDs with value < 1000. Anything
|
||||
above 1000 or nonintegers will generate API errors
|
||||
operationId: deleteOrder
|
||||
parameters:
|
||||
- description: ID of the order that needs to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: orderId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Order not found
|
||||
summary: Delete purchase order by ID
|
||||
tags:
|
||||
- store
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: store
|
||||
get:
|
||||
description: For valid response try integer IDs with value <= 5 or > 10. Other
|
||||
values will generate exceptions
|
||||
operationId: getOrderById
|
||||
parameters:
|
||||
- description: ID of pet that needs to be fetched
|
||||
explode: false
|
||||
in: path
|
||||
name: orderId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
maximum: 5
|
||||
minimum: 1
|
||||
type: integer
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
description: Order not found
|
||||
summary: Find purchase order by ID
|
||||
tags:
|
||||
- store
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: store
|
||||
/user:
|
||||
post:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: createUser
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: Created user object
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Create user
|
||||
tags:
|
||||
- user
|
||||
x-content-type: application/json
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
/user/createWithArray:
|
||||
post:
|
||||
description: ""
|
||||
operationId: createUsersWithArrayInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Creates list of users with given input array
|
||||
tags:
|
||||
- user
|
||||
x-content-type: application/json
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
/user/createWithList:
|
||||
post:
|
||||
description: ""
|
||||
operationId: createUsersWithListInput
|
||||
requestBody:
|
||||
$ref: '#/components/requestBodies/UserArray'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Creates list of users with given input array
|
||||
tags:
|
||||
- user
|
||||
x-content-type: application/json
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
/user/login:
|
||||
get:
|
||||
description: ""
|
||||
operationId: loginUser
|
||||
parameters:
|
||||
- description: The user name for login
|
||||
explode: true
|
||||
in: query
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$"
|
||||
type: string
|
||||
style: form
|
||||
- description: The password for login in clear text
|
||||
explode: true
|
||||
in: query
|
||||
name: password
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: form
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: string
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
description: successful operation
|
||||
headers:
|
||||
Set-Cookie:
|
||||
description: Cookie authentication key for use with the `api_key` apiKey
|
||||
authentication.
|
||||
explode: false
|
||||
schema:
|
||||
example: AUTH_KEY=abcde12345; Path=/; HttpOnly
|
||||
type: string
|
||||
style: simple
|
||||
X-Rate-Limit:
|
||||
description: calls per hour allowed by the user
|
||||
explode: false
|
||||
schema:
|
||||
format: int32
|
||||
type: integer
|
||||
style: simple
|
||||
X-Expires-After:
|
||||
description: date in UTC when token expires
|
||||
explode: false
|
||||
schema:
|
||||
format: date-time
|
||||
type: string
|
||||
style: simple
|
||||
"400":
|
||||
description: Invalid username/password supplied
|
||||
summary: Logs user into the system
|
||||
tags:
|
||||
- user
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: user
|
||||
/user/logout:
|
||||
get:
|
||||
description: ""
|
||||
operationId: logoutUser
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Logs out current logged in user session
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
/user/{username}:
|
||||
delete:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: deleteUser
|
||||
parameters:
|
||||
- description: The name that needs to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid username supplied
|
||||
"404":
|
||||
description: User not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Delete user
|
||||
tags:
|
||||
- user
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
get:
|
||||
description: ""
|
||||
operationId: getUserByName
|
||||
parameters:
|
||||
- description: The name that needs to be fetched. Use user1 for testing.
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: successful operation
|
||||
"400":
|
||||
description: Invalid username supplied
|
||||
"404":
|
||||
description: User not found
|
||||
summary: Get user by user name
|
||||
tags:
|
||||
- user
|
||||
x-accepts: "application/json,application/xml"
|
||||
x-tags:
|
||||
- tag: user
|
||||
put:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: updateUser
|
||||
parameters:
|
||||
- description: name that need to be deleted
|
||||
explode: false
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
style: simple
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: Updated user object
|
||||
required: true
|
||||
responses:
|
||||
"400":
|
||||
description: Invalid user supplied
|
||||
"404":
|
||||
description: User not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Updated user
|
||||
tags:
|
||||
- user
|
||||
x-content-type: application/json
|
||||
x-accepts: application/json
|
||||
x-tags:
|
||||
- tag: user
|
||||
components:
|
||||
requestBodies:
|
||||
UserArray:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
type: array
|
||||
description: List of user object
|
||||
required: true
|
||||
Pet:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: Pet object that needs to be added to the store
|
||||
required: true
|
||||
schemas:
|
||||
Order:
|
||||
description: An order for a pets from the pet store
|
||||
example:
|
||||
petId: 6
|
||||
quantity: 1
|
||||
id: 0
|
||||
shipDate: 2000-01-23T04:56:07.000+00:00
|
||||
complete: false
|
||||
status: placed
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
petId:
|
||||
format: int64
|
||||
type: integer
|
||||
quantity:
|
||||
format: int32
|
||||
type: integer
|
||||
shipDate:
|
||||
format: date-time
|
||||
type: string
|
||||
status:
|
||||
description: Order Status
|
||||
enum:
|
||||
- placed
|
||||
- approved
|
||||
- delivered
|
||||
type: string
|
||||
complete:
|
||||
default: false
|
||||
type: boolean
|
||||
title: Pet Order
|
||||
type: object
|
||||
xml:
|
||||
name: Order
|
||||
Category:
|
||||
description: A category for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 6
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
name:
|
||||
pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$"
|
||||
type: string
|
||||
title: Pet category
|
||||
type: object
|
||||
xml:
|
||||
name: Category
|
||||
User:
|
||||
description: A User who is purchasing from the pet store
|
||||
example:
|
||||
firstName: firstName
|
||||
lastName: lastName
|
||||
password: password
|
||||
userStatus: 6
|
||||
phone: phone
|
||||
id: 0
|
||||
email: email
|
||||
username: username
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
username:
|
||||
type: string
|
||||
firstName:
|
||||
type: string
|
||||
lastName:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
phone:
|
||||
type: string
|
||||
userStatus:
|
||||
description: User Status
|
||||
format: int32
|
||||
type: integer
|
||||
title: a User
|
||||
type: object
|
||||
xml:
|
||||
name: User
|
||||
Tag:
|
||||
description: A tag for a pet
|
||||
example:
|
||||
name: name
|
||||
id: 1
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
name:
|
||||
type: string
|
||||
title: Pet Tag
|
||||
type: object
|
||||
xml:
|
||||
name: Tag
|
||||
Pet:
|
||||
description: A pet for sale in the pet store
|
||||
example:
|
||||
photoUrls:
|
||||
- photoUrls
|
||||
- photoUrls
|
||||
name: doggie
|
||||
id: 0
|
||||
category:
|
||||
name: name
|
||||
id: 6
|
||||
tags:
|
||||
- name: name
|
||||
id: 1
|
||||
- name: name
|
||||
id: 1
|
||||
status: available
|
||||
properties:
|
||||
id:
|
||||
format: int64
|
||||
type: integer
|
||||
category:
|
||||
$ref: '#/components/schemas/Category'
|
||||
name:
|
||||
example: doggie
|
||||
type: string
|
||||
photoUrls:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
xml:
|
||||
name: photoUrl
|
||||
wrapped: true
|
||||
tags:
|
||||
items:
|
||||
$ref: '#/components/schemas/Tag'
|
||||
type: array
|
||||
xml:
|
||||
name: tag
|
||||
wrapped: true
|
||||
status:
|
||||
deprecated: true
|
||||
description: pet status in the store
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
- photoUrls
|
||||
title: a Pet
|
||||
type: object
|
||||
xml:
|
||||
name: Pet
|
||||
ApiResponse:
|
||||
description: Describes the result of uploading an image resource
|
||||
example:
|
||||
code: 0
|
||||
type: type
|
||||
message: message
|
||||
properties:
|
||||
code:
|
||||
format: int32
|
||||
type: integer
|
||||
type:
|
||||
type: string
|
||||
message:
|
||||
type: string
|
||||
title: An uploaded response
|
||||
type: object
|
||||
updatePetWithForm_request:
|
||||
properties:
|
||||
name:
|
||||
description: Updated name of the pet
|
||||
type: string
|
||||
status:
|
||||
description: Updated status of the pet
|
||||
type: string
|
||||
type: object
|
||||
uploadFile_request:
|
||||
properties:
|
||||
additionalMetadata:
|
||||
description: Additional data to pass to server
|
||||
type: string
|
||||
file:
|
||||
description: file to upload
|
||||
format: binary
|
||||
type: string
|
||||
type: object
|
||||
securitySchemes:
|
||||
petstore_auth:
|
||||
flows:
|
||||
implicit:
|
||||
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
|
||||
scopes:
|
||||
write:pets: modify pets in your account
|
||||
read:pets: read your pets
|
||||
type: oauth2
|
||||
api_key:
|
||||
in: header
|
||||
name: api_key
|
||||
type: apiKey
|
@ -0,0 +1,13 @@
|
||||
package org.openapitools;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
class OpenApiGeneratorApplicationTests {
|
||||
|
||||
@Test
|
||||
void contextLoads() {
|
||||
}
|
||||
|
||||
}
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -26,6 +26,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
@ -25,6 +25,8 @@
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
Loading…
x
Reference in New Issue
Block a user