-
Notifications
You must be signed in to change notification settings - Fork 30
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: add support for vendor extensions #245
Conversation
Introduces support to custom renderer for vendor extensions, by adding a new property named `renderExtensionAddon` which will call when vendor properties (properties prefixed with `x-`) are find the schema definition.
@billiegoose @daniel-white @brendarearden If someone could have a look at this would be great! |
@P0lip Can you have a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall! Thanks for the PR.
I'd appreciate it if you added a test - LMK if you have a question regarding that. Happy to help if needed
src/utils/extractVendorExtensions.ts
Outdated
* @returns VendorExtensionsResult | ||
*/ | ||
export function extractVendorExtensions(fragment: SchemaFragment = {}): VendorExtensionsResult { | ||
const extensionKeys = Object.keys(fragment).filter(key => key.toLowerCase().startsWith('x-')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should lower-case the key. If a key starts with an upper-cased X-, then IMHO it shouldn't be considered a spec ext.
Thanks, I will update the PR ASAP. I need to solve some work tasks first |
* master: fix: improve handling of array + dictionary combo (stoplightio#251) feat: support dictionaries (stoplightio#249) # Conflicts: # src/components/SchemaRow/TopLevelSchemaRow.tsx
@P0lip Sorry, I was on vacation for Chinese New Year. I have updated the PR now. Please let me know, what you think of it :) |
Anymore changes needed? I would love to be able to stop maintaining a fork of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
I'll merge it tomorrow. |
Awesome excited 👯♀️ :) Thank you! 🙏 |
@P0lip Would you be able to merge it? Love to raise a PR in Elements to bump with this support :) |
🎉 This PR is included in version 4.16.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Awesome thank you 👯 |
Motivation and Context
Adds support for rendering vendor extensions as part of a schema row or the top level schema
Fixes #236
Description
Introduces support to custom renderer for vendor extensions, by adding a new property named
renderExtensionAddon
which will call when vendor properties (properties prefixed withx-
) are find the schema definition.How Has This Been Tested?
Tested in production for our internal documentation
Screenshot(s)/recordings(s)
Rendering of a vendor extension that shows the
![CleanShot 2024-02-20 at 15 28 52@2x](https://private-user-images.githubusercontent.com/7049/306322991-d6686869-ac96-41c8-9bca-fae84ed77d60.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE1MjQ1NDQsIm5iZiI6MTcyMTUyNDI0NCwicGF0aCI6Ii83MDQ5LzMwNjMyMjk5MS1kNjY4Njg2OS1hYzk2LTQxYzgtOWJjYS1mYWU4NGVkNzdkNjAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyMSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjFUMDExMDQ0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTVkNzE2NWJlZjk2MTVjOWEyNDBhNGQ5ZDM1MzgxZjdjNTljZmZiZDNjZjgzMzRhMTFmYjAyMDU0ZTZjYWI0NiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.iQ12wlOGBBYTLXWrDYwPxCR1NEWbWsirHS-7dp_Rhqk)
x-stoplight
extension, in this example, it only returns a React element for any extensions with a nesting level higher than 0Types of changes
Checklist