Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -13,3 +13,4 @@ additionalProperties:
reactive: false
useResponseEntity: true
useFlowForArrayReturnType: false
requestMappingMode: "api_interface"
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ package {{package}}

{{#imports}}import {{import}}
{{/imports}}
{{#useRequestMappingOnInterface}}
import {{#apiPackage}}{{.}}.{{/apiPackage}}{{classname}}.Companion.BASE_PATH
{{/useRequestMappingOnInterface}}

{{#swagger2AnnotationLibrary}}
import io.swagger.v3.oas.annotations.*
Expand Down Expand Up @@ -48,7 +51,7 @@ import kotlin.collections.List
import kotlin.collections.Map

{{#useRequestMappingOnInterface}}
@HttpExchange("\${api.base-path:{{contextPath}}}")
@HttpExchange(BASE_PATH) // Generate with 'requestMappingMode' set to 'none' to skip the base path on the interface
{{/useRequestMappingOnInterface}}
{{#useBeanValidation}}
@Validated
Expand All @@ -74,9 +77,7 @@ interface {{classname}} {
{{/operation}}
companion object {
//for your own safety never directly reuse these path definitions in tests
{{#useRequestMappingOnInterface}}
const val BASE_PATH: String = "{{=<% %>=}}<%contextPath%><%={{ }}=%>"
{{/useRequestMappingOnInterface}}
{{#operation}}
const val PATH_{{#lambda.uppercase}}{{#lambda.snakecase}}{{{operationId}}}{{/lambda.snakecase}}{{/lambda.uppercase}}: String = "{{{path}}}"
{{/operation}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ public void generateHttpInterfaceReactiveWithReactorResponseEntity() throws Exce
+ " ): Mono<ResponseEntity<Order>>",
" companion object {\n"
+ " //for your own safety never directly reuse these path definitions in tests\n"
+ " const val BASE_PATH: String = \"/v2\"\n"
+ " const val PATH_DELETE_ORDER: String = \"/store/order/{orderId}\"\n"
+ " const val PATH_GET_INVENTORY: String = \"/store/inventory\"\n"
+ " const val PATH_GET_ORDER_BY_ID: String = \"/store/order/{orderId}\"\n"
Expand All @@ -1105,7 +1106,8 @@ public void generateHttpInterfaceReactiveWithReactorResponseEntity() throws Exce
);
assertFileNotContains(
path,
"suspend"
"suspend",
"@HttpExchange(BASE_PATH)" // this should not be present since "requestMappingMode" is set to "none"
);
}

Expand Down Expand Up @@ -1314,11 +1316,11 @@ public void generateHttpInterface() throws Exception {
generator.opts(input).generate();

Path path = Paths.get(outputPath + "/src/main/kotlin/org/openapitools/api/StoreApiClient.kt");
// Note: We use simple ${api.base-path:<default>} syntax because Spring's @HttpExchange
// doesn't properly resolve nested ${outer:${inner:default}} property placeholder syntax
// Note: We cannot use property placeholders as HttpServiceProxyFactory does not resolve them by default.
assertFileContains(
path,
"@HttpExchange(\"\\${api.base-path:/v2}\")",
"import org.openapitools.api.StoreApi.Companion.BASE_PATH",
"@HttpExchange(BASE_PATH) // Generate with 'requestMappingMode' set to 'none' to skip the base path on the interface", // this should be present since "requestMappingMode" is set to "api_interface"
" fun getInventory(\n"
+ " ): Map<String, kotlin.Int>",
" fun deleteOrder(\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ interface PetApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_ADD_PET: String = "/pet"
const val PATH_DELETE_PET: String = "/pet/{petId}"
const val PATH_FIND_PETS_BY_STATUS: String = "/pet/findByStatus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ interface StoreApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_DELETE_ORDER: String = "/store/order/{orderId}"
const val PATH_GET_INVENTORY: String = "/store/inventory"
const val PATH_GET_ORDER_BY_ID: String = "/store/order/{orderId}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ interface UserApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_CREATE_USER: String = "/user"
const val PATH_CREATE_USERS_WITH_ARRAY_INPUT: String = "/user/createWithArray"
const val PATH_CREATE_USERS_WITH_LIST_INPUT: String = "/user/createWithList"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ interface PetApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_ADD_PET: String = "/pet"
const val PATH_DELETE_PET: String = "/pet/{petId}"
const val PATH_FIND_PETS_BY_STATUS: String = "/pet/findByStatus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ interface StoreApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_DELETE_ORDER: String = "/store/order/{orderId}"
const val PATH_GET_INVENTORY: String = "/store/inventory"
const val PATH_GET_ORDER_BY_ID: String = "/store/order/{orderId}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ interface UserApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_CREATE_USER: String = "/user"
const val PATH_CREATE_USERS_WITH_ARRAY_INPUT: String = "/user/createWithArray"
const val PATH_CREATE_USERS_WITH_LIST_INPUT: String = "/user/createWithList"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package org.openapitools.api

import org.openapitools.model.ModelApiResponse
import org.openapitools.model.Pet
import org.openapitools.api.PetApi.Companion.BASE_PATH

import io.swagger.v3.oas.annotations.*
import io.swagger.v3.oas.annotations.enums.*
Expand All @@ -25,6 +26,7 @@ import jakarta.validation.constraints.*
import kotlin.collections.List
import kotlin.collections.Map

@HttpExchange(BASE_PATH) // Generate with 'requestMappingMode' set to 'none' to skip the base path on the interface
@Validated
interface PetApi {

Expand Down Expand Up @@ -107,6 +109,7 @@ interface PetApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_ADD_PET: String = "/pet"
const val PATH_DELETE_PET: String = "/pet/{petId}"
const val PATH_FIND_PETS_BY_STATUS: String = "/pet/findByStatus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.openapitools.api

import org.openapitools.model.Order
import org.openapitools.api.StoreApi.Companion.BASE_PATH

import io.swagger.v3.oas.annotations.*
import io.swagger.v3.oas.annotations.enums.*
Expand All @@ -24,6 +25,7 @@ import jakarta.validation.constraints.*
import kotlin.collections.List
import kotlin.collections.Map

@HttpExchange(BASE_PATH) // Generate with 'requestMappingMode' set to 'none' to skip the base path on the interface
@Validated
interface StoreApi {

Expand Down Expand Up @@ -64,6 +66,7 @@ interface StoreApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_DELETE_ORDER: String = "/store/order/{orderId}"
const val PATH_GET_INVENTORY: String = "/store/inventory"
const val PATH_GET_ORDER_BY_ID: String = "/store/order/{orderId}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.openapitools.api

import org.openapitools.model.User
import org.openapitools.api.UserApi.Companion.BASE_PATH

import io.swagger.v3.oas.annotations.*
import io.swagger.v3.oas.annotations.enums.*
Expand All @@ -24,6 +25,7 @@ import jakarta.validation.constraints.*
import kotlin.collections.List
import kotlin.collections.Map

@HttpExchange(BASE_PATH) // Generate with 'requestMappingMode' set to 'none' to skip the base path on the interface
@Validated
interface UserApi {

Expand Down Expand Up @@ -102,6 +104,7 @@ interface UserApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_CREATE_USER: String = "/user"
const val PATH_CREATE_USERS_WITH_ARRAY_INPUT: String = "/user/createWithArray"
const val PATH_CREATE_USERS_WITH_LIST_INPUT: String = "/user/createWithList"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ interface PetApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_ADD_PET: String = "/pet"
const val PATH_DELETE_PET: String = "/pet/{petId}"
const val PATH_FIND_PETS_BY_STATUS: String = "/pet/findByStatus"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ interface StoreApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_DELETE_ORDER: String = "/store/order/{orderId}"
const val PATH_GET_INVENTORY: String = "/store/inventory"
const val PATH_GET_ORDER_BY_ID: String = "/store/order/{orderId}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ interface UserApi {

companion object {
//for your own safety never directly reuse these path definitions in tests
const val BASE_PATH: String = "/v2"
const val PATH_CREATE_USER: String = "/user"
const val PATH_CREATE_USERS_WITH_ARRAY_INPUT: String = "/user/createWithArray"
const val PATH_CREATE_USERS_WITH_LIST_INPUT: String = "/user/createWithList"
Expand Down
Loading