Skip to content

Commit

Permalink
add support for json schema null type (#1068)
Browse files Browse the repository at this point in the history
  • Loading branch information
sserrata authored Jan 24, 2025
1 parent 64f8f65 commit e785058
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion demo/examples/petstore-3.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,9 @@ components:
- $ref: "#/components/schemas/Category"
name:
description: The name given to a pet
type: string
type:
- string
- "null"
example: Guru
photoUrls:
description: The list of URL to a cute photos featuring pet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ export default function SchemaItem(props: Props) {
enumDescriptions = transformEnumDescriptions(schema["x-enumDescriptions"]);
defaultValue = schema.default;
example = schema.example;
nullable = schema.nullable;
nullable =
schema.nullable ||
(Array.isArray(schema.type) && schema.type.includes("null")); // support JSON Schema nullable
}

console.log(schema);

const renderRequired = guard(
Array.isArray(required) ? required.includes(name) : required,
() => <span className="openapi-schema__required">required</span>
Expand Down

0 comments on commit e785058

Please sign in to comment.