Skip to content

Commit 9f1fc5d

Browse files
committed
refactor: CustomizeType
1 parent 09922f3 commit 9f1fc5d

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

src/theme/JSONSchemaViewer/utils/generateFriendlyName.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from "react"
22

3-
import CodeBlock from "@theme-original/CodeBlock"
4-
53
// Utility functions to know which case we have
64
import { detectedTypes } from "@theme/JSONSchemaViewer/utils"
75

@@ -140,21 +138,12 @@ function CustomizeType({ schema, type }: CustomizeProps): JSX.Element {
140138
}
141139

142140
// For constant values
143-
// I used Docusaurus Codeblock (instead of printSchemaType) as they put quotes whereas normal <code> don't
144141
if (!["array", "object"].includes(type)) {
145142
if (schema.const !== undefined) {
146-
return (
147-
<CodeBlock language="json">{`${JSON.stringify(
148-
schema.const,
149-
)}`}</CodeBlock>
150-
)
143+
return <code>{`${JSON.stringify(schema.const)}`}</code>
151144
}
152145
if (schema.enum !== undefined && schema.enum.length === 1) {
153-
return (
154-
<CodeBlock language="json">{`${JSON.stringify(
155-
schema.enum[0],
156-
)}`}</CodeBlock>
157-
)
146+
return <code>{`${JSON.stringify(schema.enum[0])}`}</code>
158147
}
159148
}
160149

0 commit comments

Comments
 (0)