Skip to content

Commit

Permalink
feat: add configuration to always show message examples (#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsauerwein authored Jul 3, 2024
1 parent 482464d commit 282829f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/configuration/config-modification.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface ConfigInterface {
servers?: boolean;
operations?: boolean;
messages?: boolean;
messageExamples?: boolean;
schemas?: boolean;
errors?: boolean;
};
Expand Down Expand Up @@ -45,7 +46,10 @@ interface ConfigInterface {
- **show?: Partial<ShowConfig>**

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<SideBarConfig>**

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 @@ -19,6 +19,7 @@ export interface ShowConfig {
servers?: boolean;
operations?: boolean;
messages?: boolean;
messageExamples?: boolean;
schemas?: boolean;
errors?: boolean;
}
Expand Down
1 change: 1 addition & 0 deletions library/src/config/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const defaultConfig: ConfigInterface = {
servers: true,
operations: true,
messages: true,
messageExamples: false,
schemas: true,
errors: true,
},
Expand Down
1 change: 1 addition & 0 deletions library/src/containers/Messages/Messages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const Messages: React.FunctionComponent = () => {
message={message}
index={idx + 1}
key={message.id()}
showExamples={config?.show?.messageExamples ?? false}
/>
</li>
))}
Expand Down

0 comments on commit 282829f

Please sign in to comment.