swagger-api / swagger-api/swagger-codegen

[JAVA] Refs with depth greater than 2 are not resolved properly

Open
#9,547 2 comments 3 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

Refs having file depth greater than 2 are not resolved properly.

Swagger-codegen version

2.4.6

Swagger declaration file content or url

First file (test.yaml)

definitions:
  test:
    type: 'object'
    properties:
      test:
        $ref: 'test2.yaml#/definitions/MyTestCluster'

Second file (test2.yaml)

definitions:
  MyTestCluster:
    $ref: 'test3.yaml#/definitions/my.test.Cluster'

Third file (test3.yaml)

definitions:
  my.test.Cluster:
      type: 'object'
      properties:
        value:
          type: 'integer'
          format: 'int64'
Command line used for generation

java -jar swagger-codegen-cli.jar generate -l java -i test.yaml -o out/

Steps to reproduce

Create 3 files with refs chaining from the first file to the third and try to generate java code.

Suggest a fix/enhancement

Will try to debug, for now it look like there's a problem in DefinitionsProcessor.processDefinitions method.

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 with DefinitionsProcessor.processDefinitions and reproduce the issue using the three linked YAML files and the Java generation command. Trace the chained refs from test.yaml through test2.yaml to test3.yaml; done means the third-level definition resolves and Java code generation succeeds.

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.