Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requestMapping for basepath defined in swagger '2.0' is missing in generation with io.swagger.codegen.v3 #1197

Open
Shiva2199 opened this issue Oct 12, 2023 · 2 comments

Comments

@Shiva2199
Copy link

Shiva2199 commented Oct 12, 2023

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>`
@Shiva2199
Copy link
Author

@HugoMario / @tgillain Can you please suggest ?

@tgillain
Copy link
Contributor

Hi @Shiva2199 ,

From our side we migrated our project to use openapi-generator-maven-plugin since its more frequent release policy was fitting better our needs. So unfortunately I cannot help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants