Issue 1025: Kotlin generator doesn't support inheritance (#1026)

* allVars is duplicating child preoperties when models are inherited. Filter out these duplicates in the KotlinSpringServerCodegen
  * isInherited property was not being populated in the CodegenModel, re-parse the models in the KotlinSpringServerCodegen class and populate the property here
  * Add template support for Kotlin models which require inheritance from a base class to support oneOf declarations in the api yaml
  * Change optional for parameters to use Kotlins nullable
  * Update petstore api with Optional -> Nullable
This commit is contained in:
Brian Mooney
2018-09-19 11:26:47 +01:00
committed by Adam Drakeford
parent 78fae0ea49
commit b7edad5cd0
14 changed files with 60 additions and 21 deletions

View File

@@ -56,7 +56,7 @@ class PetApiController(@Autowired(required = true) val service: PetApiService) {
@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> {
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)
}

View File

@@ -7,7 +7,7 @@ interface PetApiService {
fun addPet(pet: Pet): Unit
fun deletePet(petId: kotlin.Long,apiKey: kotlin.String): Unit
fun deletePet(petId: kotlin.Long,apiKey: kotlin.String?): Unit
fun findPetsByStatus(status: kotlin.Array<kotlin.String>): List<Pet>
@@ -17,7 +17,7 @@ interface PetApiService {
fun updatePet(pet: Pet): Unit
fun updatePetWithForm(petId: kotlin.Long,name: kotlin.String,status: kotlin.String): Unit
fun updatePetWithForm(petId: kotlin.Long,name: kotlin.String?,status: kotlin.String?): Unit
fun uploadFile(petId: kotlin.Long,additionalMetadata: kotlin.String,file: org.springframework.web.multipart.MultipartFile): ModelApiResponse
fun uploadFile(petId: kotlin.Long,additionalMetadata: kotlin.String?,file: org.springframework.web.multipart.MultipartFile): ModelApiResponse
}

View File

@@ -11,7 +11,7 @@ class PetApiServiceImpl : PetApiService {
TODO("Implement me")
}
override fun deletePet(petId: kotlin.Long,apiKey: kotlin.String): Unit {
override fun deletePet(petId: kotlin.Long,apiKey: kotlin.String?): Unit {
TODO("Implement me")
}
@@ -31,11 +31,11 @@ class PetApiServiceImpl : PetApiService {
TODO("Implement me")
}
override fun updatePetWithForm(petId: kotlin.Long,name: kotlin.String,status: kotlin.String): Unit {
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.web.multipart.MultipartFile): ModelApiResponse {
override fun uploadFile(petId: kotlin.Long,additionalMetadata: kotlin.String?,file: org.springframework.web.multipart.MultipartFile): ModelApiResponse {
TODO("Implement me")
}
}