OpenAPITools / OpenAPITools/openapi-generator
[BUG] [KOTLIN-SPRING-SERVER] Missing @RequestMapping("\${api.base-path:/api/v1}")
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I tested with the org.openapi.generator Gradle plugin version 7.6.0 and 7.14.0 - It seems that access to the newest version 7.15.0, the Docker images and the openapi-generator-cli JARs are currently restricted (can't download them, possibly a restrictive company network policy on my end).
Sorry about that, I hope this is a valid bug report nevertheless. I can also re-try later if necessary.
Expected: Generator version 7.6.0 outputs a Kotlin interface with the following annotations:
@Validated
@RequestMapping("\${api.base-path:/api/v1}")
interface TenantOrderResultApi {
Actual: Newer versions (7.7.0 onward) output these instead:
@RestController
@Validated
interface TenantOrderResultApi {
Note the missing @RequestMapping with base path.
Because of that, the endpoints are different (they are missing the /api/v1 prefix).
openapi-generator version
- 7.14.0
- Bug already appeared in 7.7.0
- Works in 7.6.0
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: Tenant Order Result API
version: 1.0.0
servers:
- url: https://example.com/api/v1
description: Production server
paths:
/tenant-order-result/{orderId}:
post:
summary: Report the result of ordering a tenant
operationId: reportTenantOrderResult
parameters:
- name: orderId
description: ID of the production order for ordering a new tenant
in: path
required: true
schema:
type: string
example: ABC0123
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/TenantOrderResultRequest'
responses:
'200':
description: The result was successfully reported and the corresponding production order was updated.
'400':
description: General client error.
'401':
description: Client is unauthorized.
'403':
description: Client is forbidden to report results.
'404':
description: No tenant order with the given ID was found.
'422':
description: The tenant order with the given ID is not in work-in-progress or stale.
'500':
description: Internal error of <the service> or communication with <another service> failed.
components:
schemas:
TenantOrderResultRequest:
description: Result of ordering a new tenant
type: object
properties:
result:
type: string
enum:
- success
- failure
message:
type: string
description: |-
Additional internal information about the success or failure.
example: Successfully processed tenant order for 'ExampleTenant'
required:
- result
- message
Generation Details
Config section in build.gradle.kts:
tasks.register<GenerateTask>("generateTenantOrderResultServer") {
configFile.set("$rootDir/openapi/generator-config-server.yaml")
inputSpec.set("$rootDir/openapi/Tenant_Order_Result_API.yaml")
outputDir.set(layout.buildDirectory.dir("generate-resources/tenantorderresultapi").get().toString())
packageName.set("com.example.tenantorderresultapi")
generateApiTests.set(false)
generateModelTests.set(false)
additionalProperties.set(
mapOf(
"basePackage" to "com.example.tenantorderresultapi"
)
)
}
generator-config-server.yaml:
generatorName: kotlin-spring
useSpringBoot3: true
interfaceOnly: true
skipDefaultInterface: true
Steps to reproduce
- Add the above section to your Gradle build script
- Save the OpenAPI spec to a file
/openapi/Tenant_Order_Result_API.yaml - Save the config to a file
/openapi/Tenant_Order_Result_API.yaml - Run
./gradlew generateTenantOrderResultServer(orgradle generateTenantOrderResultServerif you don't use the Gradle Wrapper) - Check the interface
TenantOrderResultApiin/build/generate-resources/tenantorderresultapi/...
Related issues/PRs
Suggest a fix
Re-add the generation of @RequestMapping("\${api.base-path:/api/v1}") or other code that sets the base path.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Gradle generation task, generator-config-server.yaml, and the supplied OpenAPI declaration, then inspect the generated TenantOrderResultApi interface. Reproduce the output with ./gradlew generateTenantOrderResultServer and compare it with the expected @RequestMapping base path; done means the generated Kotlin interface includes that annotation and preserves the /api/v1 prefix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, spring-boot
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100