From 282829f3b2e610653252383953ec1f79607e0e6b Mon Sep 17 00:00:00 2001 From: Tobias Sauerwein Date: Wed, 3 Jul 2024 20:31:57 +0200 Subject: [PATCH] feat: add configuration to always show message examples (#1016) --- 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 63326030..b1c6ec19 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 0218996e..39b55ce7 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 725fff4c..12e6dffa 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 87683583..52300c2b 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} /> ))}