From 9195cf9e431db3747b11127b0df254bf47b71ae7 Mon Sep 17 00:00:00 2001 From: Kevin Defives Date: Fri, 27 Mar 2026 10:21:23 +0100 Subject: [PATCH 1/2] Add @SerialName annotation to parameter in Paths.kt.mustache --- .../resources/kotlin-server/libraries/ktor2/Paths.kt.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/kotlin-server/libraries/ktor2/Paths.kt.mustache b/modules/openapi-generator/src/main/resources/kotlin-server/libraries/ktor2/Paths.kt.mustache index a575ea678772..cbb74f253ae8 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-server/libraries/ktor2/Paths.kt.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-server/libraries/ktor2/Paths.kt.mustache @@ -18,7 +18,7 @@ object Paths { {{#allParams}}* @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}}*/ {{#hasParams}} - @Serializable @Resource("{{{path}}}") class {{operationId}}({{#allParams}}val {{paramName}}: {{{dataType}}}{{^required}}? = null{{/required}}{{#required}}{{#isNullable}}?{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) + @Serializable @Resource("{{{path}}}") class {{operationId}}({{#allParams}}@SerialName("{{baseName}}") val {{paramName}}: {{{dataType}}}{{^required}}? = null{{/required}}{{#required}}{{#isNullable}}?{{/isNullable}}{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) {{/hasParams}} {{^hasParams}} @Serializable @Resource("{{{path}}}") class {{operationId}} From db5c81f9b7563d487f5c2654ba604ceba2978c95 Mon Sep 17 00:00:00 2001 From: Kevin Defives Date: Mon, 30 Mar 2026 11:45:18 +0200 Subject: [PATCH 2/2] after bin execution --- .../latest/UseDateTimeOffset/api/openapi.yaml | 11 ++++++ .../UseDateTimeOffset/docs/apis/PetApi.md | 2 +- .../Api/DependencyInjectionTests.cs | 16 +++++++-- .../src/Org.OpenAPITools/Api/PetApi.cs | 12 +++++-- .../kotlin/org/openapitools/server/Paths.kt | 36 +++++++++---------- 5 files changed, 53 insertions(+), 24 deletions(-) diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/api/openapi.yaml b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/api/openapi.yaml index ca451f3fb832..19998598b25e 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/api/openapi.yaml +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/api/openapi.yaml @@ -90,6 +90,9 @@ paths: - petstore_auth: - write:pets - read:pets + - petstore_auth2: + - write:pets + - read:pets summary: Add a new pet to the store tags: - pet @@ -3136,6 +3139,14 @@ components: write:pets: modify pets in your account read:pets: read your pets type: oauth2 + petstore_auth2: + flows: + implicit: + authorizationUrl: http://petstore.swagger.io/api/oauth/dialog + scopes: + write:pets: modify pets in your account + read:pets: read your pets + type: oauth2 api_key: in: header name: api-key diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/docs/apis/PetApi.md b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/docs/apis/PetApi.md index b42ee516b313..4102dc14f06b 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/docs/apis/PetApi.md +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/docs/apis/PetApi.md @@ -34,7 +34,7 @@ void (empty response body) ### Authorization -[petstore_auth](../README.md#petstore_auth), [http_signature_test](../README.md#http_signature_test) +[petstore_auth](../README.md#petstore_auth), [petstore_auth2](../README.md#petstore_auth2), [http_signature_test](../README.md#http_signature_test) ### HTTP request headers diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs index 028d71f43359..e7ed8b2af672 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools.Test/Api/DependencyInjectionTests.cs @@ -45,6 +45,9 @@ public class DependencyInjectionTest OAuthToken oauthToken1 = new("token", timeout: TimeSpan.FromSeconds(1)); options.AddTokens(oauthToken1); + + OAuthToken oauthToken2 = new("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken2); }) .Build(); @@ -67,8 +70,11 @@ public class DependencyInjectionTest HttpSignatureToken httpSignatureToken1 = new(config1, timeout: TimeSpan.FromSeconds(1)); options.AddTokens(httpSignatureToken1); - OAuthToken oauthToken = new("token", timeout: TimeSpan.FromSeconds(1)); - options.AddTokens(oauthToken); + OAuthToken oauthToken1 = new("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken1); + + OAuthToken oauthToken2 = new("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken2); options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); }) .Build(); @@ -96,6 +102,9 @@ public class DependencyInjectionTest OAuthToken oauthToken1 = new("token", timeout: TimeSpan.FromSeconds(1)); options.AddTokens(oauthToken1); + + OAuthToken oauthToken2 = new("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken2); }); }) .Build(); @@ -123,6 +132,9 @@ public class DependencyInjectionTest OAuthToken oauthToken1 = new("token", timeout: TimeSpan.FromSeconds(1)); options.AddTokens(oauthToken1); + + OAuthToken oauthToken2 = new("token", timeout: TimeSpan.FromSeconds(1)); + options.AddTokens(oauthToken2); options.AddApiHttpClients(client => client.BaseAddress = new Uri(ClientUtils.BASE_ADDRESS)); }); }) diff --git a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs index 018360748fba..c780f8623263 100644 --- a/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp/generichost/latest/UseDateTimeOffset/src/Org.OpenAPITools/Api/PetApi.cs @@ -849,14 +849,20 @@ public async Task AddPetAsync(Pet pet, System.Threading.Canc oauthTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar, ""); - HttpSignatureToken httpSignatureTokenLocalVar2 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + OAuthToken oauthTokenLocalVar2 = (OAuthToken) await OauthTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); - tokenBaseLocalVars.Add(httpSignatureTokenLocalVar2); + tokenBaseLocalVars.Add(oauthTokenLocalVar2); + + oauthTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, ""); + + HttpSignatureToken httpSignatureTokenLocalVar3 = (HttpSignatureToken) await HttpSignatureTokenProvider.GetAsync(cancellation: cancellationToken).ConfigureAwait(false); + + tokenBaseLocalVars.Add(httpSignatureTokenLocalVar3); if (httpRequestMessageLocalVar.Content != null) { string requestBodyLocalVar = await httpRequestMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - httpSignatureTokenLocalVar2.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); + httpSignatureTokenLocalVar3.UseInHeader(httpRequestMessageLocalVar, requestBodyLocalVar, cancellationToken); } string[] contentTypes = new string[] { diff --git a/samples/server/petstore/kotlin-server/ktor2/src/main/kotlin/org/openapitools/server/Paths.kt b/samples/server/petstore/kotlin-server/ktor2/src/main/kotlin/org/openapitools/server/Paths.kt index 58a0096fe4ee..c7d46f3102c9 100644 --- a/samples/server/petstore/kotlin-server/ktor2/src/main/kotlin/org/openapitools/server/Paths.kt +++ b/samples/server/petstore/kotlin-server/ktor2/src/main/kotlin/org/openapitools/server/Paths.kt @@ -21,7 +21,7 @@ object Paths { * * @param pet Pet object that needs to be added to the store */ - @Serializable @Resource("/pet") class addPet(val pet: Pet) + @Serializable @Resource("/pet") class addPet(@SerialName("Pet") val pet: Pet) /** * Deletes a pet @@ -29,35 +29,35 @@ object Paths { * @param petId Pet id to delete * @param apiKey (optional) */ - @Serializable @Resource("/pet/{petId}") class deletePet(val petId: kotlin.Long, val apiKey: kotlin.String? = null) + @Serializable @Resource("/pet/{petId}") class deletePet(@SerialName("petId") val petId: kotlin.Long, @SerialName("api_key") val apiKey: kotlin.String? = null) /** * Finds Pets by status * Multiple status values can be provided with comma separated strings * @param status Status values that need to be considered for filter */ - @Serializable @Resource("/pet/findByStatus") class findPetsByStatus(val status: kotlin.collections.List) + @Serializable @Resource("/pet/findByStatus") class findPetsByStatus(@SerialName("status") val status: kotlin.collections.List) /** * Finds Pets by tags * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. * @param tags Tags to filter by */ - @Serializable @Resource("/pet/findByTags") class findPetsByTags(val tags: kotlin.collections.List) + @Serializable @Resource("/pet/findByTags") class findPetsByTags(@SerialName("tags") val tags: kotlin.collections.List) /** * Find pet by ID * Returns a single pet * @param petId ID of pet to return */ - @Serializable @Resource("/pet/{petId}") class getPetById(val petId: kotlin.Long) + @Serializable @Resource("/pet/{petId}") class getPetById(@SerialName("petId") val petId: kotlin.Long) /** * Update an existing pet * * @param pet Pet object that needs to be added to the store */ - @Serializable @Resource("/pet") class updatePet(val pet: Pet) + @Serializable @Resource("/pet") class updatePet(@SerialName("Pet") val pet: Pet) /** * Updates a pet in the store with form data @@ -66,7 +66,7 @@ object Paths { * @param name Updated name of the pet (optional) * @param status Updated status of the pet (optional) */ - @Serializable @Resource("/pet/{petId}") class updatePetWithForm(val petId: kotlin.Long, val name: kotlin.String? = null, val status: kotlin.String? = null) + @Serializable @Resource("/pet/{petId}") class updatePetWithForm(@SerialName("petId") val petId: kotlin.Long, @SerialName("name") val name: kotlin.String? = null, @SerialName("status") val status: kotlin.String? = null) /** * uploads an image @@ -75,14 +75,14 @@ object Paths { * @param additionalMetadata Additional data to pass to server (optional) * @param file file to upload (optional) */ - @Serializable @Resource("/pet/{petId}/uploadImage") class uploadFile(val petId: kotlin.Long, val additionalMetadata: kotlin.String? = null, val file: java.io.File? = null) + @Serializable @Resource("/pet/{petId}/uploadImage") class uploadFile(@SerialName("petId") val petId: kotlin.Long, @SerialName("additionalMetadata") val additionalMetadata: kotlin.String? = null, @SerialName("file") val file: java.io.File? = null) /** * Delete purchase order by ID * For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors * @param orderId ID of the order that needs to be deleted */ - @Serializable @Resource("/store/order/{orderId}") class deleteOrder(val orderId: kotlin.String) + @Serializable @Resource("/store/order/{orderId}") class deleteOrder(@SerialName("orderId") val orderId: kotlin.String) /** * Returns pet inventories by status @@ -95,49 +95,49 @@ object Paths { * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions * @param orderId ID of pet that needs to be fetched */ - @Serializable @Resource("/store/order/{orderId}") class getOrderById(val orderId: kotlin.Long) + @Serializable @Resource("/store/order/{orderId}") class getOrderById(@SerialName("orderId") val orderId: kotlin.Long) /** * Place an order for a pet * * @param order order placed for purchasing the pet */ - @Serializable @Resource("/store/order") class placeOrder(val order: Order) + @Serializable @Resource("/store/order") class placeOrder(@SerialName("Order") val order: Order) /** * Create user * This can only be done by the logged in user. * @param user Created user object */ - @Serializable @Resource("/user") class createUser(val user: User) + @Serializable @Resource("/user") class createUser(@SerialName("User") val user: User) /** * Creates list of users with given input array * * @param user List of user object */ - @Serializable @Resource("/user/createWithArray") class createUsersWithArrayInput(val user: kotlin.collections.List) + @Serializable @Resource("/user/createWithArray") class createUsersWithArrayInput(@SerialName("User") val user: kotlin.collections.List) /** * Creates list of users with given input array * * @param user List of user object */ - @Serializable @Resource("/user/createWithList") class createUsersWithListInput(val user: kotlin.collections.List) + @Serializable @Resource("/user/createWithList") class createUsersWithListInput(@SerialName("User") val user: kotlin.collections.List) /** * Delete user * This can only be done by the logged in user. * @param username The name that needs to be deleted */ - @Serializable @Resource("/user/{username}") class deleteUser(val username: kotlin.String) + @Serializable @Resource("/user/{username}") class deleteUser(@SerialName("username") val username: kotlin.String) /** * Get user by user name * * @param username The name that needs to be fetched. Use user1 for testing. */ - @Serializable @Resource("/user/{username}") class getUserByName(val username: kotlin.String) + @Serializable @Resource("/user/{username}") class getUserByName(@SerialName("username") val username: kotlin.String) /** * Logs user into the system @@ -145,7 +145,7 @@ object Paths { * @param username The user name for login * @param password The password for login in clear text */ - @Serializable @Resource("/user/login") class loginUser(val username: kotlin.String, val password: kotlin.String) + @Serializable @Resource("/user/login") class loginUser(@SerialName("username") val username: kotlin.String, @SerialName("password") val password: kotlin.String) /** * Logs out current logged in user session @@ -159,6 +159,6 @@ object Paths { * @param username name that need to be deleted * @param user Updated user object */ - @Serializable @Resource("/user/{username}") class updateUser(val username: kotlin.String, val user: User) + @Serializable @Resource("/user/{username}") class updateUser(@SerialName("username") val username: kotlin.String, @SerialName("User") val user: User) }