swagger-api / swagger-api/swagger-codegen-generators

OpenAPI 3 Model with Named Type "Schema" creates issues for Java Codegen

Open
#1,089 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

Issue Description

Open API spec with named model type "Schema" results in an issue that cannot be resolved by customizing templates due to the forced import of io.swagger.v3.oas.annotations.media.Schema. The actual usages of this import can be fixed via mustache templates with fully qualified names (can't use short name since it is the classname), but the import is generated via code and thus requires a fork of the repo to be able to get around.

Expected behavior

Codegen should be able to handle shortname overlap for Java imports.

Suggestions

Either add checks in code for short name overlap for required imports or just always use fully qualified names in the template files to avoid issues with imports (requires removal of a bunch of import setup code as well).

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 tracing the Java code-generation path that adds required imports and the Mustache template files involved in generated model usage. Reproduce an OpenAPI spec with a model named "Schema" and compare the generated imports and references; done means the generated Java code handles the name overlap without requiring a repository fork.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, 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.