swagger-api / swagger-api/swagger-codegen

swagger-codegen-maven-plugin overwrites files even when listed on .swagger-codegen-ignore

Open
#11,125 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Issue is raised with Java when using: io.swagger.codegen.v3:swagger-codegen-maven-plugin:3.0.21 when building with gradle.
The content of the .swagger-codegen-ignore is:
**/DocumentApi.java
I'm adding the swagger ignore file location in gradle generateServer task

task generateServer {
    doLast {

        def openAPI = new OpenAPIV3Parser().read(swaggerFile, null, null)
        def clientOpts = new ClientOptInput().openAPI(openAPI)
        def codegenConfig = CodegenConfigLoader.forName('spring')
        codegenConfig.setIgnoreFilePathOverride("$projectDir".toString()+"/src/main/resources/static/.swagger-codegen-ignore")
       

however, the file DocumentApi.java is regenerated and the old configuration is not preserved.

Can you please tell me how to avoid the regeneration of a specific API or how I can exclude in the configuration that an api definition to be created for a specific endpoint?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report using swagger-codegen-maven-plugin 3.0.21, the shown Gradle generateServer task, and a .swagger-codegen-ignore entry for **/DocumentApi.java. Trace how CodegenConfigLoader and setIgnoreFilePathOverride handle that file, then verify that generation preserves the existing DocumentApi.java content while other generated files still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.