OpenAPITools / OpenAPITools/openapi-generator

[BUG][Maven Plugin] openapi-generator-maven-plugin IntelliJ classpath configuration issues

Open
#9,072 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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 (example)?
  • 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'm not entirely certain this issue is for the plugin, and not the IDE. But since the only delta between the two is the plugin configuration, I assume its a plugin issue.

I'm trying to migrate a project from the Swagger Maven plugin, to this one. But when loading a project with the Maven plugin into IntelliJ, the classloader is mis-configured for the IDE. it points to a sub-folder for the source.

openapi-generator version

5.1.0

Steps to reproduce

Showing valid state:

  1. Clone project: https://github.com/adobe/aio-lib-java-cloudmanager/
  2. Create new IntelliJ workspace
  3. Import the cloned Maven project. (Reload/Trust the project so it builds)
  4. In the Maven context, select Generate Sources and Update Folders
  5. At this point, the project should successfully compile, and if you check this folder it indicates it is a source folder
    target/generated-sources/swagger/src/main/java

Show invalid state:

  1. Run a maven clean and reload the project from the file system, ensuring that the target folder is removed.
  2. You may need to edit the source folder configuration to remove the previously configured generated source path (Optional Step)
  3. Replace the pom with the contents of this gist
  4. In the Maven context, select Generate Sources and Update Folders
  5. The IDE will show the following folders as a source
    target/generated-sources/swagger/src/main/java/io/adobe/cloudmanager/jwt/swagger

The primary difference between the two is the generator plugin. I have tried different package definitions, and arrangements of the plugin execution configurations. However, it always seems to set it to .../jwt/* as the only generated classpath. It also sets the src/test/java path as a classpath, even though this is disabled in the plugin by default.

Related issues/PRs
Suggest a fix

I compared the Swagger Plugin's CodeGenMojo to see what may be different and found these lines. However, when i tried to add something similar and test locally, it didn't have any impact.

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 two IntelliJ/Maven states using adobe/aio-lib-java-cloudmanager and the replacement pom from the linked gist. Start by comparing the Maven plugin configuration with the referenced Swagger CodeGenMojo.java lines. Done means generated sources use target/generated-sources/swagger/src/main/java as the source root and src/test/java is not added as a classpath.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, developer-experience
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.