Skip to content

Commit 214e90e

Browse files
authored
[Enhancement] Add option to hide send button (#456)
* Update mustache template * Add hideSendButton option * Toggle send button with hide_send_button * Update frontMatter.hide_send_button if true * Disable send button for testing * Unhide send button
1 parent 31d36c1 commit 214e90e

File tree

6 files changed

+18
-2
lines changed

6 files changed

+18
-2
lines changed

demo/api.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ custom_edit_url: null
2828
{{#frontMatter.proxy}}
2929
proxy: {{{frontMatter.proxy}}}
3030
{{/frontMatter.proxy}}
31+
{{#frontMatter.hide_send_button}}
32+
hide_send_button: true
33+
{{/frontMatter.hide_send_button}}
3134
---
3235

3336
{{{markdown}}}

packages/docusaurus-plugin-openapi-docs/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ custom_edit_url: null
190190
{{#frontMatter.proxy}}
191191
proxy: {{{frontMatter.proxy}}}
192192
{{/frontMatter.proxy}}
193+
{{#frontMatter.hide_send_button}}
194+
hide_send_button: true
195+
{{/frontMatter.hide_send_button}}
193196
---
194197
195198
{{{markdown}}}

packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ function createItems(
221221
.replace(/\s+$/, "")
222222
: "",
223223
...(options?.proxy && { proxy: options.proxy }),
224+
...(options?.hideSendButton && {
225+
hide_send_button: options.hideSendButton,
226+
}),
224227
},
225228
api: {
226229
...defaults,
@@ -338,6 +341,9 @@ function createItems(
338341
.replace(/\s+$/, "")
339342
: "",
340343
...(options?.proxy && { proxy: options.proxy }),
344+
...(options?.hideSendButton && {
345+
hide_send_button: options.hideSendButton,
346+
}),
341347
},
342348
api: {
343349
...defaults,

packages/docusaurus-plugin-openapi-docs/src/options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const OptionsSchema = Joi.object({
2727
outputDir: Joi.string().required(),
2828
template: Joi.string(),
2929
downloadUrl: Joi.string(),
30+
hideSendButton: Joi.boolean(),
3031
sidebarOptions: sidebarOptions,
3132
version: Joi.string().when("versions", {
3233
is: Joi.exist(),

packages/docusaurus-plugin-openapi-docs/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface APIOptions {
3333
outputDir: string;
3434
template?: string;
3535
downloadUrl?: string;
36+
hideSendButton?: boolean;
3637
sidebarOptions?: SidebarOptions;
3738
version?: string;
3839
label?: string;

packages/docusaurus-theme-openapi-docs/src/theme/ApiDemoPanel/Request/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Request({ item }: { item: NonNullable<ApiItem> }) {
2525
const response = useTypedSelector((state: any) => state.response.value);
2626
const postman = new sdk.Request(item.postman);
2727
const metadata = useDoc();
28-
const { proxy } = metadata.frontMatter;
28+
const { proxy, hide_send_button } = metadata.frontMatter;
2929

3030
const params = {
3131
path: [] as ParameterObject[],
@@ -48,7 +48,9 @@ function Request({ item }: { item: NonNullable<ApiItem> }) {
4848
<summary>
4949
<div className={`details__request-summary`}>
5050
<h4>Request</h4>
51-
{item.servers && <Execute postman={postman} proxy={proxy} />}
51+
{item.servers && !hide_send_button && (
52+
<Execute postman={postman} proxy={proxy} />
53+
)}
5254
</div>
5355
</summary>
5456
<div className={styles.optionsPanel}>

0 commit comments

Comments
 (0)