forked from loafle/openapi-generator-original
[kotlin-spring] Adding DocumentationProvider and SwaggerUI (#12184)
* Adding DocumentationProvider and SwaggerUI to Kotlin Spring * Fixing annotation errors * Fixes to homeController * Minor stylistic fixes * Removing parameter from docs * Structuring pom, making gradle file similar to pom * Updating samples
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,26 @@
|
||||
README.md
|
||||
build.gradle.kts
|
||||
pom.xml
|
||||
settings.gradle
|
||||
src/main/kotlin/org/openapitools/Application.kt
|
||||
src/main/kotlin/org/openapitools/HomeController.kt
|
||||
src/main/kotlin/org/openapitools/api/ApiUtil.kt
|
||||
src/main/kotlin/org/openapitools/api/Exceptions.kt
|
||||
src/main/kotlin/org/openapitools/api/PetApiController.kt
|
||||
src/main/kotlin/org/openapitools/api/PetApiService.kt
|
||||
src/main/kotlin/org/openapitools/api/PetApiServiceImpl.kt
|
||||
src/main/kotlin/org/openapitools/api/StoreApiController.kt
|
||||
src/main/kotlin/org/openapitools/api/StoreApiService.kt
|
||||
src/main/kotlin/org/openapitools/api/StoreApiServiceImpl.kt
|
||||
src/main/kotlin/org/openapitools/api/UserApiController.kt
|
||||
src/main/kotlin/org/openapitools/api/UserApiService.kt
|
||||
src/main/kotlin/org/openapitools/api/UserApiServiceImpl.kt
|
||||
src/main/kotlin/org/openapitools/model/Category.kt
|
||||
src/main/kotlin/org/openapitools/model/ModelApiResponse.kt
|
||||
src/main/kotlin/org/openapitools/model/Order.kt
|
||||
src/main/kotlin/org/openapitools/model/Pet.kt
|
||||
src/main/kotlin/org/openapitools/model/Tag.kt
|
||||
src/main/kotlin/org/openapitools/model/User.kt
|
||||
src/main/resources/application.yaml
|
||||
src/main/resources/openapi.yaml
|
||||
src/main/resources/static/swagger-ui.html
|
||||
@@ -0,0 +1 @@
|
||||
6.0.0-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,58 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.2.0.M3")
|
||||
}
|
||||
}
|
||||
|
||||
group = "org.openapitools"
|
||||
version = "1.0.0"
|
||||
|
||||
repositories {
|
||||
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 {
|
||||
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
compile("org.jetbrains.kotlin:kotlin-reflect")
|
||||
compile("org.springframework.boot:spring-boot-starter-web")
|
||||
compile("org.webjars:swagger-ui:4.8.1")
|
||||
compile("org.webjars:webjars-locator-core")
|
||||
compile("io.swagger.core.v3:swagger-annotations:2.1.13")
|
||||
|
||||
compile("com.google.code.findbugs:jsr305:3.0.2")
|
||||
compile("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml")
|
||||
compile("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
|
||||
compile("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
|
||||
compile("com.fasterxml.jackson.module:jackson-module-kotlin")
|
||||
compile("jakarta.validation:jakarta.validation-api")
|
||||
compile("jakarta.annotation:jakarta.annotation-api:1.3.5")
|
||||
|
||||
testCompile("org.jetbrains.kotlin:kotlin-test-junit5")
|
||||
testCompile("org.springframework.boot:spring-boot-starter-test") {
|
||||
exclude(module = "junit")
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url = uri("https://repo1.maven.org/maven2") }
|
||||
maven { url = uri("https://repo.spring.io/snapshot") }
|
||||
maven { url = uri("https://repo.spring.io/milestone") }
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
<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>
|
||||
<swagger-ui.version>4.8.1</swagger-ui.version>
|
||||
<swagger-annotations.version>2.1.13</swagger-annotations.version>
|
||||
<findbugs-jsr305.version>3.0.2</findbugs-jsr305.version>
|
||||
<jakarta-annotation.version>1.3.5</jakarta-annotation.version>
|
||||
<kotlin-test-junit5.version>1.3.31</kotlin-test-junit5.version>
|
||||
|
||||
<kotlin.version>1.3.30</kotlin.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</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-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>swagger-ui</artifactId>
|
||||
<version>${swagger-ui.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.webjars</groupId>
|
||||
<artifactId>webjars-locator-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations</artifactId>
|
||||
<version>${swagger-annotations.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- @Nullable annotation -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
<version>${findbugs-jsr305.version}</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>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jakarta.annotation</groupId>
|
||||
<artifactId>jakarta.annotation-api</artifactId>
|
||||
<version>${jakarta-annotation.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test-junit5</artifactId>
|
||||
<version>${kotlin-test-junit5.version}</version>
|
||||
<scope>test</scope>
|
||||
</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,13 @@
|
||||
package org.openapitools
|
||||
|
||||
import org.springframework.boot.runApplication
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.context.annotation.ComponentScan
|
||||
|
||||
@SpringBootApplication
|
||||
@ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"])
|
||||
class Application
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<Application>(*args)
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package org.openapitools
|
||||
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.stereotype.Controller
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.core.io.Resource
|
||||
import org.springframework.util.StreamUtils
|
||||
import org.springframework.web.bind.annotation.ResponseBody
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import java.nio.charset.Charset
|
||||
|
||||
/**
|
||||
* Home redirection to OpenAPI api documentation
|
||||
*/
|
||||
@Controller
|
||||
class HomeController {
|
||||
private val apiDocsPath = "/openapi.json"
|
||||
private val yamlMapper = YAMLMapper()
|
||||
|
||||
@Value("classpath:/openapi.yaml")
|
||||
private lateinit var openapi: Resource
|
||||
|
||||
@Bean
|
||||
fun openapiContent(): String {
|
||||
return openapi.inputStream.use {
|
||||
StreamUtils.copyToString(it, Charset.defaultCharset())
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping(value = ["/openapi.yaml"], produces = ["application/vnd.oai.openapi"])
|
||||
@ResponseBody
|
||||
fun openapiYaml(): String = openapiContent()
|
||||
|
||||
@GetMapping(value = ["/openapi.json"], produces = ["application/json"])
|
||||
@ResponseBody
|
||||
fun openapiJson(): Any = yamlMapper.readValue(openapiContent(), Any::class.java)
|
||||
|
||||
@GetMapping(value = ["/swagger-config.yaml"], produces = ["text/plain"])
|
||||
@ResponseBody
|
||||
fun swaggerConfig(): String = "url: $apiDocsPath\n"
|
||||
|
||||
@RequestMapping("/")
|
||||
fun index(): String = "redirect:swagger-ui.html"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.springframework.web.context.request.NativeWebRequest
|
||||
|
||||
import javax.servlet.http.HttpServletResponse
|
||||
import java.io.IOException
|
||||
|
||||
object ApiUtil {
|
||||
fun setExampleResponse(req: NativeWebRequest, contentType: String, example: String) {
|
||||
try {
|
||||
val res = req.getNativeResponse(HttpServletResponse::class.java)
|
||||
res?.characterEncoding = "UTF-8"
|
||||
res?.addHeader("Content-Type", contentType)
|
||||
res?.writer?.print(example)
|
||||
} catch (e: IOException) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler
|
||||
import javax.servlet.http.HttpServletResponse
|
||||
import javax.validation.ConstraintViolationException
|
||||
|
||||
// TODO Extend ApiException for custom exception handling, e.g. the below NotFound exception
|
||||
sealed class ApiException(msg: String, val code: Int) : Exception(msg)
|
||||
|
||||
class NotFoundException(msg: String, code: Int = HttpStatus.NOT_FOUND.value()) : ApiException(msg, code)
|
||||
|
||||
|
||||
@ControllerAdvice
|
||||
class DefaultExceptionHandler {
|
||||
|
||||
@ExceptionHandler(value = [ApiException::class])
|
||||
fun onApiException(ex: ApiException, response: HttpServletResponse): Unit =
|
||||
response.sendError(ex.code, ex.message)
|
||||
|
||||
@ExceptionHandler(value = [NotImplementedError::class])
|
||||
fun onNotImplemented(ex: NotImplementedError, response: HttpServletResponse): Unit =
|
||||
response.sendError(HttpStatus.NOT_IMPLEMENTED.value())
|
||||
|
||||
@ExceptionHandler(value = [ConstraintViolationException::class])
|
||||
fun onConstraintViolation(ex: ConstraintViolationException, response: HttpServletResponse): Unit =
|
||||
response.sendError(HttpStatus.BAD_REQUEST.value(), ex.constraintViolations.joinToString(", ") { it.message })
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.ModelApiResponse
|
||||
import org.openapitools.model.Pet
|
||||
import io.swagger.v3.oas.annotations.*
|
||||
import io.swagger.v3.oas.annotations.enums.*
|
||||
import io.swagger.v3.oas.annotations.media.*
|
||||
import io.swagger.v3.oas.annotations.responses.*
|
||||
import io.swagger.v3.oas.annotations.security.*
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.http.ResponseEntity
|
||||
|
||||
import org.springframework.web.bind.annotation.*
|
||||
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.Email
|
||||
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 kotlin.collections.List
|
||||
import kotlin.collections.Map
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
@RequestMapping("\${api.base-path:/v2}")
|
||||
class PetApiController(@Autowired(required = true) val service: PetApiService) {
|
||||
|
||||
@Operation(
|
||||
summary = "Add a new pet to the store",
|
||||
operationId = "addPet",
|
||||
description = "",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "405", description = "Invalid input") ],
|
||||
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.POST],
|
||||
value = ["/pet"],
|
||||
consumes = ["application/json", "application/xml"]
|
||||
)
|
||||
fun addPet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody body: Pet): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.addPet(body), HttpStatus.valueOf(405))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Deletes a pet",
|
||||
operationId = "deletePet",
|
||||
description = "",
|
||||
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}"]
|
||||
)
|
||||
fun deletePet(@Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "", `in` = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) apiKey: kotlin.String?): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.valueOf(400))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Finds Pets by status",
|
||||
operationId = "findPetsByStatus",
|
||||
description = "Multiple status values can be provided with comma separated strings",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
|
||||
ApiResponse(responseCode = "400", description = "Invalid status value") ],
|
||||
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.GET],
|
||||
value = ["/pet/findByStatus"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun findPetsByStatus(@NotNull @Parameter(description = "Status values that need to be considered for filter", required = true, schema = Schema(allowableValues = ["available", "pending", "sold"])) @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List<kotlin.String>): ResponseEntity<List<Pet>> {
|
||||
return ResponseEntity(service.findPetsByStatus(status), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Finds Pets by tags",
|
||||
operationId = "findPetsByTags",
|
||||
description = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
|
||||
ApiResponse(responseCode = "400", description = "Invalid tag value") ],
|
||||
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.GET],
|
||||
value = ["/pet/findByTags"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun findPetsByTags(@NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List<kotlin.String>): ResponseEntity<List<Pet>> {
|
||||
return ResponseEntity(service.findPetsByTags(tags), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Find pet by ID",
|
||||
operationId = "getPetById",
|
||||
description = "Returns a single pet",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(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"]
|
||||
)
|
||||
fun getPetById(@Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") petId: kotlin.Long): ResponseEntity<Pet> {
|
||||
return ResponseEntity(service.getPetById(petId), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Update an existing pet",
|
||||
operationId = "updatePet",
|
||||
description = "",
|
||||
responses = [
|
||||
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" ]) ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.PUT],
|
||||
value = ["/pet"],
|
||||
consumes = ["application/json", "application/xml"]
|
||||
)
|
||||
fun updatePet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody body: Pet): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.updatePet(body), HttpStatus.valueOf(400))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Updates a pet in the store with form data",
|
||||
operationId = "updatePetWithForm",
|
||||
description = "",
|
||||
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"]
|
||||
)
|
||||
fun updatePetWithForm(@Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) name: kotlin.String? ,@Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) status: kotlin.String? ): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.valueOf(405))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "uploads an image",
|
||||
operationId = "uploadFile",
|
||||
description = "",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(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"]
|
||||
)
|
||||
fun uploadFile(@Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") petId: kotlin.Long,@Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) additionalMetadata: kotlin.String? ,@Parameter(description = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource?): ResponseEntity<ModelApiResponse> {
|
||||
return ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.valueOf(200))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.ModelApiResponse
|
||||
import org.openapitools.model.Pet
|
||||
|
||||
interface PetApiService {
|
||||
|
||||
/**
|
||||
* POST /pet : Add a new pet to the store
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store (required)
|
||||
* @return Invalid input (status code 405)
|
||||
* @see PetApi#addPet
|
||||
*/
|
||||
fun addPet(body: Pet): Unit
|
||||
|
||||
/**
|
||||
* DELETE /pet/{petId} : Deletes a pet
|
||||
*
|
||||
* @param petId Pet id to delete (required)
|
||||
* @param apiKey (optional)
|
||||
* @return Invalid pet value (status code 400)
|
||||
* @see PetApi#deletePet
|
||||
*/
|
||||
fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?): Unit
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @see PetApi#findPetsByStatus
|
||||
*/
|
||||
fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>): List<Pet>
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @see PetApi#findPetsByTags
|
||||
*/
|
||||
fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>): List<Pet>
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @see PetApi#getPetById
|
||||
*/
|
||||
fun getPetById(petId: kotlin.Long): Pet
|
||||
|
||||
/**
|
||||
* PUT /pet : Update an existing pet
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store (required)
|
||||
* @return Invalid ID supplied (status code 400)
|
||||
* or Pet not found (status code 404)
|
||||
* or Validation exception (status code 405)
|
||||
* @see PetApi#updatePet
|
||||
*/
|
||||
fun updatePet(body: Pet): Unit
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @see PetApi#updatePetWithForm
|
||||
*/
|
||||
fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?): Unit
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @see PetApi#uploadFile
|
||||
*/
|
||||
fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: org.springframework.core.io.Resource?): ModelApiResponse
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.ModelApiResponse
|
||||
import org.openapitools.model.Pet
|
||||
import org.springframework.stereotype.Service
|
||||
@Service
|
||||
class PetApiServiceImpl : PetApiService {
|
||||
|
||||
override fun addPet(body: Pet): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>): List<Pet> {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>): List<Pet> {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun getPetById(petId: kotlin.Long): Pet {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun updatePet(body: Pet): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: org.springframework.core.io.Resource?): ModelApiResponse {
|
||||
TODO("Implement me")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.Order
|
||||
import io.swagger.v3.oas.annotations.*
|
||||
import io.swagger.v3.oas.annotations.enums.*
|
||||
import io.swagger.v3.oas.annotations.media.*
|
||||
import io.swagger.v3.oas.annotations.responses.*
|
||||
import io.swagger.v3.oas.annotations.security.*
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.http.ResponseEntity
|
||||
|
||||
import org.springframework.web.bind.annotation.*
|
||||
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.Email
|
||||
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 kotlin.collections.List
|
||||
import kotlin.collections.Map
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
@RequestMapping("\${api.base-path:/v2}")
|
||||
class StoreApiController(@Autowired(required = true) val service: StoreApiService) {
|
||||
|
||||
@Operation(
|
||||
summary = "Delete purchase order by ID",
|
||||
operationId = "deleteOrder",
|
||||
description = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
|
||||
ApiResponse(responseCode = "404", description = "Order not found") ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.DELETE],
|
||||
value = ["/store/order/{orderId}"]
|
||||
)
|
||||
fun deleteOrder(@Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") orderId: kotlin.String): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.deleteOrder(orderId), HttpStatus.valueOf(400))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Returns pet inventories by status",
|
||||
operationId = "getInventory",
|
||||
description = "Returns a map of status codes to quantities",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = kotlin.collections.Map::class))]) ],
|
||||
security = [ SecurityRequirement(name = "api_key") ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.GET],
|
||||
value = ["/store/inventory"],
|
||||
produces = ["application/json"]
|
||||
)
|
||||
fun getInventory(): ResponseEntity<Map<String, kotlin.Int>> {
|
||||
return ResponseEntity(service.getInventory(), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Find purchase order by ID",
|
||||
operationId = "getOrderById",
|
||||
description = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(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"]
|
||||
)
|
||||
fun getOrderById(@Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") orderId: kotlin.Long): ResponseEntity<Order> {
|
||||
return ResponseEntity(service.getOrderById(orderId), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Place an order for a pet",
|
||||
operationId = "placeOrder",
|
||||
description = "",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Order::class))]),
|
||||
ApiResponse(responseCode = "400", description = "Invalid Order") ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.POST],
|
||||
value = ["/store/order"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun placeOrder(@Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody body: Order): ResponseEntity<Order> {
|
||||
return ResponseEntity(service.placeOrder(body), HttpStatus.valueOf(200))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.Order
|
||||
|
||||
interface StoreApiService {
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @see StoreApi#deleteOrder
|
||||
*/
|
||||
fun deleteOrder(orderId: kotlin.String): Unit
|
||||
|
||||
/**
|
||||
* GET /store/inventory : Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
*
|
||||
* @return successful operation (status code 200)
|
||||
* @see StoreApi#getInventory
|
||||
*/
|
||||
fun getInventory(): Map<String, kotlin.Int>
|
||||
|
||||
/**
|
||||
* GET /store/order/{orderId} : Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated 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)
|
||||
* @see StoreApi#getOrderById
|
||||
*/
|
||||
fun getOrderById(orderId: kotlin.Long): Order
|
||||
|
||||
/**
|
||||
* POST /store/order : Place an order for a pet
|
||||
*
|
||||
* @param body order placed for purchasing the pet (required)
|
||||
* @return successful operation (status code 200)
|
||||
* or Invalid Order (status code 400)
|
||||
* @see StoreApi#placeOrder
|
||||
*/
|
||||
fun placeOrder(body: Order): Order
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.Order
|
||||
import org.springframework.stereotype.Service
|
||||
@Service
|
||||
class StoreApiServiceImpl : StoreApiService {
|
||||
|
||||
override fun deleteOrder(orderId: kotlin.String): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun getInventory(): Map<String, kotlin.Int> {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun getOrderById(orderId: kotlin.Long): Order {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun placeOrder(body: Order): Order {
|
||||
TODO("Implement me")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.User
|
||||
import io.swagger.v3.oas.annotations.*
|
||||
import io.swagger.v3.oas.annotations.enums.*
|
||||
import io.swagger.v3.oas.annotations.media.*
|
||||
import io.swagger.v3.oas.annotations.responses.*
|
||||
import io.swagger.v3.oas.annotations.security.*
|
||||
import org.springframework.http.HttpStatus
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.http.ResponseEntity
|
||||
|
||||
import org.springframework.web.bind.annotation.*
|
||||
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.Email
|
||||
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 kotlin.collections.List
|
||||
import kotlin.collections.Map
|
||||
|
||||
@RestController
|
||||
@Validated
|
||||
@RequestMapping("\${api.base-path:/v2}")
|
||||
class UserApiController(@Autowired(required = true) val service: UserApiService) {
|
||||
|
||||
@Operation(
|
||||
summary = "Create user",
|
||||
operationId = "createUser",
|
||||
description = "This can only be done by the logged in user.",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation") ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.POST],
|
||||
value = ["/user"]
|
||||
)
|
||||
fun createUser(@Parameter(description = "Created user object", required = true) @Valid @RequestBody body: User): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.createUser(body), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Creates list of users with given input array",
|
||||
operationId = "createUsersWithArrayInput",
|
||||
description = "",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation") ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.POST],
|
||||
value = ["/user/createWithArray"]
|
||||
)
|
||||
fun createUsersWithArrayInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody body: kotlin.collections.List<User>): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.createUsersWithArrayInput(body), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Creates list of users with given input array",
|
||||
operationId = "createUsersWithListInput",
|
||||
description = "",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation") ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.POST],
|
||||
value = ["/user/createWithList"]
|
||||
)
|
||||
fun createUsersWithListInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody body: kotlin.collections.List<User>): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.createUsersWithListInput(body), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Delete user",
|
||||
operationId = "deleteUser",
|
||||
description = "This can only be done by the logged in user.",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "400", description = "Invalid username supplied"),
|
||||
ApiResponse(responseCode = "404", description = "User not found") ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.DELETE],
|
||||
value = ["/user/{username}"]
|
||||
)
|
||||
fun deleteUser(@Parameter(description = "The name that needs to be deleted", required = true) @PathVariable("username") username: kotlin.String): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.deleteUser(username), HttpStatus.valueOf(400))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Get user by user name",
|
||||
operationId = "getUserByName",
|
||||
description = "",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(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"]
|
||||
)
|
||||
fun getUserByName(@Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") username: kotlin.String): ResponseEntity<User> {
|
||||
return ResponseEntity(service.getUserByName(username), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Logs user into the system",
|
||||
operationId = "loginUser",
|
||||
description = "",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = kotlin.String::class))]),
|
||||
ApiResponse(responseCode = "400", description = "Invalid username/password supplied") ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.GET],
|
||||
value = ["/user/login"],
|
||||
produces = ["application/xml", "application/json"]
|
||||
)
|
||||
fun loginUser(@NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: kotlin.String,@NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String): ResponseEntity<kotlin.String> {
|
||||
return ResponseEntity(service.loginUser(username, password), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Logs out current logged in user session",
|
||||
operationId = "logoutUser",
|
||||
description = "",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "200", description = "successful operation") ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.GET],
|
||||
value = ["/user/logout"]
|
||||
)
|
||||
fun logoutUser(): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.logoutUser(), HttpStatus.valueOf(200))
|
||||
}
|
||||
|
||||
@Operation(
|
||||
summary = "Updated user",
|
||||
operationId = "updateUser",
|
||||
description = "This can only be done by the logged in user.",
|
||||
responses = [
|
||||
ApiResponse(responseCode = "400", description = "Invalid user supplied"),
|
||||
ApiResponse(responseCode = "404", description = "User not found") ]
|
||||
)
|
||||
@RequestMapping(
|
||||
method = [RequestMethod.PUT],
|
||||
value = ["/user/{username}"]
|
||||
)
|
||||
fun updateUser(@Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") username: kotlin.String,@Parameter(description = "Updated user object", required = true) @Valid @RequestBody body: User): ResponseEntity<Unit> {
|
||||
return ResponseEntity(service.updateUser(username, body), HttpStatus.valueOf(400))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.User
|
||||
|
||||
interface UserApiService {
|
||||
|
||||
/**
|
||||
* POST /user : Create user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param body Created user object (required)
|
||||
* @return successful operation (status code 200)
|
||||
* @see UserApi#createUser
|
||||
*/
|
||||
fun createUser(body: User): Unit
|
||||
|
||||
/**
|
||||
* POST /user/createWithArray : Creates list of users with given input array
|
||||
*
|
||||
* @param body List of user object (required)
|
||||
* @return successful operation (status code 200)
|
||||
* @see UserApi#createUsersWithArrayInput
|
||||
*/
|
||||
fun createUsersWithArrayInput(body: kotlin.collections.List<User>): Unit
|
||||
|
||||
/**
|
||||
* POST /user/createWithList : Creates list of users with given input array
|
||||
*
|
||||
* @param body List of user object (required)
|
||||
* @return successful operation (status code 200)
|
||||
* @see UserApi#createUsersWithListInput
|
||||
*/
|
||||
fun createUsersWithListInput(body: kotlin.collections.List<User>): Unit
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @see UserApi#deleteUser
|
||||
*/
|
||||
fun deleteUser(username: kotlin.String): Unit
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @see UserApi#getUserByName
|
||||
*/
|
||||
fun getUserByName(username: kotlin.String): User
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* @see UserApi#loginUser
|
||||
*/
|
||||
fun loginUser(username: kotlin.String, password: kotlin.String): kotlin.String
|
||||
|
||||
/**
|
||||
* GET /user/logout : Logs out current logged in user session
|
||||
*
|
||||
* @return successful operation (status code 200)
|
||||
* @see UserApi#logoutUser
|
||||
*/
|
||||
fun logoutUser(): Unit
|
||||
|
||||
/**
|
||||
* 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 body Updated user object (required)
|
||||
* @return Invalid user supplied (status code 400)
|
||||
* or User not found (status code 404)
|
||||
* @see UserApi#updateUser
|
||||
*/
|
||||
fun updateUser(username: kotlin.String, body: User): Unit
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.User
|
||||
import org.springframework.stereotype.Service
|
||||
@Service
|
||||
class UserApiServiceImpl : UserApiService {
|
||||
|
||||
override fun createUser(body: User): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun createUsersWithArrayInput(body: kotlin.collections.List<User>): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun createUsersWithListInput(body: kotlin.collections.List<User>): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun deleteUser(username: kotlin.String): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun getUserByName(username: kotlin.String): User {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun loginUser(username: kotlin.String, password: kotlin.String): kotlin.String {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun logoutUser(): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
|
||||
override fun updateUser(username: kotlin.String, body: User): Unit {
|
||||
TODO("Implement me")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
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.Email
|
||||
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 javax.validation.Valid
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
data class Category(
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("id") val id: kotlin.Long? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("name") val name: kotlin.String? = null
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
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.Email
|
||||
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 javax.validation.Valid
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
* @param code
|
||||
* @param type
|
||||
* @param message
|
||||
*/
|
||||
data class ModelApiResponse(
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("code") val code: kotlin.Int? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("type") val type: kotlin.String? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("message") val message: kotlin.String? = null
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
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.Email
|
||||
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 javax.validation.Valid
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
/**
|
||||
* 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(
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("id") val id: kotlin.Long? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("petId") val petId: kotlin.Long? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("quantity") val quantity: kotlin.Int? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,
|
||||
|
||||
@Schema(example = "null", description = "Order Status")
|
||||
@field:JsonProperty("status") val status: Order.Status? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("complete") val complete: kotlin.Boolean? = false
|
||||
) {
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
* Values: placed,approved,delivered
|
||||
*/
|
||||
enum class Status(val value: kotlin.String) {
|
||||
|
||||
@JsonProperty("placed") placed("placed"),
|
||||
@JsonProperty("approved") approved("approved"),
|
||||
@JsonProperty("delivered") delivered("delivered")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
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.Email
|
||||
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 javax.validation.Valid
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
* @param name
|
||||
* @param photoUrls
|
||||
* @param id
|
||||
* @param category
|
||||
* @param tags
|
||||
* @param status pet status in the store
|
||||
*/
|
||||
data class Pet(
|
||||
|
||||
@Schema(example = "doggie", required = true, description = "")
|
||||
@field:JsonProperty("name", required = true) val name: kotlin.String,
|
||||
|
||||
@Schema(example = "null", required = true, description = "")
|
||||
@field:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List<kotlin.String>,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("id") val id: kotlin.Long? = null,
|
||||
|
||||
@field:Valid
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("category") val category: Category? = null,
|
||||
|
||||
@field:Valid
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("tags") val tags: kotlin.collections.List<Tag>? = null,
|
||||
|
||||
@Schema(example = "null", description = "pet status in the store")
|
||||
@field:JsonProperty("status") val status: Pet.Status? = null
|
||||
) {
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
* Values: available,pending,sold
|
||||
*/
|
||||
enum class Status(val value: kotlin.String) {
|
||||
|
||||
@JsonProperty("available") available("available"),
|
||||
@JsonProperty("pending") pending("pending"),
|
||||
@JsonProperty("sold") sold("sold")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
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.Email
|
||||
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 javax.validation.Valid
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
data class Tag(
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("id") val id: kotlin.Long? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("name") val name: kotlin.String? = null
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
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.Email
|
||||
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 javax.validation.Valid
|
||||
import io.swagger.v3.oas.annotations.media.Schema
|
||||
|
||||
/**
|
||||
* 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(
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("id") val id: kotlin.Long? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("username") val username: kotlin.String? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("firstName") val firstName: kotlin.String? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("lastName") val lastName: kotlin.String? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("email") val email: kotlin.String? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("password") val password: kotlin.String? = null,
|
||||
|
||||
@Schema(example = "null", description = "")
|
||||
@field:JsonProperty("phone") val phone: kotlin.String? = null,
|
||||
|
||||
@Schema(example = "null", description = "User Status")
|
||||
@field:JsonProperty("userStatus") val userStatus: kotlin.Int? = null
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
spring:
|
||||
application:
|
||||
name: openAPIPetstore
|
||||
|
||||
jackson:
|
||||
serialization:
|
||||
WRITE_DATES_AS_TIMESTAMPS: false
|
||||
|
||||
server:
|
||||
port: 8080
|
||||
@@ -0,0 +1,763 @@
|
||||
openapi: 3.0.1
|
||||
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
|
||||
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:
|
||||
operationId: addPet
|
||||
requestBody:
|
||||
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
|
||||
responses:
|
||||
"405":
|
||||
content: {}
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Add a new pet to the store
|
||||
tags:
|
||||
- pet
|
||||
x-codegen-request-body-name: body
|
||||
put:
|
||||
operationId: updatePet
|
||||
requestBody:
|
||||
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
|
||||
responses:
|
||||
"400":
|
||||
content: {}
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
content: {}
|
||||
description: Pet not found
|
||||
"405":
|
||||
content: {}
|
||||
description: Validation exception
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Update an existing pet
|
||||
tags:
|
||||
- pet
|
||||
x-codegen-request-body-name: body
|
||||
/pet/findByStatus:
|
||||
get:
|
||||
description: Multiple status values can be provided with comma separated strings
|
||||
operationId: findPetsByStatus
|
||||
parameters:
|
||||
- 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":
|
||||
content: {}
|
||||
description: Invalid status value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Finds Pets by status
|
||||
tags:
|
||||
- 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":
|
||||
content: {}
|
||||
description: Invalid tag value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Finds Pets by tags
|
||||
tags:
|
||||
- pet
|
||||
/pet/{petId}:
|
||||
delete:
|
||||
operationId: deletePet
|
||||
parameters:
|
||||
- in: header
|
||||
name: api_key
|
||||
schema:
|
||||
type: string
|
||||
- description: Pet id to delete
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
responses:
|
||||
"400":
|
||||
content: {}
|
||||
description: Invalid pet value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Deletes a pet
|
||||
tags:
|
||||
- pet
|
||||
get:
|
||||
description: Returns a single pet
|
||||
operationId: getPetById
|
||||
parameters:
|
||||
- description: ID of pet to return
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Pet'
|
||||
description: successful operation
|
||||
"400":
|
||||
content: {}
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
content: {}
|
||||
description: Pet not found
|
||||
security:
|
||||
- api_key: []
|
||||
summary: Find pet by ID
|
||||
tags:
|
||||
- pet
|
||||
post:
|
||||
operationId: updatePetWithForm
|
||||
parameters:
|
||||
- description: ID of pet that needs to be updated
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
requestBody:
|
||||
content:
|
||||
application/x-www-form-urlencoded:
|
||||
schema:
|
||||
properties:
|
||||
name:
|
||||
description: Updated name of the pet
|
||||
type: string
|
||||
status:
|
||||
description: Updated status of the pet
|
||||
type: string
|
||||
responses:
|
||||
"405":
|
||||
content: {}
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write:pets
|
||||
- read:pets
|
||||
summary: Updates a pet in the store with form data
|
||||
tags:
|
||||
- pet
|
||||
/pet/{petId}/uploadImage:
|
||||
post:
|
||||
operationId: uploadFile
|
||||
parameters:
|
||||
- description: ID of pet to update
|
||||
in: path
|
||||
name: petId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
type: integer
|
||||
requestBody:
|
||||
content:
|
||||
multipart/form-data:
|
||||
schema:
|
||||
properties:
|
||||
additionalMetadata:
|
||||
description: Additional data to pass to server
|
||||
type: string
|
||||
file:
|
||||
description: file to upload
|
||||
format: binary
|
||||
type: string
|
||||
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
|
||||
/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
|
||||
/store/order:
|
||||
post:
|
||||
operationId: placeOrder
|
||||
requestBody:
|
||||
content:
|
||||
'*/*':
|
||||
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":
|
||||
content: {}
|
||||
description: Invalid Order
|
||||
summary: Place an order for a pet
|
||||
tags:
|
||||
- store
|
||||
x-codegen-request-body-name: body
|
||||
/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
|
||||
in: path
|
||||
name: orderId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"400":
|
||||
content: {}
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
content: {}
|
||||
description: Order not found
|
||||
summary: Delete purchase order by ID
|
||||
tags:
|
||||
- store
|
||||
get:
|
||||
description: For valid response try integer IDs with value <= 5 or > 10. Other
|
||||
values will generated exceptions
|
||||
operationId: getOrderById
|
||||
parameters:
|
||||
- description: ID of pet that needs to be fetched
|
||||
in: path
|
||||
name: orderId
|
||||
required: true
|
||||
schema:
|
||||
format: int64
|
||||
maximum: 5
|
||||
minimum: 1
|
||||
type: integer
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Order'
|
||||
description: successful operation
|
||||
"400":
|
||||
content: {}
|
||||
description: Invalid ID supplied
|
||||
"404":
|
||||
content: {}
|
||||
description: Order not found
|
||||
summary: Find purchase order by ID
|
||||
tags:
|
||||
- store
|
||||
/user:
|
||||
post:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: createUser
|
||||
requestBody:
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: Created user object
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
content: {}
|
||||
description: successful operation
|
||||
summary: Create user
|
||||
tags:
|
||||
- user
|
||||
x-codegen-request-body-name: body
|
||||
/user/createWithArray:
|
||||
post:
|
||||
operationId: createUsersWithArrayInput
|
||||
requestBody:
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
type: array
|
||||
description: List of user object
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
content: {}
|
||||
description: successful operation
|
||||
summary: Creates list of users with given input array
|
||||
tags:
|
||||
- user
|
||||
x-codegen-request-body-name: body
|
||||
/user/createWithList:
|
||||
post:
|
||||
operationId: createUsersWithListInput
|
||||
requestBody:
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
type: array
|
||||
description: List of user object
|
||||
required: true
|
||||
responses:
|
||||
default:
|
||||
content: {}
|
||||
description: successful operation
|
||||
summary: Creates list of users with given input array
|
||||
tags:
|
||||
- user
|
||||
x-codegen-request-body-name: body
|
||||
/user/login:
|
||||
get:
|
||||
operationId: loginUser
|
||||
parameters:
|
||||
- description: The user name for login
|
||||
in: query
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
- description: The password for login in clear text
|
||||
in: query
|
||||
name: password
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
type: string
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
description: successful operation
|
||||
headers:
|
||||
X-Rate-Limit:
|
||||
description: calls per hour allowed by the user
|
||||
schema:
|
||||
format: int32
|
||||
type: integer
|
||||
X-Expires-After:
|
||||
description: date in UTC when token expires
|
||||
schema:
|
||||
format: date-time
|
||||
type: string
|
||||
"400":
|
||||
content: {}
|
||||
description: Invalid username/password supplied
|
||||
summary: Logs user into the system
|
||||
tags:
|
||||
- user
|
||||
/user/logout:
|
||||
get:
|
||||
operationId: logoutUser
|
||||
responses:
|
||||
default:
|
||||
content: {}
|
||||
description: successful operation
|
||||
summary: Logs out current logged in user session
|
||||
tags:
|
||||
- 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
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"400":
|
||||
content: {}
|
||||
description: Invalid username supplied
|
||||
"404":
|
||||
content: {}
|
||||
description: User not found
|
||||
summary: Delete user
|
||||
tags:
|
||||
- user
|
||||
get:
|
||||
operationId: getUserByName
|
||||
parameters:
|
||||
- description: The name that needs to be fetched. Use user1 for testing.
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
content:
|
||||
application/xml:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: successful operation
|
||||
"400":
|
||||
content: {}
|
||||
description: Invalid username supplied
|
||||
"404":
|
||||
content: {}
|
||||
description: User not found
|
||||
summary: Get user by user name
|
||||
tags:
|
||||
- user
|
||||
put:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: updateUser
|
||||
parameters:
|
||||
- description: name that need to be deleted
|
||||
in: path
|
||||
name: username
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
requestBody:
|
||||
content:
|
||||
'*/*':
|
||||
schema:
|
||||
$ref: '#/components/schemas/User'
|
||||
description: Updated user object
|
||||
required: true
|
||||
responses:
|
||||
"400":
|
||||
content: {}
|
||||
description: Invalid user supplied
|
||||
"404":
|
||||
content: {}
|
||||
description: User not found
|
||||
summary: Updated user
|
||||
tags:
|
||||
- user
|
||||
x-codegen-request-body-name: body
|
||||
components:
|
||||
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:
|
||||
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:
|
||||
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
|
||||
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
|
||||
x-original-swagger-version: "2.0"
|
||||
@@ -0,0 +1,60 @@
|
||||
<!-- HTML for static distribution bundle build -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Swagger UI</title>
|
||||
<link rel="stylesheet" type="text/css" href="webjars/swagger-ui/swagger-ui.css" />
|
||||
<link rel="icon" type="image/png" href="webjars/swagger-ui/favicon-32x32.png" sizes="32x32" />
|
||||
<link rel="icon" type="image/png" href="webjars/swagger-ui/favicon-16x16.png" sizes="16x16" />
|
||||
<style>
|
||||
html
|
||||
{
|
||||
box-sizing: border-box;
|
||||
overflow: -moz-scrollbars-vertical;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
*,
|
||||
*:before,
|
||||
*:after
|
||||
{
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
margin:0;
|
||||
background: #fafafa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="swagger-ui"></div>
|
||||
|
||||
<script src="webjars/swagger-ui/swagger-ui-bundle.js" charset="UTF-8"> </script>
|
||||
<script src="webjars/swagger-ui/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
|
||||
<script>
|
||||
window.onload = function() {
|
||||
// Begin Swagger UI call region
|
||||
const ui = SwaggerUIBundle({
|
||||
configUrl: 'swagger-config.yaml',
|
||||
dom_id: '#swagger-ui',
|
||||
deepLinking: true,
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
layout: "StandaloneLayout"
|
||||
});
|
||||
// End Swagger UI call region
|
||||
|
||||
window.ui = ui;
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,129 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.ModelApiResponse
|
||||
import org.openapitools.model.Pet
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.http.ResponseEntity
|
||||
|
||||
class PetApiTest {
|
||||
|
||||
private val service: PetApiService = PetApiServiceImpl()
|
||||
private val api: PetApiController = PetApiController(service)
|
||||
|
||||
/**
|
||||
* To test PetApiController.addPet
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun addPetTest() {
|
||||
val body: Pet = TODO()
|
||||
val response: ResponseEntity<Unit> = api.addPet(body)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test PetApiController.deletePet
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun deletePetTest() {
|
||||
val petId: kotlin.Long = TODO()
|
||||
val apiKey: kotlin.String? = TODO()
|
||||
val response: ResponseEntity<Unit> = api.deletePet(petId, apiKey)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test PetApiController.findPetsByStatus
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun findPetsByStatusTest() {
|
||||
val status: kotlin.collections.List<kotlin.String> = TODO()
|
||||
val response: ResponseEntity<List<Pet>> = api.findPetsByStatus(status)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test PetApiController.findPetsByTags
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun findPetsByTagsTest() {
|
||||
val tags: kotlin.collections.List<kotlin.String> = TODO()
|
||||
val response: ResponseEntity<List<Pet>> = api.findPetsByTags(tags)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test PetApiController.getPetById
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun getPetByIdTest() {
|
||||
val petId: kotlin.Long = TODO()
|
||||
val response: ResponseEntity<Pet> = api.getPetById(petId)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test PetApiController.updatePet
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun updatePetTest() {
|
||||
val body: Pet = TODO()
|
||||
val response: ResponseEntity<Unit> = api.updatePet(body)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test PetApiController.updatePetWithForm
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun updatePetWithFormTest() {
|
||||
val petId: kotlin.Long = TODO()
|
||||
val name: kotlin.String? = TODO()
|
||||
val status: kotlin.String? = TODO()
|
||||
val response: ResponseEntity<Unit> = api.updatePetWithForm(petId, name, status)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test PetApiController.uploadFile
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun uploadFileTest() {
|
||||
val petId: kotlin.Long = TODO()
|
||||
val additionalMetadata: kotlin.String? = TODO()
|
||||
val file: org.springframework.core.io.Resource? = TODO()
|
||||
val response: ResponseEntity<ModelApiResponse> = api.uploadFile(petId, additionalMetadata, file)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.Order
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.http.ResponseEntity
|
||||
|
||||
class StoreApiTest {
|
||||
|
||||
private val service: StoreApiService = StoreApiServiceImpl()
|
||||
private val api: StoreApiController = StoreApiController(service)
|
||||
|
||||
/**
|
||||
* To test StoreApiController.deleteOrder
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun deleteOrderTest() {
|
||||
val orderId: kotlin.String = TODO()
|
||||
val response: ResponseEntity<Unit> = api.deleteOrder(orderId)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test StoreApiController.getInventory
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun getInventoryTest() {
|
||||
val response: ResponseEntity<Map<String, kotlin.Int>> = api.getInventory()
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test StoreApiController.getOrderById
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun getOrderByIdTest() {
|
||||
val orderId: kotlin.Long = TODO()
|
||||
val response: ResponseEntity<Order> = api.getOrderById(orderId)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test StoreApiController.placeOrder
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun placeOrderTest() {
|
||||
val body: Order = TODO()
|
||||
val response: ResponseEntity<Order> = api.placeOrder(body)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package org.openapitools.api
|
||||
|
||||
import org.openapitools.model.User
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.springframework.http.ResponseEntity
|
||||
|
||||
class UserApiTest {
|
||||
|
||||
private val service: UserApiService = UserApiServiceImpl()
|
||||
private val api: UserApiController = UserApiController(service)
|
||||
|
||||
/**
|
||||
* To test UserApiController.createUser
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun createUserTest() {
|
||||
val body: User = TODO()
|
||||
val response: ResponseEntity<Unit> = api.createUser(body)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test UserApiController.createUsersWithArrayInput
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun createUsersWithArrayInputTest() {
|
||||
val body: kotlin.collections.List<User> = TODO()
|
||||
val response: ResponseEntity<Unit> = api.createUsersWithArrayInput(body)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test UserApiController.createUsersWithListInput
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun createUsersWithListInputTest() {
|
||||
val body: kotlin.collections.List<User> = TODO()
|
||||
val response: ResponseEntity<Unit> = api.createUsersWithListInput(body)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test UserApiController.deleteUser
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun deleteUserTest() {
|
||||
val username: kotlin.String = TODO()
|
||||
val response: ResponseEntity<Unit> = api.deleteUser(username)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test UserApiController.getUserByName
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun getUserByNameTest() {
|
||||
val username: kotlin.String = TODO()
|
||||
val response: ResponseEntity<User> = api.getUserByName(username)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test UserApiController.loginUser
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun loginUserTest() {
|
||||
val username: kotlin.String = TODO()
|
||||
val password: kotlin.String = TODO()
|
||||
val response: ResponseEntity<kotlin.String> = api.loginUser(username, password)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test UserApiController.logoutUser
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun logoutUserTest() {
|
||||
val response: ResponseEntity<Unit> = api.logoutUser()
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
|
||||
/**
|
||||
* To test UserApiController.updateUser
|
||||
*
|
||||
* @throws ApiException
|
||||
* if the Api call fails
|
||||
*/
|
||||
@Test
|
||||
fun updateUserTest() {
|
||||
val username: kotlin.String = TODO()
|
||||
val body: User = TODO()
|
||||
val response: ResponseEntity<Unit> = api.updateUser(username, body)
|
||||
|
||||
// TODO: test validations
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user