[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:
Johan Sjöblom
2022-04-26 17:03:32 +00:00
committed by GitHub
parent 074010e124
commit 356732d1bd
211 changed files with 11950 additions and 1338 deletions

View File

@@ -3,6 +3,7 @@ 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/PetApi.kt
@@ -21,3 +22,4 @@ 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

View File

@@ -30,14 +30,18 @@ plugins {
}
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-web")
compile("io.swagger:swagger-annotations:1.5.21")
compile("org.springdoc:springdoc-openapi-ui:1.6.6")
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") {

View File

@@ -6,10 +6,13 @@
<name>openapi-spring</name>
<version>1.0.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springdoc-openapi.version>1.6.6</springdoc-openapi.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>
<kotlinx-coroutines.version>1.2.0</kotlinx-coroutines.version>
<jakarta-annotation-version>1.3.5</jakarta-annotation-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
@@ -83,16 +86,18 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--SpringDoc dependencies -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc-openapi.version}</version>
</dependency>
<!-- @Nullable annotation -->
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<version>${findbugs-jsr305.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
@@ -118,13 +123,13 @@
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>${jakarta-annotation-version}</version>
<version>${jakarta-annotation.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>1.3.31</version>
<version>${kotlin-test-junit5.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -1,9 +1,8 @@
package org.openapitools
import org.springframework.boot.runApplication
import org.springframework.context.annotation.ComponentScan
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.context.annotation.ComponentScan
@SpringBootApplication
@ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"])

View File

@@ -0,0 +1,17 @@
package org.openapitools
import org.springframework.context.annotation.Bean
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.GetMapping
/**
* Home redirection to OpenAPI api documentation
*/
@Controller
class HomeController {
@RequestMapping("/")
fun index(): String = "redirect:swagger-ui.html"
}

View File

@@ -7,13 +7,11 @@ 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 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
@@ -37,160 +35,162 @@ import kotlin.collections.List
import kotlin.collections.Map
@Validated
@Api(value = "pet", description = "The pet API")
@RequestMapping("\${api.base-path:/v2}")
interface PetApi {
fun getDelegate(): PetApiDelegate = object: PetApiDelegate {}
@ApiOperation(
value = "Add a new pet to the store",
nickname = "addPet",
notes = "",
response = Pet::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 = Pet::class),ApiResponse(code = 405, message = "Invalid input")])
@Operation(
summary = "Add a new pet to the store",
operationId = "addPet",
description = "",
responses = [
ApiResponse(responseCode = "200", description = "successful operation", content = [Content(schema = Schema(implementation = Pet::class))]),
ApiResponse(responseCode = "405", description = "Invalid input")
],
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
)
@RequestMapping(
method = [RequestMethod.POST],
value = ["/pet"],
produces = ["application/xml", "application/json"],
consumes = ["application/json", "application/xml"]
)
fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet
): ResponseEntity<Pet> {
return getDelegate().addPet(pet);
fun addPet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet): ResponseEntity<Pet> {
return getDelegate().addPet(pet)
}
@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")])
@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(@ApiParam(value = "Pet id to delete", required=true) @PathVariable("petId") petId: kotlin.Long
,@ApiParam(value = "" ) @RequestHeader(value="api_key", required=false) apiKey: kotlin.String?
): ResponseEntity<Unit> {
return getDelegate().deletePet(petId, apiKey);
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 getDelegate().deletePet(petId, apiKey)
}
@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")])
@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 = [ "read:pets" ]) ]
)
@RequestMapping(
method = [RequestMethod.GET],
value = ["/pet/findByStatus"],
produces = ["application/xml", "application/json"]
)
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: kotlin.collections.List<kotlin.String>
): ResponseEntity<List<Pet>> {
return getDelegate().findPetsByStatus(status);
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 getDelegate().findPetsByStatus(status)
}
@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")])
@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 = [ "read:pets" ]) ]
)
@RequestMapping(
method = [RequestMethod.GET],
value = ["/pet/findByTags"],
produces = ["application/xml", "application/json"]
)
fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List<kotlin.String>
): ResponseEntity<List<Pet>> {
return getDelegate().findPetsByTags(tags);
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 getDelegate().findPetsByTags(tags)
}
@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")])
@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(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: kotlin.Long
): ResponseEntity<Pet> {
return getDelegate().getPetById(petId);
fun getPetById(@Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") petId: kotlin.Long): ResponseEntity<Pet> {
return getDelegate().getPetById(petId)
}
@ApiOperation(
value = "Update an existing pet",
nickname = "updatePet",
notes = "",
response = Pet::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 = Pet::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Pet not found"),ApiResponse(code = 405, message = "Validation exception")])
@Operation(
summary = "Update an existing pet",
operationId = "updatePet",
description = "",
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"),
ApiResponse(responseCode = "405", description = "Validation exception")
],
security = [ SecurityRequirement(name = "petstore_auth", scopes = [ "write:pets", "read:pets" ]) ]
)
@RequestMapping(
method = [RequestMethod.PUT],
value = ["/pet"],
produces = ["application/xml", "application/json"],
consumes = ["application/json", "application/xml"]
)
fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet
): ResponseEntity<Pet> {
return getDelegate().updatePet(pet);
fun updatePet(@Parameter(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody pet: Pet): ResponseEntity<Pet> {
return getDelegate().updatePet(pet)
}
@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")])
@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(@ApiParam(value = "ID of pet that needs to be updated", required=true) @PathVariable("petId") petId: kotlin.Long
,@ApiParam(value = "Updated name of the pet") @RequestParam(value="name", required=false) name: kotlin.String?
,@ApiParam(value = "Updated status of the pet") @RequestParam(value="status", required=false) status: kotlin.String?
): ResponseEntity<Unit> {
return getDelegate().updatePetWithForm(petId, name, status);
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 getDelegate().updatePetWithForm(petId, name, status)
}
@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)])
@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(@ApiParam(value = "ID of pet to update", required=true) @PathVariable("petId") petId: kotlin.Long
,@ApiParam(value = "Additional data to pass to server") @RequestParam(value="additionalMetadata", required=false) additionalMetadata: kotlin.String?
,@ApiParam(value = "file detail") @Valid @RequestPart("file") file: org.springframework.core.io.Resource?
): ResponseEntity<ModelApiResponse> {
return getDelegate().uploadFile(petId, additionalMetadata, file);
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 getDelegate().uploadFile(petId, additionalMetadata, file)
}
}

View File

@@ -1,10 +1,10 @@
package org.openapitools.api;
package org.openapitools.api
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import java.util.Optional
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Optional;
@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"])
@Controller
@RequestMapping("\${openapi.openAPIPetstore.base-path:/v2}")
class PetApiController(

View File

@@ -6,13 +6,11 @@
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 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
@@ -36,77 +34,81 @@ import kotlin.collections.List
import kotlin.collections.Map
@Validated
@Api(value = "store", description = "The store API")
@RequestMapping("\${api.base-path:/v2}")
interface StoreApi {
fun getDelegate(): StoreApiDelegate = object: StoreApiDelegate {}
@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")])
@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(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: kotlin.String
): ResponseEntity<Unit> {
return getDelegate().deleteOrder(orderId);
fun deleteOrder(@Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") orderId: kotlin.String): ResponseEntity<Unit> {
return getDelegate().deleteOrder(orderId)
}
@ApiOperation(
value = "Returns pet inventories by status",
nickname = "getInventory",
notes = "Returns a map of status codes to quantities",
response = kotlin.Int::class,
responseContainer = "Map",
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.collections.Map::class, responseContainer = "Map")])
@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 getDelegate().getInventory();
return getDelegate().getInventory()
}
@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")])
@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) @ApiParam(value = "ID of pet that needs to be fetched", required=true) @PathVariable("orderId") orderId: kotlin.Long
): ResponseEntity<Order> {
return getDelegate().getOrderById(orderId);
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 getDelegate().getOrderById(orderId)
}
@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")])
@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"],
consumes = ["application/json"]
)
fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody order: Order
): ResponseEntity<Order> {
return getDelegate().placeOrder(order);
fun placeOrder(@Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody order: Order): ResponseEntity<Order> {
return getDelegate().placeOrder(order)
}
}

View File

