swagger-api / swagger-api/swagger-codegen-generators
requestMapping for basepath defined in swagger '2.0' is missing in generation with io.swagger.codegen.v3
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
I am using swagger-codegen-maven-plugin to generate my resttemplate classes. I am currently upgrading my Application to spring boot 3 and I see swagger-codegen-maven-plugin with groupID io.swagger and language Spring doesnt have support for Jakarta and the alternative is to move to the swagger-codegen-maven-plugin io.swagger.codegen.v3 which supports both swagger 2 and jakarta based imports.But In the process I see the basePath provided in swagger definition is being ignored.
Can this be solved by changing some config params ? is there any other way to do this?
Please find below config:
`swagger: '2.0'
info:
description: ''
version: '2.0'
title: new 10.3
host: localhost
basePath: /app/api/v1
tags:
- name: app
description: >-
API for getting information.
schemes: - https
produces: - application/json
paths:
/state:
get:
tags:
- Sate
summary: Get state
description: Return state.
operationId: getState
responses:
'200':
description: OK
schema:
$ref: '#/definitions/State'`
Plugin Config:
old plugin
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.4.12</version>
<executions>
<execution>
<id>generate-state</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<language>spring</language>
<inputSpec>${project.build.directory}/state.yaml</inputSpec>
<output>${codegen.rest.dir}</output>
<apiPackage>endpoint.rest.api.interfaces</apiPackage>
<modelPackage>endpoint.rest.api.model</modelPackage>
<addCompileSourceRoot>false</addCompileSourceRoot>
<generateApiDocumentation>false</generateApiDocumentation>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<sourceFolder>.</sourceFolder>
<delegatePattern>true</delegatePattern>
<java8>true</java8>
<jakarta>true</jakarta> <!-- has no impact -->
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
V3- Plugin
`<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.47</version>
<executions>
<execution>
<id>generate-state</id>
<goals>
<goal>generate</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<language>spring</language>
<inputSpec>${project.build.directory}/state.yaml</inputSpec>
<output>${codegen.rest.dir}</output>
<apiPackage>endpoint.rest.api.interfaces</apiPackage>
<modelPackage>endpoint.rest.api.model</modelPackage>
<addCompileSourceRoot>false</addCompileSourceRoot>
<generateApiDocumentation>false</generateApiDocumentation>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<jakarta>true</jakarta>
<sourceFolder>.</sourceFolder>
<delegatePattern>true</delegatePattern>
<java8>true</java8>
</configOptions>
</configuration>
</execution>
<execution>`
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
Reproduce generation with the supplied Swagger 2.0 definition and the io.swagger.codegen.v3 Maven plugin configuration. Inspect the generated RestTemplate classes to determine where the basePath is handled, then verify that the generated request URLs include /app/api/v1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100