OpenAPITools / OpenAPITools/openapi-generator

[BUG] swagger parser failed to resolve complex external references

Open
#6,019 2 comments 8 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug Server: C-Sharp
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)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description
openapi-generator version

4.3.1 from latest master

OpenAPI declaration file content or url

test.yaml

openapi: 3.0.2
info:
  title: Test
  version: 0.1.0
servers:
  - url: http://localhost
paths:
  /tags:
    $ref: "paths/tag.yaml#/~1tags"

paths/tag.yaml

/tags:
  get:
    summary: get tags
    operationId: GetTags
    parameters:
      - name: type
        in: query
        description: type of tag
        schema:
          $ref: "../components/misc.yaml#/TagType"
        required: true
    responses:
      200:
        description: successful operation
        content:
          application/json:
            schema:
              $ref: "../components/misc.yaml#/Tag"

components/misc.yaml

Tag:
  type: object
  properties:
    test:
      $ref: "#/TagType"
TagType:
  type: string
  enum:
    - school
Command line used for generation

default option. any language. An example is

openapi-generator generate -g aspnetcore -i ./test.yaml
Steps to reproduce

generate throws warning

[main] WARN  i.s.v.p.p.ExternalRefProcessor - A model for class StringSchema {
    class Schema {
        type: string
        format: null
        $ref: null
        description: null
        title: null
        multipleOf: null
        maximum: null
        exclusiveMaximum: null
        minimum: null
        exclusiveMinimum: null
        maxLength: null
        minLength: null
        pattern: null
        maxItems: null
        minItems: null
        uniqueItems: null
        maxProperties: null
        minProperties: null
        required: null
        not: null
        properties: null
        additionalProperties: null
        nullable: null
        readOnly: null
        writeOnly: null
        example: null
        externalDocs: null
        deprecated: null
        discriminator: null
        xml: null
    }
} already exists
Related issues/PRs

Might be related to https://github.com/OpenAPITools/openapi-generator/pull/5413

Suggest a fix

Want to first make sure it's not other bugs causing this. Then I'll file an issue to swagger parser. In the meantime, maybe we want to downgrade parser to 2.0.17?

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 warning with test.yaml, paths/tag.yaml, and components/misc.yaml using the documented openapi-generator command. Start by tracing ExternalRefProcessor and the related pull request #5413 to see how nested external references are handled. Done means generation resolves Tag and TagType without the reported duplicate-model warning.

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.