Skip to content

Commit e785058

Browse files
authored
add support for json schema null type (#1068)
1 parent 64f8f65 commit e785058

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

demo/examples/petstore-3.1.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,9 @@ components:
10771077
- $ref: "#/components/schemas/Category"
10781078
name:
10791079
description: The name given to a pet
1080-
type: string
1080+
type:
1081+
- string
1082+
- "null"
10811083
example: Guru
10821084
photoUrls:
10831085
description: The list of URL to a cute photos featuring pet

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,13 @@ export default function SchemaItem(props: Props) {
7272
enumDescriptions = transformEnumDescriptions(schema["x-enumDescriptions"]);
7373
defaultValue = schema.default;
7474
example = schema.example;
75-
nullable = schema.nullable;
75+
nullable =
76+
schema.nullable ||
77+
(Array.isArray(schema.type) && schema.type.includes("null")); // support JSON Schema nullable
7678
}
7779

80+
console.log(schema);
81+
7882
const renderRequired = guard(
7983
Array.isArray(required) ? required.includes(name) : required,
8084
() => <span className="openapi-schema__required">required</span>

0 commit comments

Comments
 (0)