Discriminator / OneOf broken when using external file reference
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 25.9k
- Forks
- 2.4k
- Avg merge
- 13h 10m
- Merged PRs (30d)
- 4
Description
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 :
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) :
Please tell me if you need more informations to fix it, thanks !
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided OpenAPI document and external-file.yaml, then inspect oneOf handling at src/components/Schema/Schema.tsx around line 43. Compare the discriminator case with the working case without discriminator; done means externally referenced schemas render under oneOf and display their schema names correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100