Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

fix: issue where polymorphism titles in refs wouldn't be surfaced #898

Merged
merged 1 commit into from
Aug 27, 2020

Conversation

erunion
Copy link
Member

@erunion erunion commented Aug 26, 2020

🧰 What's being changed?

This fixes a bug in how we generate JSON Schema for the Params component where under certain conditions, title properties on polymorphism schemas (oneOf, anyOf, and allOf) would be deleted.

This also patches in a workaround for a bug in RJSF where if a title property is within a $ref and not at the level of the $ref, it wouldn't be used when constructing a dropdown for the schemas, instead displaying a placeholder label of "Option 1". Bug ticketed here.

🧪 Testing

You can see this bug in action here: http://bin.readme.com/s/5f46ce04c46abe00244f41f6

Though the Cat and Dog schemas have a title property, it's not used in the dropdown.

With this fix, it now looks like:

Screen Shot 2020-08-26 at 2 03 43 PM

Copy link
Member

@domharrington domharrington left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@darrenyong darrenyong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this with polymorphism.json as well as the Swagger files of the customers that were experiencing this issue and adding title under the $ref components correctly renders the title rather than having Option 1, Option 2, etc.

@erunion erunion merged commit f3becfe into next Aug 27, 2020
@erunion erunion deleted the fix/polymorphism-titles branch August 27, 2020 22:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants