swagger-api / swagger-api/swagger-codegen

swagger-codegen-maven-plugin: generateApis not always honored

Open
#8,290 4 comments 1 reaction 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

Description

I have a multi-module project that uses swagger-codegen-maven-plugin to generate Java stubs. In one of the modules (module A), we don't have generateApis set (which should mean that it is treated as true); for the other (module B), we have it set to false.

Usually, this works, but occasionally we don't get the API classes generated (just the model classes) in module A or else we do get the API classes generated in module B.

If it matters, we are using multithreaded builds.

Swagger-codegen version

2.2.3, 2.3.1.

Swagger declaration file content or url

Proprietary code, I haven't generated an isolated test case yet.

Here's a gist with the swagger configuration in the two poms:

https://gist.github.com/davidcarltonsumo/a941f184abaa017928fa3f298645cb9f

Command line used for generation
Steps to reproduce

I don't have a test case that reproduces it at all reliably.

Related issues/PRs

Issue #6260 might be relevant.

Suggest a fix/enhancement

Reading through the code, my only current hypothesis is that the use of system properties ("api" in this case) to pass configuration information might be relevant - if both modules are executing within the same JVM, then perhaps the value of the property is bleeding over from one execution to the other? I don't understand the swagger-codegen code well enough to understand why system properties are being used here instead of having CodeGenMojo pass the configuration to DefaultGenerator via some other method (e.g. a constructor argument).

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

Start by reading CodeGenMojo and DefaultGenerator, focusing on how the "api" system property carries generateApis between plugin executions. Compare this with issue #6260 and reproduce the behavior in a multithreaded multi-module Maven build. Done means module A consistently generates APIs by default while module B consistently honors generateApis=false.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.