move openapi 3 samples to the correct folder (#3267)

This commit is contained in:
William Cheng
2019-07-03 13:18:52 +08:00
committed by GitHub
parent b44f6c302a
commit 35262aa7d1
230 changed files with 6 additions and 6 deletions

View File

@@ -0,0 +1,14 @@
package org.openapitools
import org.springframework.boot.runApplication
import org.springframework.context.annotation.ComponentScan
import org.springframework.boot.autoconfigure.SpringBootApplication
@SpringBootApplication
@ComponentScan(basePackages = ["org.openapitools", "org.openapitools.api", "org.openapitools.model"])
class Application
fun main(args: Array<String>) {
runApplication<Application>(*args)
}

View File

@@ -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 })
}

View File

@@ -0,0 +1,185 @@
package org.openapitools.api
import org.openapitools.model.ModelApiResponse
import org.openapitools.model.Pet
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import io.swagger.annotations.ApiResponse
import io.swagger.annotations.ApiResponses
import io.swagger.annotations.Authorization
import io.swagger.annotations.AuthorizationScope
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestPart
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import javax.validation.Valid
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import kotlin.collections.List
import kotlin.collections.Map
@RestController
@Validated
@Api(value = "Pet", description = "The Pet API")
@RequestMapping("\${api.base-path:/v2}")
class PetApiController(@Autowired(required = true) val service: PetApiService) {
@ApiOperation(
value = "Add a new pet to the store",
nickname = "addPet",
notes = "",
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])])
@ApiResponses(
value = [ApiResponse(code = 405, message = "Invalid input")])
@RequestMapping(
value = ["/pet"],
consumes = ["application/json", "application/xml"],
method = [RequestMethod.POST])
fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet
): ResponseEntity<Unit> {
return ResponseEntity(service.addPet(pet), HttpStatus.OK)
}
@ApiOperation(
value = "Deletes a pet",
nickname = "deletePet",
notes = "",
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])])
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid pet value")])
@RequestMapping(
value = ["/pet/{petId}"],
method = [RequestMethod.DELETE])
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 ResponseEntity(service.deletePet(petId, apiKey), HttpStatus.OK)
}
@ApiOperation(
value = "Finds Pets by status",
nickname = "findPetsByStatus",
notes = "Multiple status values can be provided with comma separated strings",
response = Pet::class,
responseContainer = "List",
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "read:pets", description = "read your pets")])])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"),ApiResponse(code = 400, message = "Invalid status value")])
@RequestMapping(
value = ["/pet/findByStatus"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun findPetsByStatus(@NotNull @ApiParam(value = "Status values that need to be considered for filter", required = true, allowableValues = "available, pending, sold") @Valid @RequestParam(value = "status", required = true) status: kotlin.collections.List<kotlin.String>
): ResponseEntity<List<Pet>> {
return ResponseEntity(service.findPetsByStatus(status), HttpStatus.OK)
}
@ApiOperation(
value = "Finds Pets by tags",
nickname = "findPetsByTags",
notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.",
response = Pet::class,
responseContainer = "List",
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "read:pets", description = "read your pets")])])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class, responseContainer = "List"),ApiResponse(code = 400, message = "Invalid tag value")])
@RequestMapping(
value = ["/pet/findByTags"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun findPetsByTags(@NotNull @ApiParam(value = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) tags: kotlin.collections.List<kotlin.String>
,@ApiParam(value = "Maximum number of items to return") @Valid @RequestParam(value = "maxCount", required = false) maxCount: kotlin.Int?
): ResponseEntity<List<Pet>> {
return ResponseEntity(service.findPetsByTags(tags, maxCount), HttpStatus.OK)
}
@ApiOperation(
value = "Find pet by ID",
nickname = "getPetById",
notes = "Returns a single pet",
response = Pet::class,
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = Pet::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Pet not found")])
@RequestMapping(
value = ["/pet/{petId}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: kotlin.Long
): ResponseEntity<Pet> {
return ResponseEntity(service.getPetById(petId), HttpStatus.OK)
}
@ApiOperation(
value = "Update an existing pet",
nickname = "updatePet",
notes = "",
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])])
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Pet not found"),ApiResponse(code = 405, message = "Validation exception")])
@RequestMapping(
value = ["/pet"],
consumes = ["application/json", "application/xml"],
method = [RequestMethod.PUT])
fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet
): ResponseEntity<Unit> {
return ResponseEntity(service.updatePet(pet), HttpStatus.OK)
}
@ApiOperation(
value = "Updates a pet in the store with form data",
nickname = "updatePetWithForm",
notes = "",
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])])
@ApiResponses(
value = [ApiResponse(code = 405, message = "Invalid input")])
@RequestMapping(
value = ["/pet/{petId}"],
consumes = ["application/x-www-form-urlencoded"],
method = [RequestMethod.POST])
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 ResponseEntity(service.updatePetWithForm(petId, name, status), HttpStatus.OK)
}
@ApiOperation(
value = "uploads an image",
nickname = "uploadFile",
notes = "",
response = ModelApiResponse::class,
authorizations = [Authorization(value = "petstore_auth", scopes = [AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), AuthorizationScope(scope = "read:pets", description = "read your pets")])])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse::class)])
@RequestMapping(
value = ["/pet/{petId}/uploadImage"],
produces = ["application/json"],
consumes = ["multipart/form-data"],
method = [RequestMethod.POST])
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 ResponseEntity(service.uploadFile(petId, additionalMetadata, file), HttpStatus.OK)
}
}

View File

@@ -0,0 +1,22 @@
package org.openapitools.api
import org.openapitools.model.ModelApiResponse
import org.openapitools.model.Pet
interface PetApiService {
fun addPet(pet: Pet): Unit
fun deletePet(petId: kotlin.Long, apiKey: kotlin.String?): Unit
fun findPetsByStatus(status: kotlin.collections.List<kotlin.String>): List<Pet>
fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>, maxCount: kotlin.Int?): List<Pet>
fun getPetById(petId: kotlin.Long): Pet
fun updatePet(pet: Pet): Unit
fun updatePetWithForm(petId: kotlin.Long, name: kotlin.String?, status: kotlin.String?): Unit
fun uploadFile(petId: kotlin.Long, additionalMetadata: kotlin.String?, file: org.springframework.core.io.Resource?): ModelApiResponse
}

View File

@@ -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(pet: 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>, maxCount: kotlin.Int?): List<Pet> {
TODO("Implement me")
}
override fun getPetById(petId: kotlin.Long): Pet {
TODO("Implement me")
}
override fun updatePet(pet: 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")
}
}

View File

@@ -0,0 +1,108 @@
package org.openapitools.api
import org.openapitools.model.Order
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import io.swagger.annotations.ApiResponse
import io.swagger.annotations.ApiResponses
import io.swagger.annotations.Authorization
import io.swagger.annotations.AuthorizationScope
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestPart
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import javax.validation.Valid
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import kotlin.collections.List
import kotlin.collections.Map
@RestController
@Validated
@Api(value = "Store", description = "The Store API")
@RequestMapping("\${api.base-path:/v2}")
class StoreApiController(@Autowired(required = true) val service: StoreApiService) {
@ApiOperation(
value = "Delete purchase order by ID",
nickname = "deleteOrder",
notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors")
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Order not found")])
@RequestMapping(
value = ["/store/order/{orderId}"],
method = [RequestMethod.DELETE])
fun deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted", required=true) @PathVariable("orderId") orderId: kotlin.String
): ResponseEntity<Unit> {
return ResponseEntity(service.deleteOrder(orderId), HttpStatus.OK)
}
@ApiOperation(
value = "Returns pet inventories by status",
nickname = "getInventory",
notes = "Returns a map of status codes to quantities",
response = 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")])
@RequestMapping(
value = ["/store/inventory"],
produces = ["application/json"],
method = [RequestMethod.GET])
fun getInventory(): ResponseEntity<Map<String, kotlin.Int>> {
return ResponseEntity(service.getInventory(), HttpStatus.OK)
}
@ApiOperation(
value = "Find purchase order by ID",
nickname = "getOrderById",
notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions",
response = Order::class)
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid ID supplied"),ApiResponse(code = 404, message = "Order not found")])
@RequestMapping(
value = ["/store/order/{orderId}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
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 ResponseEntity(service.getOrderById(orderId), HttpStatus.OK)
}
@ApiOperation(
value = "Place an order for a pet",
nickname = "placeOrder",
notes = "",
response = Order::class)
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid Order")])
@RequestMapping(
value = ["/store/order"],
produces = ["application/xml", "application/json"],
consumes = ["application/json"],
method = [RequestMethod.POST])
fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody order: Order
): ResponseEntity<Order> {
return ResponseEntity(service.placeOrder(order), HttpStatus.OK)
}
}

View File

@@ -0,0 +1,13 @@
package org.openapitools.api
import org.openapitools.model.Order
interface StoreApiService {
fun deleteOrder(orderId: kotlin.String): Unit
fun getInventory(): Map<String, kotlin.Int>
fun getOrderById(orderId: kotlin.Long): Order
fun placeOrder(order: Order): Order
}

View File

@@ -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(order: Order): Order {
TODO("Implement me")
}
}

View File

@@ -0,0 +1,171 @@
package org.openapitools.api
import org.openapitools.model.User
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import io.swagger.annotations.ApiParam
import io.swagger.annotations.ApiResponse
import io.swagger.annotations.ApiResponses
import io.swagger.annotations.Authorization
import io.swagger.annotations.AuthorizationScope
import org.springframework.http.HttpStatus
import org.springframework.http.MediaType
import org.springframework.http.ResponseEntity
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestPart
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestHeader
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import javax.validation.Valid
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import kotlin.collections.List
import kotlin.collections.Map
@RestController
@Validated
@Api(value = "User", description = "The User API")
@RequestMapping("\${api.base-path:/v2}")
class UserApiController(@Autowired(required = true) val service: UserApiService) {
@ApiOperation(
value = "Create user",
nickname = "createUser",
notes = "This can only be done by the logged in user.",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
value = ["/user"],
consumes = ["application/json"],
method = [RequestMethod.POST])
fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody user: User
): ResponseEntity<Unit> {
return ResponseEntity(service.createUser(user), HttpStatus.OK)
}
@ApiOperation(
value = "Creates list of users with given input array",
nickname = "createUsersWithArrayInput",
notes = "",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
value = ["/user/createWithArray"],
consumes = ["application/json"],
method = [RequestMethod.POST])
fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: kotlin.collections.List<User>
): ResponseEntity<Unit> {
return ResponseEntity(service.createUsersWithArrayInput(user), HttpStatus.OK)
}
@ApiOperation(
value = "Creates list of users with given input array",
nickname = "createUsersWithListInput",
notes = "",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
value = ["/user/createWithList"],
consumes = ["application/json"],
method = [RequestMethod.POST])
fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: kotlin.collections.List<User>
): ResponseEntity<Unit> {
return ResponseEntity(service.createUsersWithListInput(user), HttpStatus.OK)
}
@ApiOperation(
value = "Delete user",
nickname = "deleteUser",
notes = "This can only be done by the logged in user.",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")])
@RequestMapping(
value = ["/user/{username}"],
method = [RequestMethod.DELETE])
fun deleteUser(@ApiParam(value = "The name that needs to be deleted", required=true) @PathVariable("username") username: kotlin.String
): ResponseEntity<Unit> {
return ResponseEntity(service.deleteUser(username), HttpStatus.OK)
}
@ApiOperation(
value = "Get user by user name",
nickname = "getUserByName",
notes = "",
response = User::class)
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = User::class),ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")])
@RequestMapping(
value = ["/user/{username}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
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 ResponseEntity(service.getUserByName(username), HttpStatus.OK)
}
@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")])
@RequestMapping(
value = ["/user/login"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
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 ResponseEntity(service.loginUser(username, password), HttpStatus.OK)
}
@ApiOperation(
value = "Logs out current logged in user session",
nickname = "logoutUser",
notes = "",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
value = ["/user/logout"],
method = [RequestMethod.GET])
fun logoutUser(): ResponseEntity<Unit> {
return ResponseEntity(service.logoutUser(), HttpStatus.OK)
}
@ApiOperation(
value = "Updated user",
nickname = "updateUser",
notes = "This can only be done by the logged in user.",
authorizations = [Authorization(value = "auth_cookie")])
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid user supplied"),ApiResponse(code = 404, message = "User not found")])
@RequestMapping(
value = ["/user/{username}"],
consumes = ["application/json"],
method = [RequestMethod.PUT])
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 ResponseEntity(service.updateUser(username, user), HttpStatus.OK)
}
}

View File

@@ -0,0 +1,21 @@
package org.openapitools.api
import org.openapitools.model.User
interface UserApiService {
fun createUser(user: User): Unit
fun createUsersWithArrayInput(user: kotlin.collections.List<User>): Unit
fun createUsersWithListInput(user: kotlin.collections.List<User>): Unit
fun deleteUser(username: kotlin.String): Unit
fun getUserByName(username: kotlin.String): User
fun loginUser(username: kotlin.String, password: kotlin.String): kotlin.String
fun logoutUser(): Unit
fun updateUser(username: kotlin.String, user: User): Unit
}

View File

@@ -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(user: User): Unit {
TODO("Implement me")
}
override fun createUsersWithArrayInput(user: kotlin.collections.List<User>): Unit {
TODO("Implement me")
}
override fun createUsersWithListInput(user: 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, user: User): Unit {
TODO("Implement me")
}
}

View File

@@ -0,0 +1,29 @@
package org.openapitools.model
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import io.swagger.annotations.ApiModelProperty
/**
* A category for a pet
* @param id
* @param name
*/
data class Category (
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: kotlin.Long? = null,
@get:Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$")
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name") val name: kotlin.String? = null
) {
}

View File

@@ -0,0 +1,29 @@
package org.openapitools.model
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import io.swagger.annotations.ApiModelProperty
/**
*
* @param name Updated name of the pet
* @param status Updated status of the pet
*/
data class InlineObject (
@ApiModelProperty(example = "null", value = "Updated name of the pet")
@JsonProperty("name") val name: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "Updated status of the pet")
@JsonProperty("status") val status: kotlin.String? = null
) {
}

View File

@@ -0,0 +1,29 @@
package org.openapitools.model
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import io.swagger.annotations.ApiModelProperty
/**
*
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
data class InlineObject1 (
@ApiModelProperty(example = "null", value = "Additional data to pass to server")
@JsonProperty("additionalMetadata") val additionalMetadata: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "file to upload")
@JsonProperty("file") val file: org.springframework.core.io.Resource? = null
) {
}

View File

@@ -0,0 +1,33 @@
package org.openapitools.model
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import io.swagger.annotations.ApiModelProperty
/**
* Describes the result of uploading an image resource
* @param code
* @param type
* @param message
*/
data class ModelApiResponse (
@ApiModelProperty(example = "null", value = "")
@JsonProperty("code") val code: kotlin.Int? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("type") val type: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("message") val message: kotlin.String? = null
) {
}

View File

@@ -0,0 +1,60 @@
package org.openapitools.model
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonValue
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import io.swagger.annotations.ApiModelProperty
/**
* An order for a pets from the pet store
* @param id
* @param petId
* @param quantity
* @param shipDate
* @param status Order Status
* @param complete
*/
data class Order (
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: kotlin.Long? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("petId") val petId: kotlin.Long? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("quantity") val quantity: kotlin.Int? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("shipDate") val shipDate: java.time.OffsetDateTime? = null,
@ApiModelProperty(example = "null", value = "Order Status")
@JsonProperty("status") val status: Order.Status? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("complete") val complete: kotlin.Boolean? = null
) {
/**
* 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");
}
}

View File

@@ -0,0 +1,64 @@
package org.openapitools.model
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonValue
import org.openapitools.model.Category
import org.openapitools.model.Tag
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import io.swagger.annotations.ApiModelProperty
/**
* A pet for sale in the pet store
* @param id
* @param category
* @param name
* @param photoUrls
* @param tags
* @param status pet status in the store
*/
data class Pet (
@get:NotNull
@ApiModelProperty(example = "doggie", required = true, value = "")
@JsonProperty("name") val name: kotlin.String,
@get:NotNull
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("photoUrls") val photoUrls: kotlin.collections.List<kotlin.String>,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: kotlin.Long? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("category") val category: Category? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("tags") val tags: kotlin.collections.List<Tag>? = null,
@ApiModelProperty(example = "null", value = "pet status in the store")
@JsonProperty("status") val status: Pet.Status? = null
) {
/**
* pet status in the store
* Values: available,pending,sold
*/
enum class Status(val value: kotlin.String) {
@JsonProperty("available") available("available"),
@JsonProperty("pending") pending("pending"),
@JsonProperty("sold") sold("sold");
}
}

View File

@@ -0,0 +1,29 @@
package org.openapitools.model
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import io.swagger.annotations.ApiModelProperty
/**
* A tag for a pet
* @param id
* @param name
*/
data class Tag (
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: kotlin.Long? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("name") val name: kotlin.String? = null
) {
}

View File

@@ -0,0 +1,53 @@
package org.openapitools.model
import java.util.Objects
import com.fasterxml.jackson.annotation.JsonProperty
import javax.validation.constraints.DecimalMax
import javax.validation.constraints.DecimalMin
import javax.validation.constraints.Max
import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import io.swagger.annotations.ApiModelProperty
/**
* A User who is purchasing from the pet store
* @param id
* @param username
* @param firstName
* @param lastName
* @param email
* @param password
* @param phone
* @param userStatus User Status
*/
data class User (
@ApiModelProperty(example = "null", value = "")
@JsonProperty("id") val id: kotlin.Long? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("username") val username: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("firstName") val firstName: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("lastName") val lastName: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("email") val email: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("password") val password: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "")
@JsonProperty("phone") val phone: kotlin.String? = null,
@ApiModelProperty(example = "null", value = "User Status")
@JsonProperty("userStatus") val userStatus: kotlin.Int? = null
) {
}

View File

@@ -0,0 +1,10 @@
spring:
application:
name: openAPIPetstore
jackson:
serialization:
WRITE_DATES_AS_TIMESTAMPS: false
server:
port: 8080