-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: render bindings, extensions and circular references (#197)
- Loading branch information
1 parent
55f2ea3
commit e333440
Showing
18 changed files
with
1,206 additions
and
659 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Schema } from "./Schema"; | ||
|
||
import { SchemaHelpers } from "../helpers/schema" | ||
import { FormatHelpers } from "../helpers/format"; | ||
|
||
export function Bindings({ name = 'Binding specific information', item }) { | ||
const bindings = item.bindings(); | ||
if (!bindings || !Object.keys(bindings).length) { | ||
return null; | ||
} | ||
|
||
const renderBindings = Object.entries(bindings).map( | ||
([bindingName, binding]) => { | ||
const schema = SchemaHelpers.jsonToSchema(binding); | ||
const schemaName = `${FormatHelpers.inlineCode(bindingName)} ${name}`; | ||
return ( | ||
<Schema schemaName={schemaName} schema={schema} key={bindingName} /> | ||
); | ||
}, | ||
); | ||
|
||
return ( | ||
<> | ||
{renderBindings} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,27 @@ | ||
import { IndentationTypes, Text } from "@asyncapi/generator-react-sdk"; | ||
import { Text } from "@asyncapi/generator-react-sdk"; | ||
|
||
import { ListItem, Link } from "./common"; | ||
import { Header, Table } from "./common"; | ||
|
||
export function Tags({ tags = [] }) { | ||
export function Tags({ name = 'Tags', tags = [] }) { | ||
if (tags.length === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<> | ||
{tags.map(tag => ( | ||
<Tag tag={tag} key={tag.name()} /> | ||
))} | ||
</> | ||
); | ||
} | ||
|
||
function Tag({ tag }) { | ||
const description = tag.description(); | ||
const externalDocs = tag.externalDocs(); | ||
const tagsHeader = ['Name', 'Description', 'Documentation']; | ||
const tagsRenderer = (tag) => { | ||
const externalDocs = tag.externalDocs(); | ||
const externalDocsDescription = externalDocs && externalDocs.hasDescription() ? externalDocs.description() : 'Find more info here'; | ||
return [ | ||
tag.name() || '-', | ||
tag.description() || '-', | ||
externalDocs ? `[${externalDocsDescription}](${externalDocs.url()})` : '-', | ||
]; | ||
} | ||
|
||
return ( | ||
<> | ||
<Text> | ||
<ListItem>{tag.name()}</ListItem> | ||
</Text> | ||
{description && ( | ||
<Text indent={2} type={IndentationTypes.SPACES}> | ||
{description} | ||
</Text> | ||
)} | ||
{externalDocs && ( | ||
<Text indent={2} type={IndentationTypes.SPACES}> | ||
<Link | ||
href={externalDocs.url()} | ||
> | ||
{externalDocs.hasDescription() ? externalDocs.description() : 'Find more info here.'} | ||
</Link> | ||
</Text> | ||
)} | ||
</> | ||
<Text> | ||
<Header type={5}>{name}</Header> | ||
<Table headers={tagsHeader} rowRenderer={tagsRenderer} data={tags} /> | ||
</Text> | ||
); | ||
} |
Oops, something went wrong.