@@ -1,10 +1,10 @@
package org.openapitools.api;
package org.openapitools.api
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import java.util.Optional
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Optional;
@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"])
@Controller
@RequestMapping("\${openapi.openAPIPetstore.base-path:/v2}")
class StoreApiController(

View File

@@ -6,13 +6,11 @@
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 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
@@ -36,144 +34,153 @@ import kotlin.collections.List
import kotlin.collections.Map
@Validated
@Api(value = "user", description = "The user API")
@RequestMapping("\${api.base-path:/v2}")
interface UserApi {
fun getDelegate(): UserApiDelegate = object: UserApiDelegate {}
@ApiOperation(
value = "Create user",
nickname = "createUser",
notes = "This can only be done by the logged in user.",
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@Operation(
summary = "Create user",
operationId = "createUser",
description = "This can only be done by the logged in user.",
responses = [
ApiResponse(responseCode = "200", description = "successful operation")
],
security = [ SecurityRequirement(name = "api_key") ]
)
@RequestMapping(
method = [RequestMethod.POST],
value = ["/user"],
consumes = ["application/json"]
)
fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody user: User
): ResponseEntity<Unit> {
return getDelegate().createUser(user);
fun createUser(@Parameter(description = "Created user object", required = true) @Valid @RequestBody user: User): ResponseEntity<Unit> {
return getDelegate().createUser(user)
}
@ApiOperation(
value = "Creates list of users with given input array",
nickname = "createUsersWithArrayInput",
notes = "",
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@Operation(
summary = "Creates list of users with given input array",
operationId = "createUsersWithArrayInput",
description = "",
responses = [
ApiResponse(responseCode = "200", description = "successful operation")
],
security = [ SecurityRequirement(name = "api_key") ]
)
@RequestMapping(
method = [RequestMethod.POST],
value = ["/user/createWithArray"],
consumes = ["application/json"]
)
fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: kotlin.collections.List<User>
): ResponseEntity<Unit> {
return getDelegate().createUsersWithArrayInput(user);
fun createUsersWithArrayInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody user: kotlin.collections.List<User>): ResponseEntity<Unit> {
return getDelegate().createUsersWithArrayInput(user)
}
@ApiOperation(
value = "Creates list of users with given input array",
nickname = "createUsersWithListInput",
notes = "",
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@Operation(
summary = "Creates list of users with given input array",
operationId = "createUsersWithListInput",
description = "",
responses = [
ApiResponse(responseCode = "200", description = "successful operation")
],
security = [ SecurityRequirement(name = "api_key") ]
)
@RequestMapping(
method = [RequestMethod.POST],
value = ["/user/createWithList"],
consumes = ["application/json"]
)
fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: kotlin.collections.List<User>
): ResponseEntity<Unit> {
return getDelegate().createUsersWithListInput(user);
fun createUsersWithListInput(@Parameter(description = "List of user object", required = true) @Valid @RequestBody user: kotlin.collections.List<User>): ResponseEntity<Unit> {
return getDelegate().createUsersWithListInput(user)
}
@ApiOperation(
value = "Delete user",
nickname = "deleteUser",
notes = "This can only be done by the logged in user.",
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")])
@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")
],
security = [ SecurityRequirement(name = "api_key") ]
)
@RequestMapping(
method = [RequestMethod.DELETE],
value = ["/user/{username}"]
)
fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true) @PathVariable("username") username: kotlin.String
): ResponseEntity<Unit> {
return getDelegate().deleteUser(username);
fun deleteUser(@Parameter(description = "The name that needs to be deleted", required = true) @PathVariable("username") username: kotlin.String): ResponseEntity<Unit> {
return getDelegate().deleteUser(username)
}
@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")])
@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(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required=true) @PathVariable("username") username: kotlin.String
): ResponseEntity<User> {
return getDelegate().getUserByName(username);
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 getDelegate().getUserByName(username)
}
@ApiOperation(
value = "Logs user into the system",
nickname = "loginUser",
notes = "",
response = kotlin.String::class)
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.String::class),ApiResponse(code = 400, message = "Invalid username/password supplied")])
@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 @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: kotlin.String
,@NotNull @ApiParam(value = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) password: kotlin.String
): ResponseEntity<kotlin.String> {
return getDelegate().loginUser(username, password);
fun loginUser(@NotNull @Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @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 getDelegate().loginUser(username, password)
}
@ApiOperation(
value = "Logs out current logged in user session",
nickname = "logoutUser",
notes = "",
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@Operation(
summary = "Logs out current logged in user session",
operationId = "logoutUser",
description = "",
responses = [
ApiResponse(responseCode = "200", description = "successful operation")
],
security = [ SecurityRequirement(name = "api_key") ]
)
@RequestMapping(
method = [RequestMethod.GET],
value = ["/user/logout"]
)
fun logoutUser(): ResponseEntity<Unit> {
return getDelegate().logoutUser();
return getDelegate().logoutUser()
}
@ApiOperation(
value = "Updated user",
nickname = "updateUser",
notes = "This can only be done by the logged in user.",
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid user supplied"),ApiResponse(code = 404, message = "User not found")])
@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")
],
security = [ SecurityRequirement(name = "api_key") ]
)
@RequestMapping(
method = [RequestMethod.PUT],
value = ["/user/{username}"],
consumes = ["application/json"]
)
fun updateUser(@ApiParam(value = "name that need to be deleted", required=true) @PathVariable("username") username: kotlin.String
,@ApiParam(value = "Updated user object" ,required=true ) @Valid @RequestBody user: User
): ResponseEntity<Unit> {
return getDelegate().updateUser(username, user);
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 user: User): ResponseEntity<Unit> {
return getDelegate().updateUser(username, user)
}
}

View File

@@ -1,10 +1,10 @@
package org.openapitools.api;
package org.openapitools.api
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import java.util.Optional
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Optional;
@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"])
@Controller
@RequestMapping("\${openapi.openAPIPetstore.base-path:/v2}")
class UserApiController(

View File

@@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
import io.swagger.v3.oas.annotations.media.Schema
/**
* A category for a pet
@@ -20,11 +20,11 @@ import io.swagger.annotations.ApiModelProperty
*/
data class Category(
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("name") val name: kotlin.String? = null
) {

View File

@@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
import io.swagger.v3.oas.annotations.media.Schema
/**
* Describes the result of uploading an image resource
@@ -21,13 +21,13 @@ import io.swagger.annotations.ApiModelProperty
*/
data class ModelApiResponse(
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("code") val code: kotlin.Int? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("type") val type: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("message") val message: kotlin.String? = null
) {

View File

@@ -12,7 +12,7 @@ import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
import io.swagger.v3.oas.annotations.media.Schema
/**
* An order for a pets from the pet store
@@ -25,22 +25,22 @@ import io.swagger.annotations.ApiModelProperty
*/
data class Order(
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("petId") val petId: kotlin.Long? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("quantity") val quantity: kotlin.Int? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,
@ApiModelProperty(example = "null", value = "Order Status")
@Schema(example = "null", description = "Order Status")
@field:JsonProperty("status") val status: Order.Status? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("complete") val complete: kotlin.Boolean? = false
) {
@@ -49,13 +49,10 @@ data class Order(
* Values: placed,approved,delivered
*/
enum class Status(val value: kotlin.String) {
@JsonProperty("placed") placed("placed"),
@JsonProperty("approved") approved("approved"),
@JsonProperty("delivered") delivered("delivered");
@JsonProperty("delivered") delivered("delivered")
}
}

View File

@@ -14,7 +14,7 @@ import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
import io.swagger.v3.oas.annotations.media.Schema
/**
* A pet for sale in the pet store
@@ -27,24 +27,24 @@ import io.swagger.annotations.ApiModelProperty
*/
data class Pet(
@ApiModelProperty(example = "doggie", required = true, value = "")
@Schema(example = "doggie", required = true, description = "")
@field:JsonProperty("name", required = true) val name: kotlin.String,
@ApiModelProperty(example = "null", required = true, value = "")
@Schema(example = "null", required = true, description = "")
@field:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List<kotlin.String>,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@field:Valid
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("category") val category: Category? = null,
@field:Valid
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("tags") val tags: kotlin.collections.List<Tag>? = null,
@ApiModelProperty(example = "null", value = "pet status in the store")
@Schema(example = "null", description = "pet status in the store")
@Deprecated(message = "")
@field:JsonProperty("status") val status: Pet.Status? = null
) {
@@ -54,13 +54,10 @@ data class Pet(
* Values: available,pending,sold
*/
enum class Status(val value: kotlin.String) {
@JsonProperty("available") available("available"),
@JsonProperty("pending") pending("pending"),
@JsonProperty("sold") sold("sold");
@JsonProperty("sold") sold("sold")
}
}

View File

@@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
import io.swagger.v3.oas.annotations.media.Schema
/**
* A tag for a pet
@@ -20,10 +20,10 @@ import io.swagger.annotations.ApiModelProperty
*/
data class Tag(
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("name") val name: kotlin.String? = null
) {

View File

@@ -11,7 +11,7 @@ import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
import io.swagger.v3.oas.annotations.media.Schema
/**
* A User who is purchasing from the pet store
@@ -26,28 +26,28 @@ import io.swagger.annotations.ApiModelProperty
*/
data class User(
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("username") val username: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("firstName") val firstName: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("lastName") val lastName: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("email") val email: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("password") val password: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@Schema(example = "null", description = "")
@field:JsonProperty("phone") val phone: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "User Status")
@Schema(example = "null", description = "User Status")
@field:JsonProperty("userStatus") val userStatus: kotlin.Int? = null
) {

View File

@@ -0,0 +1,835 @@
openapi: 3.0.0
info:
description: "This is a sample server Petstore server. For this sample, you can\
\ use the api key `special-key` to test the authorization filters."
license:
name: Apache-2.0
url: https://www.apache.org/licenses/LICENSE-2.0.html
title: OpenAPI Petstore
version: 1.0.0
externalDocs:
description: Find out more about Swagger
url: http://swagger.io
servers:
- url: http://petstore.swagger.io/v2
tags:
- description: Everything about your Pets
name: pet
- description: Access to Petstore orders
name: store
- description: Operations about user
name: user
paths:
/pet:
post:
description: ""
operationId: addPet
requestBody:
$ref: '#/components/requestBodies/Pet'
responses:
"200":
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
description: successful operation
"405":
description: Invalid input
security:
- petstore_auth:
- write:pets
- read:pets
summary: Add a new pet to the store
tags:
- pet
put:
description: ""
operationId: updatePet
requestBody:
$ref: '#/components/requestBodies/Pet'
responses:
"200":
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
description: successful operation
"400":
description: Invalid ID supplied
"404":
description: Pet not found
"405":
description: Validation exception
security:
- petstore_auth:
- write:pets
- read:pets
summary: Update an existing pet
tags:
- pet
/pet/findByStatus:
get:
description: Multiple status values can be provided with comma separated strings
operationId: findPetsByStatus
parameters:
- deprecated: true
description: Status values that need to be considered for filter
explode: false
in: query
name: status
required: true
schema:
items:
default: available
enum:
- available
- pending
- sold
type: string
type: array
style: form
responses:
"200":
content:
application/xml:
schema:
items:
$ref: '#/components/schemas/Pet'
type: array
application/json:
schema:
items:
$ref: '#/components/schemas/Pet'
type: array
description: successful operation
"400":
description: Invalid status value
security:
- petstore_auth:
- read:pets
summary: Finds Pets by status
tags:
- pet
/pet/findByTags:
get:
deprecated: true
description: "Multiple tags can be provided with comma separated strings. Use\
\ tag1, tag2, tag3 for testing."
operationId: findPetsByTags
parameters:
- description: Tags to filter by
explode: false
in: query
name: tags
required: true
schema:
items:
type: string
type: array
style: form
responses:
"200":
content:
application/xml:
schema:
items:
$ref: '#/components/schemas/Pet'
type: array
application/json:
schema:
items:
$ref: '#/components/schemas/Pet'
type: array
description: successful operation
"400":
description: Invalid tag value
security:
- petstore_auth:
- read:pets
summary: Finds Pets by tags
tags:
- pet
/pet/{petId}:
delete:
description: ""
operationId: deletePet
parameters:
- explode: false
in: header
name: api_key
required: false
schema:
type: string
style: simple
- description: Pet id to delete
explode: false
in: path
name: petId
required: true
schema:
format: int64
type: integer
style: simple
responses:
"400":
description: Invalid pet value
security:
- petstore_auth:
- write:pets
- read:pets
summary: Deletes a pet
tags:
- pet
get:
description: Returns a single pet
operationId: getPetById
parameters:
- description: ID of pet to return
explode: false
in: path
name: petId
required: true
schema:
format: int64
type: integer
style: simple
responses:
"200":
content:
application/xml:
schema:
$ref: '#/components/schemas/Pet'
application/json:
schema:
$ref: '#/components/schemas/Pet'
description: successful operation
"400":
description: Invalid ID supplied
"404":
description: Pet not found
security:
- api_key: []
summary: Find pet by ID
tags:
- pet
post:
description: ""
operationId: updatePetWithForm
parameters:
- description: ID of pet that needs to be updated
explode: false
in: path
name: petId
required: true
schema:
format: int64
type: integer
style: simple
requestBody:
$ref: '#/components/requestBodies/inline_object'
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
type: object
responses:
"405":
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:
description: ""
operationId: uploadFile
parameters:
- description: ID of pet to update
explode: false
in: path
name: petId
required: true
schema:
format: int64
type: integer
style: simple
requestBody:
$ref: '#/components/requestBodies/inline_object_1'
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
type: object
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:
description: ""
operationId: placeOrder
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
description: order placed for purchasing the pet
required: true
responses:
"200":
content:
application/xml:
schema:
$ref: '#/components/schemas/Order'
application/json:
schema:
$ref: '#/components/schemas/Order'
description: successful operation
"400":
description: Invalid Order
summary: Place an order for a pet
tags:
- store
/store/order/{orderId}:
delete:
description: For valid response try integer IDs with value < 1000. Anything
above 1000 or nonintegers will generate API errors
operationId: deleteOrder
parameters:
- description: ID of the order that needs to be deleted
explode: false
in: path
name: orderId
required: true
schema:
type: string
style: simple
responses:
"400":
description: Invalid ID supplied
"404":
description: Order not found
summary: Delete purchase order by ID
tags:
- store
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
explode: false
in: path
name: orderId
required: true
schema:
format: int64
maximum: 5
minimum: 1
type: integer
style: simple
responses:
"200":
content:
application/xml:
schema:
$ref: '#/components/schemas/Order'
application/json:
schema:
$ref: '#/components/schemas/Order'
description: successful operation
"400":
description: Invalid ID supplied
"404":
description: Order not found
summary: Find purchase order by ID
tags:
- store
/user:
post:
description: This can only be done by the logged in user.
operationId: createUser
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
description: Created user object
required: true
responses:
default:
description: successful operation
security:
- api_key: []
summary: Create user
tags:
- user
/user/createWithArray:
post:
description: ""
operationId: createUsersWithArrayInput
requestBody:
$ref: '#/components/requestBodies/UserArray'
responses:
default:
description: successful operation
security:
- api_key: []
summary: Creates list of users with given input array
tags:
- user
/user/createWithList:
post:
description: ""
operationId: createUsersWithListInput
requestBody:
$ref: '#/components/requestBodies/UserArray'
responses:
default:
description: successful operation
security:
- api_key: []
summary: Creates list of users with given input array
tags:
- user
/user/login:
get:
description: ""
operationId: loginUser
parameters:
- description: The user name for login
explode: true
in: query
name: username
required: true
schema:
pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$"
type: string
style: form
- description: The password for login in clear text
explode: true
in: query
name: password
required: true
schema:
type: string
style: form
responses:
"200":
content:
application/xml:
schema:
type: string
application/json:
schema:
type: string
description: successful operation
headers:
Set-Cookie:
description: Cookie authentication key for use with the `api_key` apiKey
authentication.
explode: false
schema:
example: AUTH_KEY=abcde12345; Path=/; HttpOnly
type: string
style: simple
X-Rate-Limit:
description: calls per hour allowed by the user
explode: false
schema:
format: int32
type: integer
style: simple
X-Expires-After:
description: date in UTC when token expires
explode: false
schema:
format: date-time
type: string
style: simple
"400":
description: Invalid username/password supplied
summary: Logs user into the system
tags:
- user
/user/logout:
get:
description: ""
operationId: logoutUser
responses:
default:
description: successful operation
security:
- api_key: []
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
explode: false
in: path
name: username
required: true
schema:
type: string
style: simple
responses:
"400":
description: Invalid username supplied
"404":
description: User not found
security:
- api_key: []
summary: Delete user
tags:
- user
get:
description: ""
operationId: getUserByName
parameters:
- description: The name that needs to be fetched. Use user1 for testing.
explode: false
in: path
name: username
required: true
schema:
type: string
style: simple
responses:
"200":
content:
application/xml:
schema:
$ref: '#/components/schemas/User'
application/json:
schema:
$ref: '#/components/schemas/User'
description: successful operation
"400":
description: Invalid username supplied
"404":
description: User not found
summary: Get user by user name
tags:
- user
put:
description: This can only be done by the logged in user.
operationId: updateUser
parameters:
- description: name that need to be deleted
explode: false
in: path
name: username
required: true
schema:
type: string
style: simple
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
description: Updated user object
required: true
responses:
"400":
description: Invalid user supplied
"404":
description: User not found
security:
- api_key: []
summary: Updated user
tags:
- user
components:
requestBodies:
UserArray:
content:
application/json:
schema:
items:
$ref: '#/components/schemas/User'
type: array
description: List of user object
required: true
Pet:
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
application/xml:
schema:
$ref: '#/components/schemas/Pet'
description: Pet object that needs to be added to the store
required: true
inline_object:
content:
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/inline_object'
inline_object_1:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/inline_object_1'
schemas:
Order:
description: An order for a pets from the pet store
example:
petId: 6
quantity: 1
id: 0
shipDate: 2000-01-23T04:56:07.000+00:00
complete: false
status: placed
properties:
id:
format: int64
type: integer
petId:
format: int64
type: integer
quantity:
format: int32
type: integer
shipDate:
format: date-time
type: string
status:
description: Order Status
enum:
- placed
- approved
- delivered
type: string
complete:
default: false
type: boolean
title: Pet Order
type: object
xml:
name: Order
Category:
description: A category for a pet
example:
name: name
id: 6
properties:
id:
format: int64
type: integer
name:
pattern: "^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$"
type: string
title: Pet category
type: object
xml:
name: Category
User:
description: A User who is purchasing from the pet store
example:
firstName: firstName
lastName: lastName
password: password
userStatus: 6
phone: phone
id: 0
email: email
username: username
properties:
id:
format: int64
type: integer
username:
type: string
firstName:
type: string
lastName:
type: string
email:
type: string
password:
type: string
phone:
type: string
userStatus:
description: User Status
format: int32
type: integer
title: a User
type: object
xml:
name: User
Tag:
description: A tag for a pet
example:
name: name
id: 1
properties:
id:
format: int64
type: integer
name:
type: string
title: Pet Tag
type: object
xml:
name: Tag
Pet:
description: A pet for sale in the pet store
example:
photoUrls:
- photoUrls
- photoUrls
name: doggie
id: 0
category:
name: name
id: 6
tags:
- name: name
id: 1
- name: name
id: 1
status: available
properties:
id:
format: int64
type: integer
category:
$ref: '#/components/schemas/Category'
name:
example: doggie
type: string
photoUrls:
items:
type: string
type: array
xml:
name: photoUrl
wrapped: true
tags:
items:
$ref: '#/components/schemas/Tag'
type: array
xml:
name: tag
wrapped: true
status:
deprecated: true
description: pet status in the store
enum:
- available
- pending
- sold
type: string
required:
- name
- photoUrls
title: a Pet
type: object
xml:
name: Pet
ApiResponse:
description: Describes the result of uploading an image resource
example:
code: 0
type: type
message: message
properties:
code:
format: int32
type: integer
type:
type: string
message:
type: string
title: An uploaded response
type: object
inline_object:
properties:
name:
description: Updated name of the pet
type: string
status:
description: Updated status of the pet
type: string
type: object
inline_object_1:
properties:
additionalMetadata:
description: Additional data to pass to server
type: string
file:
description: file to upload
format: binary
type: string
type: object
securitySchemes:
petstore_auth:
flows:
implicit:
authorizationUrl: http://petstore.swagger.io/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets
type: oauth2
api_key:
in: header
name: api_key
type: apiKey