redoc
redoc copied to clipboard
feat: Custom Extension Components
Custom Element for openapi extensions
Inspired by Extended Markdown Components feature, add the ability to customize how an extension should be rendered. Backwards compatible.
Usage:
openapi: 3.0.0
paths:
/pet:
post:
x-custom: # or whatever the extension lives
- foo
- bar
const options: RedocRawOptions = {
showExtensions: true,
extensionsComponents: {
'x-custom': {
component: ExtensionCustomComponent,
propsSelector: (store: AppStore) => store.spec.parser.spec,
props: { defined: true },
},
},
}
type Props = OpenAPISpec & { defined: boolean } & {
'x-custom': any
};
class ExtensionCustomComponent extends React.PureComponent<Props> {
render() {
// this.props['x-custom'] === ['foo', 'bar']
// this.props.defined === true
// this.props also has what propsSelector returns, in this case, all the spec properties
}
}
Coverage decreased (-0.1%) to 82.453% when pulling 6f34a3530d77c97a2786199de969f7cc7c391da8 on jmendiara:feat/extensionComponents into 2f65f051e0ede6d786d510cc1ddad2889ab9d367 on Rebilly:master.
@RomanHotsiy Any chance to get this merged? Do you need something from my side?
Hey @jmendiara. This PR looks really great 👍
I will review it carefully early next week though. Sorry for the delay.
Hey @RomanHotsiy :) did you have some time to review this?
Hey @RomanHotsiy...
any news on this?
@RomanHotsiy This PR is published in npm in case you want to try it and helps in merging this PR
npm install @jmendiara/[email protected]
https://www.npmjs.com/package/@jmendiara/redoc/v/2.0.0-rc.23-customComponents.1
@RomanHotsiy Any update?
If this helps on merging, the full changeset is now rebased against main
@RomanHotsiy did you find some time to consider this PR? We've been using it in production for several years now and we'd like to avoid forking redoc if possible. Thank you.
First of all, thank you for building this and sharing it with us! It's a good use case, but we eventually decided that this feature is not something that we're comfortable adopting at this time. I'm therefore closing this pull request, and I'm sorry it hung around without a clear outcome for so long.