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: react component for extension catalog #884

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions library/src/components/Extensions.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import React from 'react';
import { Schema } from './Schema'
import { SchemaHelpers } from '../helpers';
import type { AsyncAPIDocumentInterface, BaseModel } from "@asyncapi/parser"
import type { ConfigInterface } from "../config"

import { Schema } from './Schema';

import { SchemaHelpers } from '../helpers';

export interface ExtensionComponentProps<V = any> {
key: string;
value: V;
document: AsyncAPIDocumentInterface
config: ConfigInterface
parent: BaseModel
}
interface Props {
name?: string;
item: any;
extensions: ExtensionsInterface;
}

export const Extensions: React.FunctionComponent<Props> = ({
name = 'Extensions',
item,
name = 'Extensions Specific Information',
extensions,
}) => {
const extensions = SchemaHelpers.getCustomExtensions(item);
const extensions = SchemaHelpers.getCustomExtensions(extensions);
if (!extensions || !Object.keys(extensions).length) {
return null;
}
Expand Down
1 change: 1 addition & 0 deletions library/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface ConfigInterface {
receiveLabel?: string;
requestLabel?: string;
replyLabel?: string;
extensions: Record<string, React.ComponentType<ExtensionComponentProps>>
}

export interface ShowConfig {
Expand Down
Loading