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 @@ -30,9 +30,6 @@ import org.springframework.validation.annotation.Validated
{{/useBeanValidation}}
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
{{#useRequestMappingOnController}}
import {{#apiPackage}}{{.}}.{{/apiPackage}}{{classname}}Controller.Companion.BASE_PATH
{{/useRequestMappingOnController}}

{{#useBeanValidation}}
import {{javaxPackage}}.validation.Valid
Expand Down Expand Up @@ -60,9 +57,7 @@ import kotlin.collections.Map
@Api(value = "{{{baseName}}}", description = "The {{{baseName}}} API")
{{/swagger1AnnotationLibrary}}
{{#useRequestMappingOnController}}
{{=<% %>=}}
@RequestMapping("\${openapi.<%title%>.base-path:\${api.base-path:$BASE_PATH}}")
<%={{ }}=%>
@RequestMapping("\${api.base-path:{{contextPath}}}")
{{/useRequestMappingOnController}}
{{#operations}}
class {{classname}}Controller({{#serviceInterface}}@Autowired(required = true) val service: {{classname}}Service{{/serviceInterface}}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,12 @@ package {{package}}
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import java.util.Optional
{{#useRequestMappingOnController}}
import {{#apiPackage}}{{.}}.{{/apiPackage}}{{classname}}Controller.Companion.BASE_PATH
{{/useRequestMappingOnController}}

{{>generatedAnnotation}}

@Controller{{#beanQualifiers}}("{{package}}.{{classname}}Controller"){{/beanQualifiers}}
{{#useRequestMappingOnController}}
{{=<% %>=}}
@RequestMapping("\${openapi.<%title%>.base-path:\${api.base-path:$BASE_PATH}}")
<%={{ }}=%>
@RequestMapping("\${api.base-path:{{contextPath}}}")
{{/useRequestMappingOnController}}
{{#operations}}
class {{classname}}Controller(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ import org.springframework.validation.annotation.Validated
{{/useBeanValidation}}
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
{{#useRequestMappingOnInterface}}
import {{#apiPackage}}{{.}}.{{/apiPackage}}{{classname}}.Companion.BASE_PATH
{{/useRequestMappingOnInterface}}

{{#useBeanValidation}}
import {{javaxPackage}}.validation.constraints.DecimalMax
Expand Down Expand Up @@ -67,9 +64,7 @@ import kotlin.collections.Map
@Api(value = "{{{baseName}}}", description = "The {{{baseName}}} API")
{{/swagger1AnnotationLibrary}}
{{#useRequestMappingOnInterface}}
{{=<% %>=}}
@RequestMapping("\${openapi.<%title%>.base-path:\${api.base-path:$BASE_PATH}}")
<%={{ }}=%>
@RequestMapping("\${api.base-path:{{contextPath}}}")
{{/useRequestMappingOnInterface}}
{{#operations}}
interface {{classname}} {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ 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 @@ -51,9 +48,7 @@ import kotlin.collections.List
import kotlin.collections.Map

{{#useRequestMappingOnInterface}}
{{=<% %>=}}
@HttpExchange("\${openapi.<%title%>.base-path:\${api.base-path:$BASE_PATH}}")
<%={{ }}=%>
@HttpExchange("\${api.base-path:{{contextPath}}}")
{{/useRequestMappingOnInterface}}
{{#useBeanValidation}}
@Validated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,11 @@ public void testNoRequestMappingAnnotationController() throws IOException {
"@RequestMapping(\"\\${"
);
// Check that the @RequestMapping annotation is generated in the ApiController file
// Note: We use simple ${api.base-path:<default>} syntax because Spring's @RequestMapping
// doesn't properly resolve nested ${outer:${inner:default}} property placeholder syntax
assertFileContains(
Paths.get(output + "/src/main/kotlin/org/openapitools/api/PetApiController.kt"),
"@RequestMapping(\"\\${openapi.openAPIPetstore.base-path:\\${api.base-path:$BASE_PATH}}\")",
"@RequestMapping(\"\\${api.base-path:/v2}\")",
" companion object {\n"
+ " //for your own safety never directly reuse these path definitions in tests\n"
+ " const val BASE_PATH: String = \"/v2\"\n"
Expand All @@ -156,9 +158,11 @@ public void testNoRequestMappingAnnotationApiInterface() throws IOException {
File output = generatePetstoreWithRequestMappingMode(KotlinSpringServerCodegen.RequestMappingMode.api_interface);

// Check that the @RequestMapping annotation is generated in the Api file
// Note: We use simple ${api.base-path:<default>} syntax because Spring's @RequestMapping
// doesn't properly resolve nested ${outer:${inner:default}} property placeholder syntax
assertFileContains(
Paths.get(output + "/src/main/kotlin/org/openapitools/api/PetApi.kt"),
"@RequestMapping(\"\\${openapi.openAPIPetstore.base-path:\\${api.base-path:$BASE_PATH}}\")",
"@RequestMapping(\"\\${api.base-path:/v2}\")",
" companion object {\n"
+ " //for your own safety never directly reuse these path definitions in tests\n"
+ " const val BASE_PATH: String = \"/v2\""
Expand Down Expand Up @@ -1310,11 +1314,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
assertFileContains(
path,
"@HttpExchange(\n"
+ "\"\\${openapi.openAPIPetstore.base-path:\\${api.base-path:$BASE_PATH}}\"\n"
+ ")",
"@HttpExchange(\"\\${api.base-path:/v2}\")",
" fun getInventory(\n"
+ " ): Map<String, kotlin.Int>",
" fun deleteOrder(\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.FakeApiController.Companion.BASE_PATH

import javax.validation.Valid
import javax.validation.constraints.DecimalMax
Expand All @@ -31,7 +30,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class FakeApiController() {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.PetApiController.Companion.BASE_PATH

import javax.validation.Valid
import javax.validation.constraints.DecimalMax
Expand All @@ -32,7 +31,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class PetApiController() {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.StoreApiController.Companion.BASE_PATH

import javax.validation.Valid
import javax.validation.constraints.DecimalMax
Expand All @@ -31,7 +30,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class StoreApiController() {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.UserApiController.Companion.BASE_PATH

import javax.validation.Valid
import javax.validation.constraints.DecimalMax
Expand All @@ -31,7 +30,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class UserApiController() {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.TestApiController.Companion.BASE_PATH

import javax.validation.Valid
import javax.validation.constraints.DecimalMax
Expand All @@ -31,7 +30,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.demo.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:}")
class TestApiController() {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.PetApi.Companion.BASE_PATH

import jakarta.validation.constraints.DecimalMax
import jakarta.validation.constraints.DecimalMin
Expand All @@ -37,7 +36,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
interface PetApi {

fun getDelegate(): PetApiDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.StoreApi.Companion.BASE_PATH

import jakarta.validation.constraints.DecimalMax
import jakarta.validation.constraints.DecimalMin
Expand All @@ -36,7 +35,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
interface StoreApi {

fun getDelegate(): StoreApiDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.UserApi.Companion.BASE_PATH

import jakarta.validation.constraints.DecimalMax
import jakarta.validation.constraints.DecimalMin
Expand All @@ -36,7 +35,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
interface UserApi {

fun getDelegate(): UserApiDelegate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package org.openapitools.api
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import java.util.Optional
import org.openapitools.api.PetApiController.Companion.BASE_PATH

@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.19.0-SNAPSHOT")
@Controller
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class PetApiController(
private val delegate: PetApiDelegate
) : PetApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package org.openapitools.api
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import java.util.Optional
import org.openapitools.api.StoreApiController.Companion.BASE_PATH

@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.19.0-SNAPSHOT")
@Controller
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class StoreApiController(
private val delegate: StoreApiDelegate
) : StoreApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package org.openapitools.api
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import java.util.Optional
import org.openapitools.api.UserApiController.Companion.BASE_PATH

@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.19.0-SNAPSHOT")
@Controller
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class UserApiController(
private val delegate: UserApiDelegate
) : UserApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.PetApiController.Companion.BASE_PATH

import javax.validation.Valid
import javax.validation.constraints.DecimalMax
Expand All @@ -32,7 +31,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class PetApiController(@Autowired(required = true) val service: PetApiService) {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.StoreApiController.Companion.BASE_PATH

import javax.validation.Valid
import javax.validation.constraints.DecimalMax
Expand All @@ -31,7 +30,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class StoreApiController(@Autowired(required = true) val service: StoreApiService) {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.UserApiController.Companion.BASE_PATH

import javax.validation.Valid
import javax.validation.constraints.DecimalMax
Expand All @@ -31,7 +30,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class UserApiController(@Autowired(required = true) val service: UserApiService) {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*
import org.springframework.validation.annotation.Validated
import org.springframework.web.context.request.NativeWebRequest
import org.springframework.beans.factory.annotation.Autowired
import org.openapitools.api.MultipartMixedApiController.Companion.BASE_PATH

import javax.validation.Valid
import javax.validation.constraints.DecimalMax
Expand All @@ -32,7 +31,7 @@ import kotlin.collections.Map

@RestController
@Validated
@RequestMapping("\${openapi.multipartFileTest.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:}")
class MultipartMixedApiController() {

@Operation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package org.openapitools.api
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import java.util.Optional
import org.openapitools.api.PetApiController.Companion.BASE_PATH

@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.19.0-SNAPSHOT")
@Controller
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class PetApiController(
delegate: PetApiDelegate?
) : PetApi {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package org.openapitools.api
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import java.util.Optional
import org.openapitools.api.StoreApiController.Companion.BASE_PATH

@javax.annotation.Generated(value = ["org.openapitools.codegen.languages.KotlinSpringServerCodegen"], comments = "Generator version: 7.19.0-SNAPSHOT")
@Controller
@RequestMapping("\${openapi.openAPIPetstore.base-path:\${api.base-path:$BASE_PATH}}")
@RequestMapping("\${api.base-path:/v2}")
class StoreApiController(
delegate: StoreApiDelegate?
) : StoreApi {
Expand Down
Loading
Loading