Skip to content

referencing a schema from another file breaks nswag if that schema has an internal ref #2536

@Place1

Description

@Place1

If I try to use NSwag with a spec that references a schema from another spec, but the referenced schema uses an internal $ref then NSwag crashes with the following error:

Unhandled Exception: System.InvalidOperationException: Could not resolve the path '#/components/schemas/Owner

here's an example set of specs i'm using:

# spec-a.yaml

openapi: 3.0.0

paths: {}

components:
  schemas:
    Home:
      type: object
      additionalProperties: false
      required:
        - name
        - owner
      properties:
        name:
          type: string
        owner:
          $ref: '#/components/schemas/Owner'

    Owner:
      type: object
      additionalProperties: false
      required:
        - name
      properties:
        name:
          type: string
# spec-b.yaml

openapi: 3.0.0

paths: {}

components:
  schemas:
    Thing:
      type: object
      additionalProperties: false
      required:
        - home
      properties:
        home:
          $ref: './spec-a.yaml#/components/schemas/Home'

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions