0.0.4 • Published 1 year ago
grpc-custom-docs-render v0.0.4
grpc-custom-docs-render
Installation
Add the plugin to backstage dependencies
yarn add grpc-custom-docs-render --save
And then hook it to api docs:
// on packages/app/src/apis.ts
import { CustomGrpcDefinitionWidget } from 'grpc-custom-docs-render';
// ...
export const apis: AnyApiFactory[] = [
// other apis
// ...
createApiFactory({
api: apiDocsConfigRef,
deps: {},
factory: () => {
// load the default widgets
const definitionWidgets = defaultDefinitionWidgets();
return {
getApiDefinitionWidget: (apiEntity: ApiEntity) => {
if (apiEntity.spec.type === 'custom-grpc') {
return {
type: 'custom-grpc',
title: 'Custom Grpc',
component: definition => <CustomGrpcDefinitionWidget definition={definition}/>,
} as ApiDefinitionWidget;
}
// fallback to the defaults
return definitionWidgets.find(d => d.type === apiEntity.spec.type);
},
};
},
}),
]