Skip to content

Commit 7d5c279

Browse files
author
andrewwilsonnew
committed
first pass
1 parent eb8ce73 commit 7d5c279

9 files changed

Lines changed: 97 additions & 45 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinMiskServerCodegen.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ public KotlinMiskServerCodegen() {
172172
artifactId = "openapi-kotlin-misk-server";
173173
artifactVersion = apiVersion;
174174

175+
typeMapping.put("File", "Response<ByteString>");
176+
175177
updateOption(CodegenConstants.API_PACKAGE, apiPackage);
176178
updateOption(CodegenConstants.MODEL_PACKAGE, modelPackage);
177179
additionalProperties.put(ROOT_PACKAGE, rootPackage);
@@ -328,4 +330,4 @@ private static Map<String, String> getMappings() {
328330

329331
return result;
330332
}
331-
}
333+
}

modules/openapi-generator/src/main/resources/kotlin-misk/apiAction.mustache

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import misk.web.QueryParam
2828
import misk.web.RequestBody
2929
import misk.web.RequestContentType
3030
import misk.web.RequestHeader
31+
import misk.web.Response
3132
import misk.web.ResponseContentType
3233
import misk.web.mediatype.MediaTypes
3334
{{#imports}}
@@ -50,10 +51,13 @@ class {{classname}}Action @Inject constructor(
5051
{{#actionAnnotations}}
5152
{{{.}}}
5253
{{/actionAnnotations}}
53-
fun {{operationId}}({{#allParams}}
54-
{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{^-last}}, {{/-last}}{{/allParams}}){{#returnType}}: {{{returnType}}}{{/returnType}} {
54+
fun {{operationId}}(
55+
{{#allParams}}
56+
{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>cookieParams}}{{>bodyParams}}{{>formParams}}{{^-last}}, {{/-last}}
57+
{{/allParams}}
58+
): {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Response<Unit>{{/returnType}} {
5559
TODO()
5660
}
5761
{{/operation}}
5862
}
59-
{{/operations}}
63+
{{/operations}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{^isFile}}{{{dataType}}}{{^required}}{{^defaultValue}}?{{/defaultValue}}{{/required}}{{/isFile}}{{#isFile}}{{#isArray}}Array<{{/isArray}}{{#isArray}}>{{/isArray}}{{^isArray}}{{^required}}{{/required}}{{/isArray}}{{/isFile}}
1+
{{^isFile}}{{{dataType}}}{{^required}}{{^defaultValue}}?{{/defaultValue}}{{/required}}{{/isFile}}{{#isFile}}{{#isArray}}List<{{/isArray}}{{#isArray}}>{{/isArray}}{{^isArray}}{{^required}}{{/required}}{{/isArray}}{{/isFile}}

samples/server/petstore/kotlin-misk-config/src/main/kotlin/org/openapitools/server/api/api/PetApiAction.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import misk.web.QueryParam
2525
import misk.web.RequestBody
2626
import misk.web.RequestContentType
2727
import misk.web.RequestHeader
28+
import misk.web.Response
2829
import misk.web.ResponseContentType
2930
import misk.web.mediatype.MediaTypes
3031
import org.openapitools.server.api.model.ModelApiResponse
@@ -44,7 +45,8 @@ class PetApiAction @Inject constructor(
4445
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
4546
@Suppress("unused")
4647
fun addPet(
47-
@Valid @RequestBody pet: Pet): Pet {
48+
@Valid @RequestBody pet: Pet
49+
): Pet {
4850
TODO()
4951
}
5052

@@ -54,7 +56,8 @@ class PetApiAction @Inject constructor(
5456
@Suppress("unused")
5557
fun deletePet(
5658
@PathParam("petId") petId: kotlin.Long,
57-
@RequestHeader(value = "api_key") apiKey: kotlin.String?) {
59+
@RequestHeader(value = "api_key") apiKey: kotlin.String?
60+
): Response<Unit> {
5861
TODO()
5962
}
6063

@@ -64,7 +67,8 @@ class PetApiAction @Inject constructor(
6467
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
6568
@Suppress("unused")
6669
fun findPetsByStatus(
67-
@QueryParam(value = "status") status: kotlin.Array<kotlin.String>): kotlin.Array<Pet> {
70+
@QueryParam(value = "status") status: kotlin.Array<kotlin.String>
71+
): kotlin.Array<Pet> {
6872
TODO()
6973
}
7074

@@ -74,7 +78,8 @@ class PetApiAction @Inject constructor(
7478
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
7579
@Suppress("unused")
7680
fun findPetsByTags(
77-
@QueryParam(value = "tags") tags: kotlin.Array<kotlin.String>): kotlin.Array<Pet> {
81+
@QueryParam(value = "tags") tags: kotlin.Array<kotlin.String>
82+
): kotlin.Array<Pet> {
7883
TODO()
7984
}
8085

@@ -84,7 +89,8 @@ class PetApiAction @Inject constructor(
8489
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
8590
@Suppress("unused")
8691
fun getPetById(
87-
@PathParam("petId") petId: kotlin.Long): Pet {
92+
@PathParam("petId") petId: kotlin.Long
93+
): Pet {
8894
TODO()
8995
}
9096

@@ -95,7 +101,8 @@ class PetApiAction @Inject constructor(
95101
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
96102
@Suppress("unused")
97103
fun updatePet(
98-
@Valid @RequestBody pet: Pet): Pet {
104+
@Valid @RequestBody pet: Pet
105+
): Pet {
99106
TODO()
100107
}
101108

@@ -107,7 +114,8 @@ class PetApiAction @Inject constructor(
107114
fun updatePetWithForm(
108115
@PathParam("petId") petId: kotlin.Long,
109116
@QueryParam(value = "name") name: kotlin.String? ,
110-
@QueryParam(value = "status") status: kotlin.String? ) {
117+
@QueryParam(value = "status") status: kotlin.String?
118+
): Response<Unit> {
111119
TODO()
112120
}
113121

@@ -120,7 +128,8 @@ class PetApiAction @Inject constructor(
120128
fun uploadFile(
121129
@PathParam("petId") petId: kotlin.Long,
122130
@QueryParam(value = "additionalMetadata") additionalMetadata: kotlin.String? ,
123-
@Valid file: HttpCall): ModelApiResponse {
131+
@Valid file: HttpCall
132+
): ModelApiResponse {
124133
TODO()
125134
}
126135
}

samples/server/petstore/kotlin-misk-config/src/main/kotlin/org/openapitools/server/api/api/StoreApiAction.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import misk.web.QueryParam
2525
import misk.web.RequestBody
2626
import misk.web.RequestContentType
2727
import misk.web.RequestHeader
28+
import misk.web.Response
2829
import misk.web.ResponseContentType
2930
import misk.web.mediatype.MediaTypes
3031
import org.openapitools.server.api.model.Order
@@ -41,7 +42,8 @@ class StoreApiAction @Inject constructor(
4142
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
4243
@Suppress("unused")
4344
fun deleteOrder(
44-
@PathParam("orderId") orderId: kotlin.String) {
45+
@PathParam("orderId") orderId: kotlin.String
46+
): Response<Unit> {
4547
TODO()
4648
}
4749

@@ -50,7 +52,8 @@ class StoreApiAction @Inject constructor(
5052
@ResponseContentType(MediaTypes.APPLICATION_JSON)
5153
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
5254
@Suppress("unused")
53-
fun getInventory(): kotlin.collections.Map<kotlin.String, kotlin.Int> {
55+
fun getInventory(
56+
): kotlin.collections.Map<kotlin.String, kotlin.Int> {
5457
TODO()
5558
}
5659

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

@@ -71,7 +75,8 @@ class StoreApiAction @Inject constructor(
7175
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
7276
@Suppress("unused")
7377
fun placeOrder(
74-
@Valid @RequestBody order: Order): Order {
78+
@Valid @RequestBody order: Order
79+
): Order {
7580
TODO()
7681
}
7782
}

samples/server/petstore/kotlin-misk-config/src/main/kotlin/org/openapitools/server/api/api/UserApiAction.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import misk.web.QueryParam
2525
import misk.web.RequestBody
2626
import misk.web.RequestContentType
2727
import misk.web.RequestHeader
28+
import misk.web.Response
2829
import misk.web.ResponseContentType
2930
import misk.web.mediatype.MediaTypes
3031
import org.openapitools.server.api.model.User
@@ -42,7 +43,8 @@ class UserApiAction @Inject constructor(
4243
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
4344
@Suppress("unused")
4445
fun createUser(
45-
@Valid @RequestBody user: User) {
46+
@Valid @RequestBody user: User
47+
): Response<Unit> {
4648
TODO()
4749
}
4850

@@ -52,7 +54,8 @@ class UserApiAction @Inject constructor(
5254
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
5355
@Suppress("unused")
5456
fun createUsersWithArrayInput(
55-
@Valid @RequestBody user: kotlin.Array<User>) {
57+
@Valid @RequestBody user: kotlin.Array<User>
58+
): Response<Unit> {
5659
TODO()
5760
}
5861

@@ -62,7 +65,8 @@ class UserApiAction @Inject constructor(
6265
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
6366
@Suppress("unused")
6467
fun createUsersWithListInput(
65-
@Valid @RequestBody user: kotlin.Array<User>) {
68+
@Valid @RequestBody user: kotlin.Array<User>
69+
): Response<Unit> {
6670
TODO()
6771
}
6872

@@ -71,7 +75,8 @@ class UserApiAction @Inject constructor(
7175
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
7276
@Suppress("unused")
7377
fun deleteUser(
74-
@PathParam("username") username: kotlin.String) {
78+
@PathParam("username") username: kotlin.String
79+
): Response<Unit> {
7580
TODO()
7681
}
7782

@@ -81,7 +86,8 @@ class UserApiAction @Inject constructor(
8186
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
8287
@Suppress("unused")
8388
fun getUserByName(
84-
@PathParam("username") username: kotlin.String): User {
89+
@PathParam("username") username: kotlin.String
90+
): User {
8591
TODO()
8692
}
8793

@@ -92,15 +98,17 @@ class UserApiAction @Inject constructor(
9298
@Suppress("unused")
9399
fun loginUser(
94100
@QueryParam(value = "username") username: kotlin.String,
95-
@QueryParam(value = "password") password: kotlin.String): kotlin.String {
101+
@QueryParam(value = "password") password: kotlin.String
102+
): kotlin.String {
96103
TODO()
97104
}
98105

99106
@Get("samplePrefix/user/logout")
100107
@Description("Logs out current logged in user session")
101108
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 2.0)
102109
@Suppress("unused")
103-
fun logoutUser() {
110+
fun logoutUser(
111+
): Response<Unit> {
104112
TODO()
105113
}
106114

@@ -111,7 +119,8 @@ class UserApiAction @Inject constructor(
111119
@Suppress("unused")
112120
fun updateUser(
113121
@PathParam("username") username: kotlin.String,
114-
@Valid @RequestBody user: User) {
122+
@Valid @RequestBody user: User
123+
): Response<Unit> {
115124
TODO()
116125
}
117126
}

samples/server/petstore/kotlin-misk/src/main/kotlin/org/openapitools/server/api/api/PetApiAction.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import misk.web.QueryParam
2525
import misk.web.RequestBody
2626
import misk.web.RequestContentType
2727
import misk.web.RequestHeader
28+
import misk.web.Response
2829
import misk.web.ResponseContentType
2930
import misk.web.mediatype.MediaTypes
3031
import org.openapitools.server.api.model.ModelApiResponse
@@ -43,7 +44,8 @@ class PetApiAction @Inject constructor(
4344
@ResponseContentType(MediaTypes.APPLICATION_XML, MediaTypes.APPLICATION_JSON)
4445
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 1.0)
4546
fun addPet(
46-
@Valid @RequestBody pet: Pet): Pet {
47+
@Valid @RequestBody pet: Pet
48+
): Pet {
4749
TODO()
4850
}
4951

@@ -52,7 +54,8 @@ class PetApiAction @Inject constructor(
5254
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 1.0)
5355
fun deletePet(
5456
@PathParam("petId") petId: kotlin.Long,
55-
@RequestHeader(value = "api_key") apiKey: kotlin.String?) {
57+
@RequestHeader(value = "api_key") apiKey: kotlin.String?
58+
): Response<Unit> {
5659
TODO()
5760
}
5861

@@ -61,7 +64,8 @@ class PetApiAction @Inject constructor(
6164
@ResponseContentType(MediaTypes.APPLICATION_XML, MediaTypes.APPLICATION_JSON)
6265
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 1.0)
6366
fun findPetsByStatus(
64-
@QueryParam(value = "status") status: kotlin.Array<kotlin.String>): kotlin.Array<Pet> {
67+
@QueryParam(value = "status") status: kotlin.Array<kotlin.String>
68+
): kotlin.Array<Pet> {
6569
TODO()
6670
}
6771

@@ -70,7 +74,8 @@ class PetApiAction @Inject constructor(
7074
@ResponseContentType(MediaTypes.APPLICATION_XML, MediaTypes.APPLICATION_JSON)
7175
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 1.0)
7276
fun findPetsByTags(
73-
@QueryParam(value = "tags") tags: kotlin.Array<kotlin.String>): kotlin.Array<Pet> {
77+
@QueryParam(value = "tags") tags: kotlin.Array<kotlin.String>
78+
): kotlin.Array<Pet> {
7479
TODO()
7580
}
7681

@@ -79,7 +84,8 @@ class PetApiAction @Inject constructor(
7984
@ResponseContentType(MediaTypes.APPLICATION_XML, MediaTypes.APPLICATION_JSON)
8085
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 1.0)
8186
fun getPetById(
82-
@PathParam("petId") petId: kotlin.Long): Pet {
87+
@PathParam("petId") petId: kotlin.Long
88+
): Pet {
8389
TODO()
8490
}
8591

@@ -89,7 +95,8 @@ class PetApiAction @Inject constructor(
8995
@ResponseContentType(MediaTypes.APPLICATION_XML, MediaTypes.APPLICATION_JSON)
9096
@LogRequestResponse(bodySampling = 1.0, errorBodySampling = 1.0)
9197
fun updatePet(
92-
@Valid @RequestBody pet: Pet): Pet {
98+
@Valid @RequestBody pet: Pet
99+
): Pet {
93100
TODO()
94101
}
95102

@@ -100,7 +107,8 @@ class PetApiAction @Inject constructor(
100107
fun updatePetWithForm(
101108
@PathParam("petId") petId: kotlin.Long,
102109
@QueryParam(value = "name") name: kotlin.String? ,
103-
@QueryParam(value = "status") status: kotlin.String? ) {
110+
@QueryParam(value = "status") status: kotlin.String?
111+
): Response<Unit> {
104112
TODO()
105113
}
106114

@@ -112,7 +120,8 @@ class PetApiAction @Inject constructor(
112120
fun uploadFile(
113121
@PathParam("petId") petId: kotlin.Long,
114122
@QueryParam(value = "additionalMetadata") additionalMetadata: kotlin.String? ,
115-
@Valid file: HttpCall): ModelApiResponse {
123+
@Valid file: HttpCall
124+
): ModelApiResponse {
116125
TODO()
117126
}
118127
}

0 commit comments

Comments
 (0)