Skip to content

Commit e941b41

Browse files
committed
render default value as string literal instead of markdown
1 parent dca70f4 commit e941b41

File tree

1 file changed

+29
-7
lines changed
  • packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem

1 file changed

+29
-7
lines changed

packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/index.tsx

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default function SchemaItem(props: Props) {
6565
} = props;
6666
let deprecated;
6767
let schemaDescription;
68-
let defaultValue;
68+
let defaultValue: string | undefined;
6969
let nullable;
7070
let enumDescriptions: [string, string][] = [];
7171

@@ -133,11 +133,33 @@ export default function SchemaItem(props: Props) {
133133
</div>
134134
));
135135

136-
const renderDefaultValue = guard(defaultValue, (value) => (
137-
<div className="">
138-
<ReactMarkdown children={`**Default value:** \`${value}\``} />
139-
</div>
140-
));
136+
function renderDefaultValue() {
137+
if (defaultValue !== undefined) {
138+
if (typeof defaultValue === "string") {
139+
return (
140+
<div>
141+
<strong>
142+
Default value:{" "}
143+
<span>
144+
<code>{defaultValue}</code>
145+
</span>
146+
</strong>
147+
</div>
148+
);
149+
}
150+
return (
151+
<div>
152+
<strong>
153+
Default value:{" "}
154+
<span>
155+
<code>{JSON.stringify(defaultValue)}</code>
156+
</span>
157+
</strong>
158+
</div>
159+
);
160+
}
161+
return undefined;
162+
}
141163

142164
const schemaContent = (
143165
<div>
@@ -158,7 +180,7 @@ export default function SchemaItem(props: Props) {
158180
{renderDeprecated}
159181
</span>
160182
{renderQualifierMessage}
161-
{renderDefaultValue}
183+
{renderDefaultValue()}
162184
{renderSchemaDescription}
163185
{renderEnumDescriptions}
164186
{collapsibleSchemaContent ?? collapsibleSchemaContent}

0 commit comments

Comments
 (0)