From 69c5ce252e546117a0462fe569434fd7dfdcc9ea Mon Sep 17 00:00:00 2001 From: Martin Helmich Date: Tue, 2 Jul 2024 09:57:30 +0200 Subject: [PATCH] Fix display of array items in Schema component This commit changes the display of array items so that the actual sub-schema of said items is displayed. This reduces the asthetic annoyance when an empty "Array[]" schema is displayed (when no sub-schema is given), and also fixes a bug where the description of array items was not rendered at all. --- src/components/openapi/OperationInputValue.tsx | 6 ++++-- src/components/openapi/Schema.tsx | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/openapi/OperationInputValue.tsx b/src/components/openapi/OperationInputValue.tsx index b5e484e8..cc7708c4 100644 --- a/src/components/openapi/OperationInputValue.tsx +++ b/src/components/openapi/OperationInputValue.tsx @@ -34,7 +34,7 @@ export function ArrayValue({ schema }: { schema: OpenAPIV3.SchemaObject }) { Array[
{body}
- +
]
@@ -58,6 +58,8 @@ export function PropertyValue({ body = {schema.description}; } + const hasSubSchema = schema.properties || schema.additionalProperties || schema.items; + return (
  • @@ -67,7 +69,7 @@ export function PropertyValue({ {requiredOrOptional}
    {body}
    - + {hasSubSchema && }
  • ); } diff --git a/src/components/openapi/Schema.tsx b/src/components/openapi/Schema.tsx index d8010582..845e24b3 100644 --- a/src/components/openapi/Schema.tsx +++ b/src/components/openapi/Schema.tsx @@ -92,4 +92,6 @@ export default function Schema({ schema }: Props) { if (schema.type === "array") { return ; } + + return ; }