Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: preserving ref schema names during dereferencing #481

Merged
merged 1 commit into from
Aug 16, 2021

Conversation

erunion
Copy link
Member

@erunion erunion commented Aug 16, 2021

🧰 Changes

With the work I did in #479, I accidentaly broke some functionality in our form generator where for an anyOf or oneOf schema we use the name of the component schema if there isn't a title present. Since those schemas are no longer always present we need an alternative way to expose what the schema was called, and we're doing that now with this x-readme-ref-name extension.

Pre-dereferencing we now run through all component schemas and note what their name is so that when we dereference that metadata will be preserved wherever that schema $ref is utilized.

🧬 QA & Testing

See tests.

@erunion erunion added the enhancement New feature or request label Aug 16, 2021
@erunion erunion requested review from Dashron and julshotal August 16, 2021 18:49
// dereferencing happens below those names will be preserved.
if (oas && oas.components && oas.components.schemas && typeof oas.components.schemas === 'object') {
Object.keys(oas.components.schemas).forEach(schemaName => {
oas.components.schemas[schemaName]['x-readme-ref-name'] = schemaName;
Copy link
Contributor

Choose a reason for hiding this comment

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

clean and simple, love it.

@erunion erunion merged commit a9b0d00 into main Aug 16, 2021
@erunion erunion deleted the feat/store-schema-metadata branch August 16, 2021 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants