[kotlin] fix Date types usages (#8594)

* [kotlin] fix Date types usages
This commit is contained in:
Bruno Coelho
2021-02-03 01:55:51 +00:00
committed by GitHub
parent b78d4fce6a
commit 45fc02350b
151 changed files with 660 additions and 790 deletions

View File

@@ -13,14 +13,7 @@ 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.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
@@ -52,11 +45,11 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
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")])
@RequestMapping(
@PostMapping(
value = ["/pet"],
produces = ["application/xml", "application/json"],
consumes = ["application/json", "application/xml"],
method = [RequestMethod.POST])
produces = ["application/xml", "application/json"],
consumes = ["application/json", "application/xml"]
)
suspend fun addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet
): ResponseEntity<Pet> {
return ResponseEntity(service.addPet(pet), HttpStatus.valueOf(200))
@@ -69,9 +62,9 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
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])
@DeleteMapping(
value = ["/pet/{petId}"]
)
suspend 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> {
@@ -87,10 +80,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
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(
@GetMapping(
value = ["/pet/findByStatus"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
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<Flow<Pet>> {
return ResponseEntity(service.findPetsByStatus(status), HttpStatus.valueOf(200))
@@ -105,10 +98,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
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(
@GetMapping(
value = ["/pet/findByTags"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
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<Flow<Pet>> {
return ResponseEntity(service.findPetsByTags(tags), HttpStatus.valueOf(200))
@@ -122,10 +115,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
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(
@GetMapping(
value = ["/pet/{petId}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
produces = ["application/xml", "application/json"]
)
suspend fun getPetById(@ApiParam(value = "ID of pet to return", required=true) @PathVariable("petId") petId: kotlin.Long
): ResponseEntity<Pet> {
return ResponseEntity(service.getPetById(petId), HttpStatus.valueOf(200))
@@ -139,11 +132,11 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
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")])
@RequestMapping(
@PutMapping(
value = ["/pet"],
produces = ["application/xml", "application/json"],
consumes = ["application/json", "application/xml"],
method = [RequestMethod.PUT])
produces = ["application/xml", "application/json"],
consumes = ["application/json", "application/xml"]
)
suspend fun updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true ) @Valid @RequestBody pet: Pet
): ResponseEntity<Pet> {
return ResponseEntity(service.updatePet(pet), HttpStatus.valueOf(200))
@@ -156,10 +149,10 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
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(
@PostMapping(
value = ["/pet/{petId}"],
consumes = ["application/x-www-form-urlencoded"],
method = [RequestMethod.POST])
consumes = ["application/x-www-form-urlencoded"]
)
suspend 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?
@@ -175,11 +168,11 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
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(
@PostMapping(
value = ["/pet/{petId}/uploadImage"],
produces = ["application/json"],
consumes = ["multipart/form-data"],
method = [RequestMethod.POST])
produces = ["application/json"],
consumes = ["multipart/form-data"]
)
suspend 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?

View File

@@ -12,14 +12,7 @@ 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.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
@@ -49,9 +42,9 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
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])
@DeleteMapping(
value = ["/store/order/{orderId}"]
)
suspend 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.valueOf(400))
@@ -66,10 +59,10 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = kotlin.collections.Map::class, responseContainer = "Map")])
@RequestMapping(
@GetMapping(
value = ["/store/inventory"],
produces = ["application/json"],
method = [RequestMethod.GET])
produces = ["application/json"]
)
suspend fun getInventory(): ResponseEntity<Map<String, kotlin.Int>> {
return ResponseEntity(service.getInventory(), HttpStatus.valueOf(200))
}
@@ -81,10 +74,10 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
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(
@GetMapping(
value = ["/store/order/{orderId}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
produces = ["application/xml", "application/json"]
)
suspend 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.valueOf(200))
@@ -97,11 +90,11 @@ class StoreApiController(@Autowired(required = true) val service: StoreApiServic
response = Order::class)
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation", response = Order::class),ApiResponse(code = 400, message = "Invalid Order")])
@RequestMapping(
@PostMapping(
value = ["/store/order"],
produces = ["application/xml", "application/json"],
consumes = ["application/json"],
method = [RequestMethod.POST])
produces = ["application/xml", "application/json"],
consumes = ["application/json"]
)
suspend fun placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true ) @Valid @RequestBody order: Order
): ResponseEntity<Order> {
return ResponseEntity(service.placeOrder(order), HttpStatus.valueOf(200))

View File

@@ -12,14 +12,7 @@ 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.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
@@ -50,10 +43,10 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
@PostMapping(
value = ["/user"],
consumes = ["application/json"],
method = [RequestMethod.POST])
consumes = ["application/json"]
)
suspend fun createUser(@ApiParam(value = "Created user object" ,required=true ) @Valid @RequestBody user: User
): ResponseEntity<Unit> {
return ResponseEntity(service.createUser(user), HttpStatus.valueOf(200))
@@ -66,10 +59,10 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
@PostMapping(
value = ["/user/createWithArray"],
consumes = ["application/json"],
method = [RequestMethod.POST])
consumes = ["application/json"]
)
suspend fun createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: Flow<User>
): ResponseEntity<Unit> {
return ResponseEntity(service.createUsersWithArrayInput(user), HttpStatus.valueOf(200))
@@ -82,10 +75,10 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
@PostMapping(
value = ["/user/createWithList"],
consumes = ["application/json"],
method = [RequestMethod.POST])
consumes = ["application/json"]
)
suspend fun createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true ) @Valid @RequestBody user: Flow<User>
): ResponseEntity<Unit> {
return ResponseEntity(service.createUsersWithListInput(user), HttpStatus.valueOf(200))
@@ -98,9 +91,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid username supplied"),ApiResponse(code = 404, message = "User not found")])
@RequestMapping(
value = ["/user/{username}"],
method = [RequestMethod.DELETE])
@DeleteMapping(
value = ["/user/{username}"]
)
suspend 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.valueOf(400))
@@ -113,10 +106,10 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
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(
@GetMapping(
value = ["/user/{username}"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
produces = ["application/xml", "application/json"]
)
suspend 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.valueOf(200))
@@ -129,10 +122,10 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
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(
@GetMapping(
value = ["/user/login"],
produces = ["application/xml", "application/json"],
method = [RequestMethod.GET])
produces = ["application/xml", "application/json"]
)
suspend fun loginUser(@NotNull @Pattern(regexp="^[a-zA-Z0-9]+[a-zA-Z0-9\\.\\-_]*[a-zA-Z0-9]+$") @ApiParam(value = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) username: 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> {
@@ -146,9 +139,9 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 200, message = "successful operation")])
@RequestMapping(
value = ["/user/logout"],
method = [RequestMethod.GET])
@GetMapping(
value = ["/user/logout"]
)
suspend fun logoutUser(): ResponseEntity<Unit> {
return ResponseEntity(service.logoutUser(), HttpStatus.valueOf(200))
}
@@ -160,10 +153,10 @@ class UserApiController(@Autowired(required = true) val service: UserApiService)
authorizations = [Authorization(value = "api_key")])
@ApiResponses(
value = [ApiResponse(code = 400, message = "Invalid user supplied"),ApiResponse(code = 404, message = "User not found")])
@RequestMapping(
@PutMapping(
value = ["/user/{username}"],
consumes = ["application/json"],
method = [RequestMethod.PUT])
consumes = ["application/json"]
)
suspend 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> {

View File

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

View File

@@ -9,6 +9,7 @@ import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
/**

View File

@@ -10,6 +10,7 @@ import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
/**
@@ -39,7 +40,7 @@ data class Order(
@field:JsonProperty("status") val status: Order.Status? = null,
@ApiModelProperty(example = "null", value = "")
@field:JsonProperty("complete") val complete: kotlin.Boolean? = null
@field:JsonProperty("complete") val complete: kotlin.Boolean? = false
) {
/**

View File

@@ -12,6 +12,7 @@ import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
/**
@@ -25,20 +26,20 @@ import io.swagger.annotations.ApiModelProperty
*/
data class Pet(
@get:NotNull
@ApiModelProperty(example = "doggie", required = true, value = "")
@field:JsonProperty("name") val name: kotlin.String,
@field:JsonProperty("name", required = true) val name: kotlin.String,
@get:NotNull
@ApiModelProperty(example = "null", required = true, value = "")
@field:JsonProperty("photoUrls") val photoUrls: kotlin.collections.List<kotlin.String>,
@field:JsonProperty("photoUrls", required = true) val photoUrls: kotlin.collections.List<kotlin.String>,
@ApiModelProperty(example = "null", value = "")
@field:JsonProperty("id") val id: kotlin.Long? = null,
@field:Valid
@ApiModelProperty(example = "null", value = "")
@field:JsonProperty("category") val category: Category? = null,
@field:Valid
@ApiModelProperty(example = "null", value = "")
@field:JsonProperty("tags") val tags: kotlin.collections.List<Tag>? = null,

View File

@@ -9,6 +9,7 @@ import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
/**

View File

@@ -9,6 +9,7 @@ import javax.validation.constraints.Min
import javax.validation.constraints.NotNull
import javax.validation.constraints.Pattern
import javax.validation.constraints.Size
import javax.validation.Valid
import io.swagger.annotations.ApiModelProperty
/**