Skip to content

Discriminator / OneOf broken when using external file reference #862

Open
@tms0

Description

@tms0

The discriminator functionnality is broken when using with external files. Here's a reproducible test case :

openapi: 3.0.0
info:
  title: test
  version: 1.0.0
paths:
  /test:
    get:
      responses:
        '200':
          description: test
          content:
            'application/json':
              schema:
                oneOf:
                  - $ref: './external-file.yaml#/components/schemas/simpleObject'
                  - $ref: './external-file.yaml#/components/schemas/complexObject'
                discriminator:
                  propertyName: objectType

## external-file.yaml :
openapi: 3.0.0
components:
  schemas:
    simpleObject:
      type: object
      required:
        - objectType
      properties:
        objectType:
          type: string
    complexObject:
      type: object
      required:
        - objectType
      properties:
        objectType:
          type: string

And when we try to see the responses object in ReDoc, we have the following error :

2019-03-21 10_07_31-MPD API PRIVEE - NFC 1 3

I tried to debug it quickly, and I figured out that in this case, the oneOf variable is empty : https://github.com/Rebilly/ReDoc/blob/master/src/components/Schema/Schema.tsx#L43

Another related issue (I think) : if we remove the discriminator part, it will work but the schemas names are not displayed correctly (object instead of simpleObject for example) :

2019-03-21 10_14_57-MPD API PRIVEE - NFC 1 3

Please tell me if you need more informations to fix it, thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugopenapiQuestions about specification, validity, and edge cases

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions