diff --git a/bin/configs/kotlin-server-jaxrs-spec-array-response.yaml b/bin/configs/kotlin-server-jaxrs-spec-array-response.yaml index ce6fe3f06c8a..de81f9dceb66 100644 --- a/bin/configs/kotlin-server-jaxrs-spec-array-response.yaml +++ b/bin/configs/kotlin-server-jaxrs-spec-array-response.yaml @@ -6,3 +6,4 @@ templateDir: modules/openapi-generator/src/main/resources/kotlin-server additionalProperties: interfaceOnly: "true" useJakartaEe: true + useTags: "true" diff --git a/bin/configs/kotlin-server-jaxrs-spec-parameter-tests.yaml b/bin/configs/kotlin-server-jaxrs-spec-parameter-tests.yaml index 948d739d995d..a18a371f62e6 100644 --- a/bin/configs/kotlin-server-jaxrs-spec-parameter-tests.yaml +++ b/bin/configs/kotlin-server-jaxrs-spec-parameter-tests.yaml @@ -5,3 +5,4 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/parameter-test-spec. templateDir: modules/openapi-generator/src/main/resources/kotlin-server additionalProperties: useCoroutines: "true" + useTags: "true" diff --git a/bin/configs/kotlin-server-jaxrs-spec.yaml b/bin/configs/kotlin-server-jaxrs-spec.yaml index 3ffc6a51f1d5..c80e330cd785 100644 --- a/bin/configs/kotlin-server-jaxrs-spec.yaml +++ b/bin/configs/kotlin-server-jaxrs-spec.yaml @@ -5,5 +5,4 @@ inputSpec: modules/openapi-generator/src/test/resources/2_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/kotlin-server additionalProperties: useCoroutines: "true" - useTags: "true" implicitHeaders: "true" diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java index f8b0cb2c224b..0e540f263b6f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinServerCodegen.java @@ -18,12 +18,36 @@ package org.openapitools.codegen.languages; import com.google.common.collect.ImmutableMap; +import io.swagger.v3.oas.models.Operation; +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.StringUtils; -import org.openapitools.codegen.*; +import org.openapitools.codegen.CodegenConstants; +import org.openapitools.codegen.CodegenDiscriminator; +import org.openapitools.codegen.CodegenModel; +import org.openapitools.codegen.CodegenOperation; +import org.openapitools.codegen.CodegenParameter; +import org.openapitools.codegen.CodegenProperty; +import org.openapitools.codegen.CodegenResponse; +import org.openapitools.codegen.CodegenType; +import org.openapitools.codegen.SupportingFile; import org.openapitools.codegen.languages.features.BeanValidationFeatures; -import org.openapitools.codegen.meta.features.*; +import org.openapitools.codegen.meta.features.DocumentationFeature; +import org.openapitools.codegen.meta.features.GlobalFeature; +import org.openapitools.codegen.meta.features.ParameterFeature; +import org.openapitools.codegen.meta.features.SchemaSupportFeature; +import org.openapitools.codegen.meta.features.SecurityFeature; +import org.openapitools.codegen.meta.features.WireFormatFeature; import org.openapitools.codegen.model.ModelMap; import org.openapitools.codegen.model.ModelsMap; import org.openapitools.codegen.model.OperationMap; @@ -33,9 +57,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.util.*; - public class KotlinServerCodegen extends AbstractKotlinCodegen implements BeanValidationFeatures { public static final String DEFAULT_LIBRARY = Constants.KTOR; @@ -702,32 +723,45 @@ public void postProcess() { System.out.println("################################################################################"); } + @Override + public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map> operations) { + if (!Objects.equals(library, Constants.JAXRS_SPEC) || useTags) { + super.addOperationToGroup(tag, resourcePath, operation, co, operations); + return; + } + + final String basePath = StringUtils.substringBefore(resourcePath.startsWith("/") ? resourcePath.substring(1) : resourcePath, "/"); + if (!StringUtils.isEmpty(basePath)) { + co.subresourceOperation = !co.path.isEmpty(); + } + co.baseName = basePath; + if (StringUtils.isEmpty(co.baseName) || co.baseName.chars().anyMatch(ch -> ch == '{' || ch == '}')) { + co.baseName = "default"; + } + final List opList = operations.computeIfAbsent(co.baseName, k -> new ArrayList<>()); + opList.add(co); + } + @Override public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List allModels) { OperationMap operations = objs.getOperations(); - // For JAXRS_SPEC library, compute commonPath when useTags=true, otherwise default to "/" + // For JAXRS_SPEC library, compute commonPath for all library modes if (operations != null && Objects.equals(library, Constants.JAXRS_SPEC)) { - if (useTags) { - String commonPath = null; - List ops = operations.getOperation(); - for (CodegenOperation operation : ops) { - if (commonPath == null) { - commonPath = operation.path; - } else { - commonPath = getCommonPath(commonPath, operation.path); - } - } - for (CodegenOperation co : ops) { - co.path = StringUtils.removeStart(co.path, commonPath); - co.subresourceOperation = co.path.length() > 1; - } - objs.put("commonPath", "/".equals(commonPath) ? StringUtils.EMPTY : commonPath); - } else { - for (CodegenOperation co : operations.getOperation()) { - co.subresourceOperation = !co.path.isEmpty(); + List ops = operations.getOperation(); + // Compute commonPath from operations in this group (called once per API class) + String commonPath = null; + for (CodegenOperation operation : ops) { + if (commonPath == null) { + commonPath = operation.path; + } else { + commonPath = getCommonPath(commonPath, operation.path); } - objs.put("commonPath", "/"); } + for (CodegenOperation co : ops) { + co.path = StringUtils.removeStart(co.path, commonPath); + co.subresourceOperation = co.path.length() > 1; + } + objs.put("commonPath", "/".equals(commonPath) ? StringUtils.EMPTY : commonPath); } // The following processing breaks the JAX-RS spec, so we only do this for the other libs. if (operations != null && !Objects.equals(library, Constants.JAXRS_SPEC)) { @@ -801,8 +835,8 @@ private boolean isJavalin() { */ private boolean usesJacksonSerialization() { return Constants.JAVALIN5.equals(library) || - Constants.JAVALIN6.equals(library) || - Constants.JAXRS_SPEC.equals(library); + Constants.JAVALIN6.equals(library) || + Constants.JAXRS_SPEC.equals(library); } private boolean isKtor2Or3() { diff --git a/modules/openapi-generator/src/main/resources/kotlin-server/README.mustache b/modules/openapi-generator/src/main/resources/kotlin-server/README.mustache index df987591f1bd..c20d79a43dca 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-server/README.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-server/README.mustache @@ -35,7 +35,7 @@ All URIs are relative to *{{{basePath}}}* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{#useTags}}{{commonPath}}{{/useTags}}{{path}} | {{{summary}}} +{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{commonPath}}{{path}} | {{{summary}}} {{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} {{/generateApiDocs}} diff --git a/modules/openapi-generator/src/main/resources/kotlin-server/libraries/jaxrs-spec/apiInterface.mustache b/modules/openapi-generator/src/main/resources/kotlin-server/libraries/jaxrs-spec/apiInterface.mustache index e5f33141a3ba..c1eccb534dba 100644 --- a/modules/openapi-generator/src/main/resources/kotlin-server/libraries/jaxrs-spec/apiInterface.mustache +++ b/modules/openapi-generator/src/main/resources/kotlin-server/libraries/jaxrs-spec/apiInterface.mustache @@ -1,5 +1,5 @@ - @{{httpMethod}} - @Path("{{{path}}}"){{#hasConsumes}} + @{{httpMethod}}{{#subresourceOperation}} + @Path("{{{path}}}"){{/subresourceOperation}}{{#hasConsumes}} @Consumes({{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}){{/hasConsumes}}{{#hasProduces}} @Produces({{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}){{/hasProduces}} {{#useCoroutines}}suspend {{/useCoroutines}}fun {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}){{#returnResponse}}: {{#useMutiny}}io.smallrye.mutiny.Uni<{{/useMutiny}}Response{{#useMutiny}}>{{/useMutiny}}{{/returnResponse}}{{^returnResponse}}{{#returnType}}: {{#useMutiny}}io.smallrye.mutiny.Uni<{{/useMutiny}}{{{returnType}}}{{#useMutiny}}>{{/useMutiny}}{{/returnType}}{{/returnResponse}}{{^returnResponse}}{{^returnType}}{{#useMutiny}}: io.smallrye.mutiny.Uni{{/useMutiny}}{{/returnType}}{{/returnResponse}} \ No newline at end of file diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinServerCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinServerCodegenTest.java index 508b84d03ab3..cefe70432c3c 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinServerCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/KotlinServerCodegenTest.java @@ -1,37 +1,41 @@ package org.openapitools.codegen.kotlin; -import lombok.Getter; -import org.antlr.v4.runtime.*; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import org.antlr.v4.runtime.CharStreams; +import org.antlr.v4.runtime.CommonTokenStream; import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.ParseTreeWalker; -import org.checkerframework.checker.units.qual.C; import org.openapitools.codegen.ClientOptInput; import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.DefaultGenerator; import org.openapitools.codegen.TestUtils; import org.openapitools.codegen.antlr4.KotlinLexer; import org.openapitools.codegen.antlr4.KotlinParser; -import org.openapitools.codegen.antlr4.KotlinParserBaseListener; import org.openapitools.codegen.languages.KotlinServerCodegen; import org.openapitools.codegen.languages.KotlinSpringServerCodegen; import org.testng.Assert; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import java.io.File; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.HashMap; -import java.util.Map; - -import static org.openapitools.codegen.CodegenConstants.*; +import static org.openapitools.codegen.CodegenConstants.API_PACKAGE; +import static org.openapitools.codegen.CodegenConstants.LIBRARY; +import static org.openapitools.codegen.CodegenConstants.MODEL_PACKAGE; +import static org.openapitools.codegen.CodegenConstants.PACKAGE_NAME; import static org.openapitools.codegen.TestUtils.assertFileContains; import static org.openapitools.codegen.TestUtils.assertFileNotContains; import static org.openapitools.codegen.languages.AbstractKotlinCodegen.USE_JAKARTA_EE; import static org.openapitools.codegen.languages.AbstractKotlinCodegen.USE_TAGS; -import static org.openapitools.codegen.languages.KotlinServerCodegen.Constants.*; +import static org.openapitools.codegen.languages.KotlinServerCodegen.Constants.INTERFACE_ONLY; +import static org.openapitools.codegen.languages.KotlinServerCodegen.Constants.JAVALIN5; +import static org.openapitools.codegen.languages.KotlinServerCodegen.Constants.JAVALIN6; +import static org.openapitools.codegen.languages.KotlinServerCodegen.Constants.JAXRS_SPEC; +import static org.openapitools.codegen.languages.KotlinServerCodegen.Constants.RETURN_RESPONSE; import static org.openapitools.codegen.languages.features.BeanValidationFeatures.USE_BEANVALIDATION; public class KotlinServerCodegenTest { @@ -222,6 +226,7 @@ public void issue18177Arrays() throws IOException { codegen.additionalProperties().put(INTERFACE_ONLY, true); codegen.additionalProperties().put(USE_JAKARTA_EE, true); codegen.additionalProperties().put(LIBRARY, JAXRS_SPEC); + codegen.additionalProperties().put(USE_TAGS, true); new DefaultGenerator().opts(new ClientOptInput() .openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/issue18177-array.yaml")) .config(codegen)) @@ -559,9 +564,9 @@ public void useTags_false_classNameFromTagsAndRootPathForJaxrsSpecLibrary() thro assertFileContains(petApi, "class PetApi", - "@Path(\"/\")", "@Path(\"/pet\")", - "@Path(\"/pet/{petId}\")" + "@Path(\"/findByStatus\")", + "@Path(\"/{petId}\")" ); assertFileNotContains(petApi, "@Path(\"/pet\")".replace("/pet", "/store")); } @@ -586,9 +591,9 @@ public void useTags_notSpecified_behavesLikeUseTagsFalseForJaxrsSpecLibrary() th assertFileContains(petApi, "class PetApi", - "@Path(\"/\")", "@Path(\"/pet\")", - "@Path(\"/pet/{petId}\")" + "@Path(\"/findByStatus\")", + "@Path(\"/{petId}\")" ); assertFileNotContains(petApi, "@Path(\"/store\")"); } diff --git a/samples/server/others/kotlin-server/jaxrs-spec-array-response/src/main/kotlin/org/openapitools/server/apis/StuffApi.kt b/samples/server/others/kotlin-server/jaxrs-spec-array-response/src/main/kotlin/org/openapitools/server/apis/StuffApi.kt index 3f5bce2366e4..d0c12b7a4ddc 100644 --- a/samples/server/others/kotlin-server/jaxrs-spec-array-response/src/main/kotlin/org/openapitools/server/apis/StuffApi.kt +++ b/samples/server/others/kotlin-server/jaxrs-spec-array-response/src/main/kotlin/org/openapitools/server/apis/StuffApi.kt @@ -10,7 +10,7 @@ import java.io.InputStream -@Path("/") +@Path("") @jakarta.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"), comments = "Generator version: 7.22.0-SNAPSHOT") interface StuffApi { diff --git a/samples/server/others/kotlin-server/jaxrs-spec/src/main/kotlin/org/openapitools/server/apis/DefaultApi.kt b/samples/server/others/kotlin-server/jaxrs-spec/src/main/kotlin/org/openapitools/server/apis/DefaultApi.kt index 516e7ef25dfb..73997d550dd9 100644 --- a/samples/server/others/kotlin-server/jaxrs-spec/src/main/kotlin/org/openapitools/server/apis/DefaultApi.kt +++ b/samples/server/others/kotlin-server/jaxrs-spec/src/main/kotlin/org/openapitools/server/apis/DefaultApi.kt @@ -9,12 +9,11 @@ import java.io.InputStream -@Path("/") +@Path("/test/parameters/{path_default}/{path_nullable}") @javax.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"), comments = "Generator version: 7.22.0-SNAPSHOT") class DefaultApi { @GET - @Path("/test/parameters/{path_default}/{path_nullable}") suspend fun findPetsByStatus(@PathParam("path_default") pathDefault: kotlin.String,@PathParam("path_nullable") pathNullable: kotlin.String,@QueryParam("query_default") @DefaultValue("available") queryDefault: kotlin.String,@QueryParam("query_default_enum") @DefaultValue("B") queryDefaultEnum: kotlin.String,@QueryParam("query_default_int") @DefaultValue("3") queryDefaultInt: java.math.BigDecimal,@HeaderParam("header_default") @DefaultValue("available") headerDefault: kotlin.String,@HeaderParam("header_default_enum") @DefaultValue("B") headerDefaultEnum: kotlin.String,@HeaderParam("header_default_int") @DefaultValue("3") headerDefaultInt: java.math.BigDecimal,@CookieParam("cookie_default") @DefaultValue("available") cookieDefault: kotlin.String,@CookieParam("cookie_default_enum") @DefaultValue("B") cookieDefaultEnum: kotlin.String,@CookieParam("cookie_default_int") @DefaultValue("3") cookieDefaultInt: java.math.BigDecimal,@QueryParam("query_nullable") queryNullable: kotlin.String?,@HeaderParam("header_nullable") headerNullable: kotlin.String?,@CookieParam("cookie_nullable") cookieNullable: kotlin.String?,@QueryParam("\$query-\$dollar-sign") dollarQueryDollarDollarSign: kotlin.String?): Response { return Response.ok().entity("magic!").build(); } diff --git a/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/README.md b/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/README.md index 231a738d36cc..c332fd4d8d2b 100644 --- a/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/README.md +++ b/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/README.md @@ -34,26 +34,26 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store -*PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet -*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status -*PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags -*PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID -*PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet -*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data -*PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image -*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status -*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID -*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet -*UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** /user | Create user -*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array -*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array -*UserApi* | [**deleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user -*UserApi* | [**getUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name -*UserApi* | [**loginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system -*UserApi* | [**logoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session -*UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user +*PetApi* | [**addPet**](docs/PetApi.md#) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs/PetApi.md#) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs/PetApi.md#) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs/PetApi.md#) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs/PetApi.md#) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs/StoreApi.md#) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs/StoreApi.md#) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#) | **PUT** /user/{username} | Updated user diff --git a/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/PetApi.kt b/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/PetApi.kt index c5991e639955..45fc8405122d 100644 --- a/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/PetApi.kt +++ b/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/PetApi.kt @@ -11,46 +11,44 @@ import java.io.InputStream -@Path("/") +@Path("/pet") @javax.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"), comments = "Generator version: 7.22.0-SNAPSHOT") interface PetApi { @POST - @Path("/pet") @Consumes("application/json", "application/xml") fun addPet( body: Pet): io.smallrye.mutiny.Uni @DELETE - @Path("/pet/{petId}") + @Path("/{petId}") fun deletePet(@PathParam("petId") petId: kotlin.Long,@HeaderParam("api_key") apiKey: kotlin.String?): io.smallrye.mutiny.Uni @GET - @Path("/pet/findByStatus") + @Path("/findByStatus") @Produces("application/xml", "application/json") fun findPetsByStatus(@QueryParam("status") status: kotlin.collections.List): io.smallrye.mutiny.Uni @GET - @Path("/pet/findByTags") + @Path("/findByTags") @Produces("application/xml", "application/json") fun findPetsByTags(@QueryParam("tags") tags: kotlin.collections.List): io.smallrye.mutiny.Uni @GET - @Path("/pet/{petId}") + @Path("/{petId}") @Produces("application/xml", "application/json") fun getPetById(@PathParam("petId") petId: kotlin.Long): io.smallrye.mutiny.Uni @PUT - @Path("/pet") @Consumes("application/json", "application/xml") fun updatePet( body: Pet): io.smallrye.mutiny.Uni @POST - @Path("/pet/{petId}") + @Path("/{petId}") @Consumes("application/x-www-form-urlencoded") fun updatePetWithForm(@PathParam("petId") petId: kotlin.Long,@FormParam(value = "name") name: kotlin.String?,@FormParam(value = "status") status: kotlin.String?): io.smallrye.mutiny.Uni @POST - @Path("/pet/{petId}/uploadImage") + @Path("/{petId}/uploadImage") @Consumes("multipart/form-data") @Produces("application/json") fun uploadFile(@PathParam("petId") petId: kotlin.Long,@FormParam(value = "additionalMetadata") additionalMetadata: kotlin.String?, @FormParam(value = "file") fileInputStream: InputStream?): io.smallrye.mutiny.Uni diff --git a/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt b/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt index 18698be8de2a..afcdeb1c40a6 100644 --- a/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt +++ b/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/StoreApi.kt @@ -10,26 +10,26 @@ import java.io.InputStream -@Path("/") +@Path("/store") @javax.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"), comments = "Generator version: 7.22.0-SNAPSHOT") interface StoreApi { @DELETE - @Path("/store/order/{orderId}") + @Path("/order/{orderId}") fun deleteOrder(@PathParam("orderId") orderId: kotlin.String): io.smallrye.mutiny.Uni @GET - @Path("/store/inventory") + @Path("/inventory") @Produces("application/json") fun getInventory(): io.smallrye.mutiny.Uni @GET - @Path("/store/order/{orderId}") + @Path("/order/{orderId}") @Produces("application/xml", "application/json") fun getOrderById(@PathParam("orderId") orderId: kotlin.Long): io.smallrye.mutiny.Uni @POST - @Path("/store/order") + @Path("/order") @Produces("application/xml", "application/json") fun placeOrder( body: Order): io.smallrye.mutiny.Uni } diff --git a/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/UserApi.kt b/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/UserApi.kt index d8c542088541..fe783ee8dce5 100644 --- a/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/UserApi.kt +++ b/samples/server/petstore/kotlin-server/jaxrs-spec-mutiny/src/main/kotlin/org/openapitools/server/apis/UserApi.kt @@ -10,41 +10,40 @@ import java.io.InputStream -@Path("/") +@Path("/user") @javax.annotation.Generated(value = arrayOf("org.openapitools.codegen.languages.KotlinServerCodegen"), comments = "Generator version: 7.22.0-SNAPSHOT") interface UserApi { @POST - @Path("/user") fun createUser( body: User): io.smallrye.mutiny.Uni @POST - @Path("/user/createWithArray") + @Path("/createWithArray") fun createUsersWithArrayInput( body: kotlin.collections.List): io.smallrye.mutiny.Uni @POST - @Path("/user/createWithList") + @Path("/createWithList") fun createUsersWithListInput( body: kotlin.collections.List): io.smallrye.mutiny.Uni @DELETE - @Path("/user/{username}") + @Path("/{username}") fun deleteUser(@PathParam("username") username: kotlin.String): io.smallrye.mutiny.Uni @GET - @Path("/user/{username}") + @Path("/{username}") @Produces("application/xml", "application/json") fun getUserByName(@PathParam("username") username: kotlin.String): io.smallrye.mutiny.Uni @GET - @Path("/user/login") + @Path("/login") @Produces("application/xml", "application/json") fun loginUser(@QueryParam("username") username: kotlin.String,@QueryParam("password") password: kotlin.String): io.smallrye.mutiny.Uni @GET - @Path("/user/logout") + @Path("/logout") fun logoutUser(): io.smallrye.mutiny.Uni @PUT - @Path("/user/{username}") + @Path("/{username}") fun updateUser(@PathParam("username") username: kotlin.String, body: User): io.smallrye.mutiny.Uni } diff --git a/samples/server/petstore/kotlin-server/jaxrs-spec/README.md b/samples/server/petstore/kotlin-server/jaxrs-spec/README.md index 231a738d36cc..c332fd4d8d2b 100644 --- a/samples/server/petstore/kotlin-server/jaxrs-spec/README.md +++ b/samples/server/petstore/kotlin-server/jaxrs-spec/README.md @@ -34,26 +34,26 @@ All URIs are relative to *http://petstore.swagger.io/v2* Class | Method | HTTP request | Description ------------ | ------------- | ------------- | ------------- -*PetApi* | [**addPet**](docs/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store -*PetApi* | [**deletePet**](docs/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet -*PetApi* | [**findPetsByStatus**](docs/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status -*PetApi* | [**findPetsByTags**](docs/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags -*PetApi* | [**getPetById**](docs/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID -*PetApi* | [**updatePet**](docs/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet -*PetApi* | [**updatePetWithForm**](docs/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data -*PetApi* | [**uploadFile**](docs/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image -*StoreApi* | [**deleteOrder**](docs/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID -*StoreApi* | [**getInventory**](docs/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status -*StoreApi* | [**getOrderById**](docs/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID -*StoreApi* | [**placeOrder**](docs/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet -*UserApi* | [**createUser**](docs/UserApi.md#createuser) | **POST** /user | Create user -*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array -*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array -*UserApi* | [**deleteUser**](docs/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user -*UserApi* | [**getUserByName**](docs/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name -*UserApi* | [**loginUser**](docs/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system -*UserApi* | [**logoutUser**](docs/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session -*UserApi* | [**updateUser**](docs/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user +*PetApi* | [**addPet**](docs/PetApi.md#) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs/PetApi.md#) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs/PetApi.md#) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs/PetApi.md#) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs/PetApi.md#) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs/PetApi.md#) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs/PetApi.md#) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs/PetApi.md#) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs/StoreApi.md#) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs/StoreApi.md#) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs/StoreApi.md#) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs/StoreApi.md#) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs/UserApi.md#) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs/UserApi.md#) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs/UserApi.md#) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs/UserApi.md#) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs/UserApi.md#) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs/UserApi.md#) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs/UserApi.md#) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs/UserApi.md#) | **PUT** /user/{username} | Updated user