From 2becbd998a61329318869a104453c784c5b2333b Mon Sep 17 00:00:00 2001 From: Tobias Sauerwein Date: Mon, 17 Jun 2024 10:59:26 +0200 Subject: [PATCH] Add config to always show message examples --- docs/configuration/config-modification.md | 6 +++++- library/src/config/config.ts | 1 + library/src/config/default.ts | 1 + library/src/containers/Messages/Messages.tsx | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/configuration/config-modification.md b/docs/configuration/config-modification.md index 633260303..b1c6ec19f 100644 --- a/docs/configuration/config-modification.md +++ b/docs/configuration/config-modification.md @@ -17,6 +17,7 @@ interface ConfigInterface { servers?: boolean; operations?: boolean; messages?: boolean; + messageExamples?: boolean; schemas?: boolean; errors?: boolean; }; @@ -45,7 +46,10 @@ interface ConfigInterface { - **show?: Partial** This field contains configuration responsible for rendering specific parts of the AsyncAPI component. - All except the `sidebar` fields are set to `true` by default. + The `sidebar` and `messageExamples` fields are set to `false` by default. The default for all other fields is `true`. + + The examples for messages shown within an operation are always displayed. To also show examples for the + standalone messages in the "Messages" section, set `messageExamples` to `true`. - **sidebar?: Partial** diff --git a/library/src/config/config.ts b/library/src/config/config.ts index 0218996eb..39b55ce7f 100644 --- a/library/src/config/config.ts +++ b/library/src/config/config.ts @@ -19,6 +19,7 @@ export interface ShowConfig { servers?: boolean; operations?: boolean; messages?: boolean; + messageExamples?: boolean; schemas?: boolean; errors?: boolean; } diff --git a/library/src/config/default.ts b/library/src/config/default.ts index 725fff4c5..12e6dffa6 100644 --- a/library/src/config/default.ts +++ b/library/src/config/default.ts @@ -16,6 +16,7 @@ export const defaultConfig: ConfigInterface = { servers: true, operations: true, messages: true, + messageExamples: false, schemas: true, errors: true, }, diff --git a/library/src/containers/Messages/Messages.tsx b/library/src/containers/Messages/Messages.tsx index 876835837..52300c2bc 100644 --- a/library/src/containers/Messages/Messages.tsx +++ b/library/src/containers/Messages/Messages.tsx @@ -36,6 +36,7 @@ export const Messages: React.FunctionComponent = () => { message={message} index={idx + 1} key={message.id()} + showExamples={config?.show?.messageExamples ?? false} /> ))}