mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-05 08:06:10 +00:00
move openapi 3 samples to the correct folder (#3267)
This commit is contained in:
@@ -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 @@
|
||||
4.0.1-SNAPSHOT
|
||||
@@ -0,0 +1,21 @@
|
||||
# openAPIPetstore
|
||||
|
||||
This Kotlin based [Spring Boot](https://spring.io/projects/spring-boot) application has been generated using the [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator).
|
||||
|
||||
## Getting Started
|
||||
|
||||
This document assumes you have either maven or gradle available, either via the wrapper or otherwise. This does not come with a gradle / maven wrapper checked in.
|
||||
|
||||
By default a [`pom.xml`](pom.xml) file will be generated. If you specified `gradleBuildFile=true` when generating this project, a `build.gradle.kts` will also be generated. Note this uses [Gradle Kotlin DSL](https://github.com/gradle/kotlin-dsl).
|
||||
|
||||
To build the project using maven, run:
|
||||
```bash
|
||||
mvn package && java -jar target/openapi-spring-1.0.0.jar
|
||||
```
|
||||
|
||||
To build the project using gradle, run:
|
||||
```bash
|
||||
gradle build && java -jar build/libs/openapi-spring-1.0.0.jar
|
||||
```
|
||||
|
||||
If all builds successfully, the server should run on [http://localhost:8080/](http://localhost:8080/)
|
||||
@@ -0,0 +1,55 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.0.M3")
|
||||
}
|
||||
}
|
||||
|
||||
group = "org.openapitools"
|
||||
version = "1.0.0"
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
plugins {
|
||||
val kotlinVersion = "1.3.30"
|
||||
id("org.jetbrains.kotlin.jvm") version kotlinVersion
|
||||
id("org.jetbrains.kotlin.plugin.jpa") version kotlinVersion
|
||||
id("org.jetbrains.kotlin.plugin.spring") version kotlinVersion
|
||||
id("org.springframework.boot") version "2.2.0.M3"
|
||||
id("io.spring.dependency-management") version "1.0.5.RELEASE"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
val kotlinxCoroutinesVersion="1.2.0"
|
||||
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
compile("org.jetbrains.kotlin:kotlin-reflect")
|
||||
compile("org.springframework.boot:spring-boot-starter-webflux")
|
||||
compile("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
|
||||
compile("org.jetbrains.kotlinx:kotlinx-coroutines-reactor:$kotlinxCoroutinesVersion")
|
||||
compile("io.swagger:swagger-annotations:1.5.21")
|
||||
compile("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
|
||||
compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
|
||||
compile("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||
|
||||
testCompile("org.springframework.boot:spring-boot-starter-test") {
|
||||
exclude(module = "junit")
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo.spring.io/snapshot") }
|
||||
maven { url = uri("https://repo.spring.io/milestone") }
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
<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</groupId>
|
||||
<artifactId>openapi-spring</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>openapi-spring</name>
|
||||
<version>1.0.0</version>
|
||||
<properties>
|
||||
<kotlin.version>1.3.30</kotlin.version>
|
||||
<kotlinx-coroutines.version>1.2.0</kotlinx-coroutines.version>
|
||||
</properties>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.2.0.M3</version>
|
||||
</parent>
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${kotlin.version}</version>
|
||||
<configuration>
|
||||
<compilerPlugins>
|
||||
<plugin>spring</plugin>
|
||||
</compilerPlugins>
|
||||
<jvmTarget>1.8</jvmTarget>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-allopen</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-reflect</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-coroutines-core</artifactId>
|
||||
<version>${kotlinx-coroutines.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlinx</groupId>
|
||||
<artifactId>kotlinx-coroutines-reactor</artifactId>
|
||||
<version>${kotlinx-coroutines.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.swagger</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>1.5.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-yaml</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
<artifactId>jackson-module-kotlin</artifactId>
|
||||
</dependency>
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</project>
|
||||
@@ -0,0 +1,15 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven { url = uri("https://repo.spring.io/snapshot") }
|
||||
maven { url = uri("https://repo.spring.io/milestone") }
|
||||
gradlePluginPortal()
|
||||
}
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.id == "org.springframework.boot") {
|
||||
useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rootProject.name = "openapi-spring"
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.openapitools
|
||||
|
||||
import org.springframework.boot.runApplication
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"])
|
||||
class Application
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<Application>(*args)
|
||||
}
|
||||
@@ -0,0 +1,186 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.ModelApiResponse
|
||||
import org.openapitools.model.Pet
|
||||
import io.swagger.annotations.Api
|
||||
import io.swagger.annotations.ApiOperation
|
||||
import io.swagger.annotations.ApiParam
|
||||
import io.swagger.annotations.ApiResponse
|
||||
import io.swagger.annotations.ApiResponses
|
||||
import io.swagger.annotations.Authorization
|
||||
import io.swagger.annotations.AuthorizationScope
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.http.ResponseEntity
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestPart
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.RequestHeader
|
||||
import org.springframework.web.bind.annotation.RequestMethod
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import org.springframework.validation.annotation.Validated
|
||||
import org.springframework.web.context.request.NativeWebRequest
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
|
||||
import javax.validation.Valid
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
import kotlin.collections.List
|
||||
import kotlin.collections.Map
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
@Api(value = "Pet", description = "The Pet API")
|
||||
@RequestMapping("\${api.base-path:/v2}")
|
||||
class PetApiController(@Autowired(required = true) val service: PetApiService) {
|
||||
|
||||
@ApiOperation(
|
||||
value = "Add a new pet to the store",
|
||||
nickname = "addPet",
|
||||
notes = "",
|
||||
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 405, message = "Invalid input")])
|
||||
@RequestMapping(
|
||||
value = ["/pet"],
|
||||
consumes = ["application/json", "application/xml"],
|
||||
method = [RequestMethod.POST])
|
||||
suspend fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet
|
||||
): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.addPet(pet), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Deletes a pet",
|
||||
nickname = "deletePet",
|
||||
notes = "",
|
||||
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 400, message = "Invalid pet value")])
|
||||
@RequestMapping(
|
||||
value = ["/pet/{petId}"],
|
||||
method = [RequestMethod.DELETE])
|
||||
suspend fun deletePet(@ApiParam(value = "Pet id to delete", required=true) @PathVariable("petId") petId: Long
|
||||
,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) apiKey: String?
|
||||
): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Finds Pets by status",
|
||||
nickname = "findPetsByStatus",
|
||||
notes = "Multiple status values can be provided with comma separated strings",
|
||||
response = Pet::class,
|
||||
responseContainer = "List",
|
||||
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "read:pets", description = "read your pets")])])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"),ApiResponse(code = 400, message = "Invalid status value")])
|
||||
@RequestMapping(
|
||||
value = ["/pet/findByStatus"],
|
||||
produces = ["application/xml", "application/json"],
|
||||
method = [RequestMethod.GET])
|
||||
fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) status: List<String>
|
||||
): ResponseEntity<Flow<Pet>> {
|
||||
return ResponseEntity(service.findPetsByStatus(status), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Finds Pets by tags",
|
||||
nickname = "findPetsByTags",
|
||||
notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
|
||||
response = Pet::class,
|
||||
responseContainer = "List",
|
||||
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "read:pets", description = "read your pets")])])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"),ApiResponse(code = 400, message = "Invalid tag value")])
|
||||
@RequestMapping(
|
||||
value = ["/pet/findByTags"],
|
||||
produces = ["application/xml", "application/json"],
|
||||
method = [RequestMethod.GET])
|
||||
fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: List<String>
|
||||
,@ApiParam(value = "Maximum number of items to return") @Valid @RequestParam(value = "maxCount", required = false) maxCount: Int?
|
||||
): ResponseEntity<Flow<Pet>> {
|
||||
return ResponseEntity(service.findPetsByTags(tags, maxCount), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Find pet by ID",
|
||||
nickname = "getPetById",
|
||||
notes = "Returns a single pet",
|
||||
response = Pet::class,
|
||||
authorizations = [Authorization(value = "api_key")])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Pet not found")])
|
||||
@RequestMapping(
|
||||
value = ["/pet/{petId}"],
|
||||
produces = ["application/xml", "application/json"],
|
||||
method = [RequestMethod.GET])
|
||||
suspend fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: Long
|
||||
): ResponseEntity<Pet> {
|
||||
return ResponseEntity(service.getPetById(petId), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Update an existing pet",
|
||||
nickname = "updatePet",
|
||||
notes = "",
|
||||
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Pet not found"),ApiResponse(code = 405, message = "Validation exception")])
|
||||
@RequestMapping(
|
||||
value = ["/pet"],
|
||||
consumes = ["application/json", "application/xml"],
|
||||
method = [RequestMethod.PUT])
|
||||
suspend fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet
|
||||
): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.updatePet(pet), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Updates a pet in the store with form data",
|
||||
nickname = "updatePetWithForm",
|
||||
notes = "",
|
||||
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 405, message = "Invalid input")])
|
||||
@RequestMapping(
|
||||
value = ["/pet/{petId}"],
|
||||
consumes = ["application/x-www-form-urlencoded"],
|
||||
method = [RequestMethod.POST])
|
||||
suspend fun updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated", required=true) @PathVariable("petId") petId: Long
|
||||
,@ApiParam(value = "Updated name of the pet") @RequestParam(value="name", required=false) name: String?
|
||||
,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) status: String?
|
||||
): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "uploads an image",
|
||||
nickname = "uploadFile",
|
||||
notes = "",
|
||||
response = ModelApiResponse::class,
|
||||
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse::class)])
|
||||
@RequestMapping(
|
||||
value = ["/pet/{petId}/uploadImage"],
|
||||
produces = ["application/json"],
|
||||
consumes = ["multipart/form-data"],
|
||||
method = [RequestMethod.POST])
|
||||
suspend fun uploadFile(@ApiParam(value = "ID of pet to update", required=true) @PathVariable("petId") petId: Long
|
||||
,@ApiParam(value = "Additional data to pass to server") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: String?
|
||||
,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource?
|
||||
): ResponseEntity<ModelApiResponse> {
|
||||
return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.ModelApiResponse
|
||||
import org.openapitools.model.Pet
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
interface PetApiService {
|
||||
|
||||
suspend fun addPet(pet: Pet): Unit
|
||||
|
||||
suspend fun deletePet(petId: Long, apiKey: String?): Unit
|
||||
|
||||
fun findPetsByStatus(status: List<String>): Flow<Pet>
|
||||
|
||||
fun findPetsByTags(tags: List<String>, maxCount: Int?): Flow<Pet>
|
||||
|
||||
suspend fun getPetById(petId: Long): Pet
|
||||
|
||||
suspend fun updatePet(pet: Pet): Unit
|
||||
|
||||
suspend fun updatePetWithForm(petId: Long, name: String?, status: String?): Unit
|
||||
|
||||
suspend fun uploadFile(petId: Long, additionalMetadata: String?, file: org.springframework.core.io.Resource?): ModelApiResponse
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.ModelApiResponse
|
||||
import org.openapitools.model.Pet
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
import org.springframework.stereotype.Service
|
||||
@Service
|
||||
class PetApiServiceImpl : PetApiService {
|
||||
|
||||
override suspend fun addPet(pet: Pet): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun deletePet(petId: Long, apiKey: String?): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun findPetsByStatus(status: List<String>): Flow<Pet> {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun findPetsByTags(tags: List<String>, maxCount: Int?): Flow<Pet> {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun getPetById(petId: Long): Pet {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun updatePet(pet: Pet): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun updatePetWithForm(petId: Long, name: String?, status: String?): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun uploadFile(petId: Long, additionalMetadata: String?, file: org.springframework.core.io.Resource?): ModelApiResponse {
|
||||
TODO("Implement me")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.Order
|
||||
import io.swagger.annotations.Api
|
||||
import io.swagger.annotations.ApiOperation
|
||||
import io.swagger.annotations.ApiParam
|
||||
import io.swagger.annotations.ApiResponse
|
||||
import io.swagger.annotations.ApiResponses
|
||||
import io.swagger.annotations.Authorization
|
||||
import io.swagger.annotations.AuthorizationScope
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.http.ResponseEntity
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestPart
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.RequestHeader
|
||||
import org.springframework.web.bind.annotation.RequestMethod
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import org.springframework.validation.annotation.Validated
|
||||
import org.springframework.web.context.request.NativeWebRequest
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
|
||||
import javax.validation.Valid
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
import kotlin.collections.List
|
||||
import kotlin.collections.Map
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
@Api(value = "Store", description = "The Store API")
|
||||
@RequestMapping("\${api.base-path:/v2}")
|
||||
class StoreApiController(@Autowired(required = true) val service: StoreApiService) {
|
||||
|
||||
@ApiOperation(
|
||||
value = "Delete purchase order by ID",
|
||||
nickname = "deleteOrder",
|
||||
notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors")
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Order not found")])
|
||||
@RequestMapping(
|
||||
value = ["/store/order/{orderId}"],
|
||||
method = [RequestMethod.DELETE])
|
||||
suspend fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: String
|
||||
): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.deleteOrder(orderId), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Returns pet inventories by status",
|
||||
nickname = "getInventory",
|
||||
notes = "Returns a map of status codes to quantities",
|
||||
response = Int::class,
|
||||
responseContainer = "Map",
|
||||
authorizations = [Authorization(value = "api_key")])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation", response = Map::class, responseContainer = "Map")])
|
||||
@RequestMapping(
|
||||
value = ["/store/inventory"],
|
||||
produces = ["application/json"],
|
||||
method = [RequestMethod.GET])
|
||||
suspend fun getInventory(): ResponseEntity<Map<String, Int>> {
|
||||
return ResponseEntity(service.getInventory(), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Find purchase order by ID",
|
||||
nickname = "getOrderById",
|
||||
notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
|
||||
response = Order::class)
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Order not found")])
|
||||
@RequestMapping(
|
||||
value = ["/store/order/{orderId}"],
|
||||
produces = ["application/xml", "application/json"],
|
||||
method = [RequestMethod.GET])
|
||||
suspend fun getOrderById(@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required=true) @PathVariable("orderId") orderId: Long
|
||||
): ResponseEntity<Order> {
|
||||
return ResponseEntity(service.getOrderById(orderId), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Place an order for a pet",
|
||||
nickname = "placeOrder",
|
||||
notes = "",
|
||||
response = Order::class)
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid Order")])
|
||||
@RequestMapping(
|
||||
value = ["/store/order"],
|
||||
produces = ["application/xml", "application/json"],
|
||||
consumes = ["application/json"],
|
||||
method = [RequestMethod.POST])
|
||||
suspend fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody order: Order
|
||||
): ResponseEntity<Order> {
|
||||
return ResponseEntity(service.placeOrder(order), HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.Order
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
interface StoreApiService {
|
||||
|
||||
suspend fun deleteOrder(orderId: String): Unit
|
||||
|
||||
suspend fun getInventory(): Map<String, Int>
|
||||
|
||||
suspend fun getOrderById(orderId: Long): Order
|
||||
|
||||
suspend fun placeOrder(order: Order): Order
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.Order
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
import org.springframework.stereotype.Service
|
||||
@Service
|
||||
class StoreApiServiceImpl : StoreApiService {
|
||||
|
||||
override suspend fun deleteOrder(orderId: String): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun getInventory(): Map<String, Int> {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun getOrderById(orderId: Long): Order {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun placeOrder(order: Order): Order {
|
||||
TODO("Implement me")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.User
|
||||
import io.swagger.annotations.Api
|
||||
import io.swagger.annotations.ApiOperation
|
||||
import io.swagger.annotations.ApiParam
|
||||
import io.swagger.annotations.ApiResponse
|
||||
import io.swagger.annotations.ApiResponses
|
||||
import io.swagger.annotations.Authorization
|
||||
import io.swagger.annotations.AuthorizationScope
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.http.ResponseEntity
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestBody
|
||||
import org.springframework.web.bind.annotation.RequestPart
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
import org.springframework.web.bind.annotation.RequestHeader
|
||||
import org.springframework.web.bind.annotation.RequestMethod
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import org.springframework.validation.annotation.Validated
|
||||
import org.springframework.web.context.request.NativeWebRequest
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
|
||||
import javax.validation.Valid
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
import kotlin.collections.List
|
||||
import kotlin.collections.Map
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
@Api(value = "User", description = "The User API")
|
||||
@RequestMapping("\${api.base-path:/v2}")
|
||||
class UserApiController(@Autowired(required = true) val service: UserApiService) {
|
||||
|
||||
@ApiOperation(
|
||||
value = "Create user",
|
||||
nickname = "createUser",
|
||||
notes = "This can only be done by the logged in user.",
|
||||
authorizations = [Authorization(value = "auth_cookie")])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation")])
|
||||
@RequestMapping(
|
||||
value = ["/user"],
|
||||
consumes = ["application/json"],
|
||||
method = [RequestMethod.POST])
|
||||
suspend fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody user: User
|
||||
): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.createUser(user), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Creates list of users with given input array",
|
||||
nickname = "createUsersWithArrayInput",
|
||||
notes = "",
|
||||
authorizations = [Authorization(value = "auth_cookie")])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation")])
|
||||
@RequestMapping(
|
||||
value = ["/user/createWithArray"],
|
||||
consumes = ["application/json"],
|
||||
method = [RequestMethod.POST])
|
||||
suspend fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: Flow<User>
|
||||
): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.createUsersWithArrayInput(user), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Creates list of users with given input array",
|
||||
nickname = "createUsersWithListInput",
|
||||
notes = "",
|
||||
authorizations = [Authorization(value = "auth_cookie")])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation")])
|
||||
@RequestMapping(
|
||||
value = ["/user/createWithList"],
|
||||
consumes = ["application/json"],
|
||||
method = [RequestMethod.POST])
|
||||
suspend fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: Flow<User>
|
||||
): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.createUsersWithListInput(user), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Delete user",
|
||||
nickname = "deleteUser",
|
||||
notes = "This can only be done by the logged in user.",
|
||||
authorizations = [Authorization(value = "auth_cookie")])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")])
|
||||
@RequestMapping(
|
||||
value = ["/user/{username}"],
|
||||
method = [RequestMethod.DELETE])
|
||||
suspend fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true) @PathVariable("username") username: String
|
||||
): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.deleteUser(username), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Get user by user name",
|
||||
nickname = "getUserByName",
|
||||
notes = "",
|
||||
response = User::class)
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation", response = User::class),ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")])
|
||||
@RequestMapping(
|
||||
value = ["/user/{username}"],
|
||||
produces = ["application/xml", "application/json"],
|
||||
method = [RequestMethod.GET])
|
||||
suspend fun getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true) @PathVariable("username") username: String
|
||||
): ResponseEntity<User> {
|
||||
return ResponseEntity(service.getUserByName(username), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Logs user into the system",
|
||||
nickname = "loginUser",
|
||||
notes = "",
|
||||
response = String::class)
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation", response = String::class),ApiResponse(code = 400, message = "Invalid username/password supplied")])
|
||||
@RequestMapping(
|
||||
value = ["/user/login"],
|
||||
produces = ["application/xml", "application/json"],
|
||||
method = [RequestMethod.GET])
|
||||
suspend fun loginUser(@NotNull @Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: String
|
||||
,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: String
|
||||
): ResponseEntity<String> {
|
||||
return ResponseEntity(service.loginUser(username, password), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Logs out current logged in user session",
|
||||
nickname = "logoutUser",
|
||||
notes = "",
|
||||
authorizations = [Authorization(value = "auth_cookie")])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 200, message = "successful operation")])
|
||||
@RequestMapping(
|
||||
value = ["/user/logout"],
|
||||
method = [RequestMethod.GET])
|
||||
suspend fun logoutUser(): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.logoutUser(), HttpStatus.OK)
|
||||
}
|
||||
|
||||
@ApiOperation(
|
||||
value = "Updated user",
|
||||
nickname = "updateUser",
|
||||
notes = "This can only be done by the logged in user.",
|
||||
authorizations = [Authorization(value = "auth_cookie")])
|
||||
@ApiResponses(
|
||||
value = [ApiResponse(code = 400, message = "Invalid user supplied"),ApiResponse(code = 404, message = "User not found")])
|
||||
@RequestMapping(
|
||||
value = ["/user/{username}"],
|
||||
consumes = ["application/json"],
|
||||
method = [RequestMethod.PUT])
|
||||
suspend fun updateUser(@ApiParam(value = "name that need to be deleted", required=true) @PathVariable("username") username: String
|
||||
,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody user: User
|
||||
): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.updateUser(username, user), HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.User
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
interface UserApiService {
|
||||
|
||||
suspend fun createUser(user: User): Unit
|
||||
|
||||
suspend fun createUsersWithArrayInput(user: Flow<User>): Unit
|
||||
|
||||
suspend fun createUsersWithListInput(user: Flow<User>): Unit
|
||||
|
||||
suspend fun deleteUser(username: String): Unit
|
||||
|
||||
suspend fun getUserByName(username: String): User
|
||||
|
||||
suspend fun loginUser(username: String, password: String): String
|
||||
|
||||
suspend fun logoutUser(): Unit
|
||||
|
||||
suspend fun updateUser(username: String, user: User): Unit
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.User
|
||||
import kotlinx.coroutines.flow.Flow;
|
||||
import org.springframework.stereotype.Service
|
||||
@Service
|
||||
class UserApiServiceImpl : UserApiService {
|
||||
|
||||
override suspend fun createUser(user: User): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun createUsersWithArrayInput(user: Flow<User>): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun createUsersWithListInput(user: Flow<User>): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun deleteUser(username: String): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun getUserByName(username: String): User {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun loginUser(username: String, password: String): String {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun logoutUser(): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override suspend fun updateUser(username: String, user: User): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.openapitools.model
|
||||
|
||||
import java.util.Objects
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
import io.swagger.annotations.ApiModelProperty
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
data class Category (
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("id") val id: Long? = null,
|
||||
@get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("name") val name: String? = null
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.openapitools.model
|
||||
|
||||
import java.util.Objects
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
import io.swagger.annotations.ApiModelProperty
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name Updated name of the pet
|
||||
* @param status Updated status of the pet
|
||||
*/
|
||||
data class InlineObject (
|
||||
|
||||
@ApiModelProperty(example = "null", value = "Updated name of the pet")
|
||||
@JsonProperty("name") val name: String? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "Updated status of the pet")
|
||||
@JsonProperty("status") val status: String? = null
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.openapitools.model
|
||||
|
||||
import java.util.Objects
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
import io.swagger.annotations.ApiModelProperty
|
||||
|
||||
/**
|
||||
*
|
||||
* @param additionalMetadata Additional data to pass to server
|
||||
* @param file file to upload
|
||||
*/
|
||||
data class InlineObject1 (
|
||||
|
||||
@ApiModelProperty(example = "null", value = "Additional data to pass to server")
|
||||
@JsonProperty("additionalMetadata") val additionalMetadata: String? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "file to upload")
|
||||
@JsonProperty("file") val file: org.springframework.core.io.Resource? = null
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package org.openapitools.model
|
||||
|
||||
import java.util.Objects
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
import io.swagger.annotations.ApiModelProperty
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
* @param code
|
||||
* @param type
|
||||
* @param message
|
||||
*/
|
||||
data class ModelApiResponse (
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("code") val code: Int? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("type") val type: String? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("message") val message: String? = null
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.openapitools.model
|
||||
|
||||
import java.util.Objects
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.fasterxml.jackson.annotation.JsonValue
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
import io.swagger.annotations.ApiModelProperty
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
* @param id
|
||||
* @param petId
|
||||
* @param quantity
|
||||
* @param shipDate
|
||||
* @param status Order Status
|
||||
* @param complete
|
||||
*/
|
||||
data class Order (
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("id") val id: Long? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("petId") val petId: Long? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("quantity") val quantity: Int? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "Order Status")
|
||||
@JsonProperty("status") val status: Order.Status? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("complete") val complete: Boolean? = null
|
||||
) {
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
* Values: placed,approved,delivered
|
||||
*/
|
||||
enum class Status(val value: String) {
|
||||
|
||||
@JsonProperty("placed") placed("placed"),
|
||||
|
||||
@JsonProperty("approved") approved("approved"),
|
||||
|
||||
@JsonProperty("delivered") delivered("delivered");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.openapitools.model
|
||||
|
||||
import java.util.Objects
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.fasterxml.jackson.annotation.JsonValue
|
||||
import org.openapitools.model.Category
|
||||
import org.openapitools.model.Tag
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
import io.swagger.annotations.ApiModelProperty
|
||||
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
* @param id
|
||||
* @param category
|
||||
* @param name
|
||||
* @param photoUrls
|
||||
* @param tags
|
||||
* @param status pet status in the store
|
||||
*/
|
||||
data class Pet (
|
||||
|
||||
@get:NotNull
|
||||
@ApiModelProperty(example = "doggie", required = true, value = "")
|
||||
@JsonProperty("name") val name: String,
|
||||
|
||||
@get:NotNull
|
||||
@ApiModelProperty(example = "null", required = true, value = "")
|
||||
@JsonProperty("photoUrls") val photoUrls: List<String>,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("id") val id: Long? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("category") val category: Category? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("tags") val tags: List<Tag>? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "pet status in the store")
|
||||
@JsonProperty("status") val status: Pet.Status? = null
|
||||
) {
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
* Values: available,pending,sold
|
||||
*/
|
||||
enum class Status(val value: String) {
|
||||
|
||||
@JsonProperty("available") available("available"),
|
||||
|
||||
@JsonProperty("pending") pending("pending"),
|
||||
|
||||
@JsonProperty("sold") sold("sold");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.openapitools.model
|
||||
|
||||
import java.util.Objects
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
import io.swagger.annotations.ApiModelProperty
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
data class Tag (
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("id") val id: Long? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("name") val name: String? = null
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.openapitools.model
|
||||
|
||||
import java.util.Objects
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import javax.validation.constraints.DecimalMax
|
||||
import javax.validation.constraints.DecimalMin
|
||||
import javax.validation.constraints.Max
|
||||
import javax.validation.constraints.Min
|
||||
import javax.validation.constraints.NotNull
|
||||
import javax.validation.constraints.Pattern
|
||||
import javax.validation.constraints.Size
|
||||
import io.swagger.annotations.ApiModelProperty
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
* @param id
|
||||
* @param username
|
||||
* @param firstName
|
||||
* @param lastName
|
||||
* @param email
|
||||
* @param password
|
||||
* @param phone
|
||||
* @param userStatus User Status
|
||||
*/
|
||||
data class User (
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("id") val id: Long? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("username") val username: String? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("firstName") val firstName: String? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("lastName") val lastName: String? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("email") val email: String? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("password") val password: String? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "")
|
||||
@JsonProperty("phone") val phone: String? = null,
|
||||
|
||||
@ApiModelProperty(example = "null", value = "User Status")
|
||||
@JsonProperty("userStatus") val userStatus: Int? = null
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
spring:
|
||||
application:
|
||||
name: openAPIPetstore
|
||||
|
||||
jackson:
|
||||
serialization:
|
||||
WRITE_DATES_AS_TIMESTAMPS: false
|
||||
|
||||
server:
|
||||
port: 8080
|
||||
Reference in New Issue
Block a user