Skip to content

Fix MiskKotlin OpenApiGenerator types #21390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ public KotlinMiskServerCodegen() {
artifactId = "openapi-kotlin-misk-server";
artifactVersion = apiVersion;

typeMapping.put("array", "kotlin.collections.List");

updateOption(CodegenConstants.API_PACKAGE, apiPackage);
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
additionalProperties.put(ROOT_PACKAGE, rootPackage);
Expand Down Expand Up @@ -328,4 +330,4 @@ private static Map<String, String> getMappings() {

return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import misk.web.QueryParam
import misk.web.RequestBody
import misk.web.RequestContentType
import misk.web.RequestHeader
import misk.web.Response
import misk.web.ResponseContentType
import misk.web.mediatype.MediaTypes
{{#imports}}
Expand All @@ -50,10 +51,13 @@ class {{classname}}Action @Inject constructor(
{{#actionAnnotations}}
{{{.}}}
{{/actionAnnotations}}
fun {{operationId}}({{#allParams}}
{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}: {{{returnType}}}{{/returnType}} {
fun {{operationId}}(
{{#allParams}}
{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{^-last}}, {{/-last}}
{{/allParams}}
): {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response<Unit>{{/returnType}} {
TODO()
}
{{/operation}}
}
{{/operations}}
{{/operations}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{^isFile}}{{{dataType}}}{{^required}}{{^defaultValue}}?{{/defaultValue}}{{/required}}{{/isFile}}{{#isFile}}{{#isArray}}Array<{{/isArray}}{{#isArray}}>{{/isArray}}{{^isArray}}{{^required}}{{/required}}{{/isArray}}{{/isFile}}
{{^isFile}}{{{dataType}}}{{^required}}{{^defaultValue}}?{{/defaultValue}}{{/required}}{{/isFile}}{{#isFile}}{{#isArray}}kotlin.collections.List<{{/isArray}}{{#isArray}}>{{/isArray}}{{^isArray}}{{^required}}{{/required}}{{/isArray}}{{/isFile}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#isMap}}Map<String, {{{returnType}}}>{{/isMap}}{{#isArray}}{{{returnContainer}}}<{{{returnType}}}>{{/isArray}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}
{{#isMap}}Map<String, {{{returnType}}}>{{/isMap}}{{#isArray}}{{{returnContainer}}}<{{{returnType}}}>{{/isArray}}{{^returnContainer}}{{#isFile}}Response<ByteString>{{/isFile}}{{^isFile}}{{{returnType}}}{{/isFile}}{{/returnContainer}}
4 changes: 2 additions & 2 deletions samples/server/petstore/kotlin-misk-config/docs/Pet.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**name** | **kotlin.String** | |
**photoUrls** | **kotlin.Array&lt;kotlin.String&gt;** | |
**photoUrls** | **kotlin.collections.List&lt;kotlin.String&gt;** | |
**id** | **kotlin.Long** | | [optional]
**category** | [**Category**](Category.md) | | [optional]
**tags** | [**kotlin.Array&lt;Tag&gt;**](Tag.md) | | [optional]
**tags** | [**kotlin.collections.List&lt;Tag&gt;**](Tag.md) | | [optional]
**status** | [**inline**](#Status) | pet status in the store | [optional]


Expand Down
20 changes: 10 additions & 10 deletions samples/server/petstore/kotlin-misk-config/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ null (empty response body)

<a name="findPetsByStatus"></a>
# **findPetsByStatus**
> kotlin.Array&lt;Pet&gt; findPetsByStatus(status)
> kotlin.collections.List&lt;Pet&gt; findPetsByStatus(status)

Finds Pets by status

Expand All @@ -124,9 +124,9 @@ Multiple status values can be provided with comma separated strings
//import org.openapitools.server.api.model.*

val apiInstance = PetApi()
val status : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Status values that need to be considered for filter
val status : kotlin.collections.List<kotlin.String> = // kotlin.collections.List<kotlin.String> | Status values that need to be considered for filter
try {
val result : kotlin.Array<Pet> = apiInstance.findPetsByStatus(status)
val result : kotlin.collections.List<Pet> = apiInstance.findPetsByStatus(status)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#findPetsByStatus")
Expand All @@ -141,11 +141,11 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**status** | [**kotlin.Array&lt;kotlin.String&gt;**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold]
**status** | [**kotlin.collections.List&lt;kotlin.String&gt;**](kotlin.String.md)| Status values that need to be considered for filter | [enum: available, pending, sold]

### Return type

[**kotlin.Array&lt;Pet&gt;**](Pet.md)
[**kotlin.collections.List&lt;Pet&gt;**](Pet.md)

### Authorization

Expand All @@ -158,7 +158,7 @@ Name | Type | Description | Notes

<a name="findPetsByTags"></a>
# **findPetsByTags**
> kotlin.Array&lt;Pet&gt; findPetsByTags(tags)
> kotlin.collections.List&lt;Pet&gt; findPetsByTags(tags)

Finds Pets by tags

Expand All @@ -171,9 +171,9 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
//import org.openapitools.server.api.model.*

val apiInstance = PetApi()
val tags : kotlin.Array<kotlin.String> = // kotlin.Array<kotlin.String> | Tags to filter by
val tags : kotlin.collections.List<kotlin.String> = // kotlin.collections.List<kotlin.String> | Tags to filter by
try {
val result : kotlin.Array<Pet> = apiInstance.findPetsByTags(tags)
val result : kotlin.collections.List<Pet> = apiInstance.findPetsByTags(tags)
println(result)
} catch (e: ClientException) {
println("4xx response calling PetApi#findPetsByTags")
Expand All @@ -188,11 +188,11 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**tags** | [**kotlin.Array&lt;kotlin.String&gt;**](kotlin.String.md)| Tags to filter by |
**tags** | [**kotlin.collections.List&lt;kotlin.String&gt;**](kotlin.String.md)| Tags to filter by |

### Return type

[**kotlin.Array&lt;Pet&gt;**](Pet.md)
[**kotlin.collections.List&lt;Pet&gt;**](Pet.md)

### Authorization

Expand Down
8 changes: 4 additions & 4 deletions samples/server/petstore/kotlin-misk-config/docs/UserApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Creates list of users with given input array
//import org.openapitools.server.api.model.*

val apiInstance = UserApi()
val user : kotlin.Array<User> = // kotlin.Array<User> | List of user object
val user : kotlin.collections.List<User> = // kotlin.collections.List<User> | List of user object
try {
apiInstance.createUsersWithArrayInput(user)
} catch (e: ClientException) {
Expand All @@ -91,7 +91,7 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**kotlin.Array&lt;User&gt;**](User.md)| List of user object |
**user** | [**kotlin.collections.List&lt;User&gt;**](User.md)| List of user object |

### Return type

Expand Down Expand Up @@ -121,7 +121,7 @@ Creates list of users with given input array
//import org.openapitools.server.api.model.*

val apiInstance = UserApi()
val user : kotlin.Array<User> = // kotlin.Array<User> | List of user object
val user : kotlin.collections.List<User> = // kotlin.collections.List<User> | List of user object
try {
apiInstance.createUsersWithListInput(user)
} catch (e: ClientException) {
Expand All @@ -137,7 +137,7 @@ try {

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**user** | [**kotlin.Array&lt;User&gt;**](User.md)| List of user object |
**user** | [**kotlin.collections.List&lt;User&gt;**](User.md)| List of user object |

### Return type

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import misk.web.QueryParam
import misk.web.RequestBody
import misk.web.RequestContentType
import misk.web.RequestHeader
import misk.web.Response
import misk.web.ResponseContentType
import misk.web.mediatype.MediaTypes
import org.openapitools.server.api.model.ModelApiResponse
Expand All @@ -44,7 +45,8 @@ class PetApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun addPet(
@Valid @RequestBody pet: Pet): Pet {
@Valid @RequestBody pet: Pet
): Pet {
TODO()
}

Expand All @@ -54,7 +56,8 @@ class PetApiAction @Inject constructor(
@Suppress("unused")
fun deletePet(
@PathParam("petId") petId: kotlin.Long,
@RequestHeader(value = "api_key") apiKey: kotlin.String?) {
@RequestHeader(value = "api_key") apiKey: kotlin.String?
): Response<Unit> {
TODO()
}

Expand All @@ -64,7 +67,8 @@ class PetApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun findPetsByStatus(
@QueryParam(value = "status") status: kotlin.Array<kotlin.String>): kotlin.Array<Pet> {
@QueryParam(value = "status") status: kotlin.collections.List<kotlin.String>
): kotlin.collections.List<Pet> {
TODO()
}

Expand All @@ -74,7 +78,8 @@ class PetApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun findPetsByTags(
@QueryParam(value = "tags") tags: kotlin.Array<kotlin.String>): kotlin.Array<Pet> {
@QueryParam(value = "tags") tags: kotlin.collections.List<kotlin.String>
): kotlin.collections.List<Pet> {
TODO()
}

Expand All @@ -84,7 +89,8 @@ class PetApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun getPetById(
@PathParam("petId") petId: kotlin.Long): Pet {
@PathParam("petId") petId: kotlin.Long
): Pet {
TODO()
}

Expand All @@ -95,7 +101,8 @@ class PetApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun updatePet(
@Valid @RequestBody pet: Pet): Pet {
@Valid @RequestBody pet: Pet
): Pet {
TODO()
}

Expand All @@ -107,7 +114,8 @@ class PetApiAction @Inject constructor(
fun updatePetWithForm(
@PathParam("petId") petId: kotlin.Long,
@QueryParam(value = "name") name: kotlin.String? ,
@QueryParam(value = "status") status: kotlin.String? ) {
@QueryParam(value = "status") status: kotlin.String?
): Response<Unit> {
TODO()
}

Expand All @@ -120,7 +128,8 @@ class PetApiAction @Inject constructor(
fun uploadFile(
@PathParam("petId") petId: kotlin.Long,
@QueryParam(value = "additionalMetadata") additionalMetadata: kotlin.String? ,
@Valid file: HttpCall): ModelApiResponse {
@Valid file: HttpCall
): ModelApiResponse {
TODO()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import misk.web.QueryParam
import misk.web.RequestBody
import misk.web.RequestContentType
import misk.web.RequestHeader
import misk.web.Response
import misk.web.ResponseContentType
import misk.web.mediatype.MediaTypes
import org.openapitools.server.api.model.Order
Expand All @@ -41,7 +42,8 @@ class StoreApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun deleteOrder(
@PathParam("orderId") orderId: kotlin.String) {
@PathParam("orderId") orderId: kotlin.String
): Response<Unit> {
TODO()
}

Expand All @@ -50,7 +52,8 @@ class StoreApiAction @Inject constructor(
@ResponseContentType(MediaTypes.APPLICATION_JSON)
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun getInventory(): kotlin.collections.Map<kotlin.String, kotlin.Int> {
fun getInventory(
): kotlin.collections.Map<kotlin.String, kotlin.Int> {
TODO()
}

Expand All @@ -60,7 +63,8 @@ class StoreApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun getOrderById(
@Min(1L) @Max(5L) @PathParam("orderId") orderId: kotlin.Long): Order {
@Min(1L) @Max(5L) @PathParam("orderId") orderId: kotlin.Long
): Order {
TODO()
}

Expand All @@ -71,7 +75,8 @@ class StoreApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun placeOrder(
@Valid @RequestBody order: Order): Order {
@Valid @RequestBody order: Order
): Order {
TODO()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import misk.web.QueryParam
import misk.web.RequestBody
import misk.web.RequestContentType
import misk.web.RequestHeader
import misk.web.Response
import misk.web.ResponseContentType
import misk.web.mediatype.MediaTypes
import org.openapitools.server.api.model.User
Expand All @@ -42,7 +43,8 @@ class UserApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun createUser(
@Valid @RequestBody user: User) {
@Valid @RequestBody user: User
): Response<Unit> {
TODO()
}

Expand All @@ -52,7 +54,8 @@ class UserApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun createUsersWithArrayInput(
@Valid @RequestBody user: kotlin.Array<User>) {
@Valid @RequestBody user: kotlin.collections.List<User>
): Response<Unit> {
TODO()
}

Expand All @@ -62,7 +65,8 @@ class UserApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun createUsersWithListInput(
@Valid @RequestBody user: kotlin.Array<User>) {
@Valid @RequestBody user: kotlin.collections.List<User>
): Response<Unit> {
TODO()
}

Expand All @@ -71,7 +75,8 @@ class UserApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun deleteUser(
@PathParam("username") username: kotlin.String) {
@PathParam("username") username: kotlin.String
): Response<Unit> {
TODO()
}

Expand All @@ -81,7 +86,8 @@ class UserApiAction @Inject constructor(
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun getUserByName(
@PathParam("username") username: kotlin.String): User {
@PathParam("username") username: kotlin.String
): User {
TODO()
}

Expand All @@ -92,15 +98,17 @@ class UserApiAction @Inject constructor(
@Suppress("unused")
fun loginUser(
@QueryParam(value = "username") username: kotlin.String,
@QueryParam(value = "password") password: kotlin.String): kotlin.String {
@QueryParam(value = "password") password: kotlin.String
): kotlin.String {
TODO()
}

@Get("samplePrefix/user/logout")
@Description("Logs out current logged in user session")
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
@Suppress("unused")
fun logoutUser() {
fun logoutUser(
): Response<Unit> {
TODO()
}

Expand All @@ -111,7 +119,8 @@ class UserApiAction @Inject constructor(
@Suppress("unused")
fun updateUser(
@PathParam("username") username: kotlin.String,
@Valid @RequestBody user: User) {
@Valid @RequestBody user: User
): Response<Unit> {
TODO()
}
}
Loading
Loading