swagger-api / swagger-api/swagger-codegen

[JAVA] Skipping alias models is hardcoded to the `java` and `inflector` languages

Open
#8,373 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

Description

As Java does not supporting alias types, any APIs which use these types will get the base type of the alias. In DefaultGenerator.java, there is code to skip the generation of model files for these aliased types, but this is hardcoded to the java and inflector languages. Any other Java-based generator with aliased types will produced non-compiling empty models.

Swagger-codegen version

Latest from 3.0.0 branch

Swagger declaration file content or url
openapi: 3.0.0
components:
  schemas:
    Int32:
      format: int32
      type: integer
info:
  version: 1.0.0
  title: Test
  license:
    name: MIT
paths:
  /test/{id}:
    get:
      operationId: getById
      parameters:
      - in: path
        name: id
        required: true
        schema:
          $ref: '#/components/schemas/Int32'
      responses:
        '200':
          description: success
Command line used for generation

java -jar swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i test.yaml -l jaxrs-resteasy -o test

Steps to reproduce

Generate a project with a Java language other than java or inflector (e.g. jaxrs-resteasy)

Related issues/PRs

None

Suggest a fix/enhancement

See PR #8374

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 in modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java, especially the alias-model handling around lines 379 and 1025. Reproduce the issue with the provided OpenAPI document and jaxrs-resteasy command, then review PR #8374. Done means other Java-based generators no longer produce empty, non-compiling models for aliased types.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.