Skip to content

[BUG] nested references to external schema are not resolved properly in swagger parser v3. #1949

Description

@rojaranivutukuri

I have defined schema in following structure.

├── schema
    ├── com
          ├── wf
               ├── test
                     ├── schema_a.yaml
                     ├── schema_b.yaml

schema_a.yaml:

openapi: 3.0.0
info:
  title: SCHEMA A
  version: 1.0.2
  description: Links
  x-package: com.workfusion.test
components:
  schemas:
    TypeFromB:
      $ref: 'schema/com/wf/test/schema_b.yaml#/components/schemas/MyType'
    UnrelatedType:
      type: object

schema_b.yaml:

openapi: 3.0.0
info:
  title: SCHEMA B
  version: 1.0.2
  description: Links
  x-package: com.workfusion.test
components:
  schemas:
    MyType:
      type: string

and I want to parse the below schema:

openapi: 3.0.0
info:
  title: REF SCHEMA A
  version: 1.0.1
components:
  schemas:
    in:
      type: object
      properties:
        schema_a_ref:
          $ref: 'schema/com/wf/test/schema_a.yaml#/components/schemas/TypeFromB'

parsing using

OpenAPIV3Parser parser = new OpenAPIV3Parser();
ParseOptions options = new ParseOptions();
options.setResolve(true);
return parser.readContents(yamlSchema, null, options, schemaDir.toAbsolutePath().toString());

and I got below error:
Unable to load RELATIVE ref: schema\com\wf\test\schema\com\wf\test\schema_b.yaml

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions