diff --git a/components/Message.js b/components/Message.js index 0c6fb2f86..767a055a7 100644 --- a/components/Message.js +++ b/components/Message.js @@ -1,7 +1,7 @@ import { Text } from "@asyncapi/generator-react-sdk"; -import { generateExample, getHeadersExamples, getPayloadExamples } from "@asyncapi/generator-filters"; +import { generateExample, getPayloadExamples, getHeadersExamples } from "@asyncapi/generator-filters"; -import { Header, ListItem, CodeBlock, BlockQuote } from "./common"; +import { Header, CodeBlock, BlockQuote, Tags } from "./common"; import { Schema } from "./Schema"; export function Message({ message, title = 'Message' }) { @@ -23,7 +23,7 @@ export function Message({ message, title = 'Message' }) { <>
Headers
- + )} @@ -31,7 +31,7 @@ export function Message({ message, title = 'Message' }) { <>
Payload
- + )} @@ -45,28 +45,14 @@ export function Message({ message, title = 'Message' }) { ) } -function Tags({ tags = [] }) { - return ( - - {tags.map(tag => ( - {tag.name()} - ))} - - ); -} - -function Example({ type = 'headers', message }) { +function Examples({ type = 'headers', message }) { if (type === 'headers') { const examples = getHeadersExamples(message); if (examples) { return ( <>
Examples of headers
- {examples.map(ex => ( - - {JSON.stringify(ex, null, 2)} - - ))} + ); } @@ -85,11 +71,7 @@ function Example({ type = 'headers', message }) { return ( <>
Examples of payload
- {examples.map(ex => ( - - {JSON.stringify(ex, null, 2)} - - ))} + ); } @@ -104,3 +86,17 @@ function Example({ type = 'headers', message }) { ); } } + +function Example({ examples = [] }) { + if (examples.length === 0) { + return null; + } + + return examples.map(ex => ( + + {ex.name && **{ex.name}**} + {ex.summary && {ex.summary}} + {JSON.stringify(ex.example, null, 2)} + + )) +} diff --git a/components/common.js b/components/common.js index 2d3509035..f4b34eed6 100644 --- a/components/common.js +++ b/components/common.js @@ -57,3 +57,12 @@ export function BlockQuote({ childrenContent = "" }) { return {`> ${childrenContent}`} } +export function Tags({ tags = [] }) { + return ( + + {tags.map(tag => ( + {tag.name()} + ))} + + ); +} diff --git a/package-lock.json b/package-lock.json index 338ba450b..d8edbcf5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -77,9 +77,9 @@ } }, "@asyncapi/generator-filters": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@asyncapi/generator-filters/-/generator-filters-1.1.0.tgz", - "integrity": "sha512-04Z2mMi3iv1jl7RZ1U5DX+Ruet5BOHLzEMSsl0vnYx2UZCM0AIlMvS6ph5JHv2AhBTD65a4Lfnsdr8qz0ybW+g==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@asyncapi/generator-filters/-/generator-filters-2.0.0.tgz", + "integrity": "sha512-KTcdPrdF2qPtiW4VCwIJmX+U0S8teeRaZ3UX1l5PIluWxc4RPNnIkQvpRMJyrdw7nJFGuX1yu1bvhCzqBoWyhA==", "requires": { "lodash": "^4.17.15", "markdown-it": "^10.0.0", diff --git a/package.json b/package.json index 83c8b1836..c8ec2a4dd 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "access": "public" }, "dependencies": { - "@asyncapi/generator-filters": "^1.1.0", + "@asyncapi/generator-filters": "^2.0.0", "@asyncapi/generator-react-sdk": "^0.2.11", "yaml": "^1.10.0" },