From beacf960b30292e796e94f571ed59436fb6f1d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Dzivjak?= Date: Wed, 25 Feb 2026 12:08:07 +0100 Subject: [PATCH 1/3] feat: improve API specs rendering Don't show 'Show attributes' for primitive types of object without properties. --- src/components/ApiDocs/Schema.astro | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/components/ApiDocs/Schema.astro b/src/components/ApiDocs/Schema.astro index cffbb092..0c193312 100644 --- a/src/components/ApiDocs/Schema.astro +++ b/src/components/ApiDocs/Schema.astro @@ -14,6 +14,23 @@ const isNonArraySchemaObject = ( ): object is OpenAPIV3_1.NonArraySchemaObject => !!object && !("items" in object); +const hasRenderableAttributes = ( + object: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject | undefined, +): boolean => { + if (!object) return false; + + const schema = resolveSchema(object); + const hasProperties = Object.keys(schema.properties || {}).length > 0; + + if (hasProperties) return true; + + if (schema.type === "array" && "items" in schema) { + return hasRenderableAttributes(schema.items); + } + + return false; +}; + export interface Props { kind: string; schema: OpenAPIV3_1.SchemaObject; @@ -58,7 +75,9 @@ const schema = resolveSchema(obj); schema.type === "array" && "items" in schema && (
- + {hasRenderableAttributes(schema.items) && ( + + )}
) } @@ -91,13 +110,15 @@ const schema = resolveSchema(obj); {propertySchema.description && ( {propertySchema.description} )} - {"type" in propertySchema && propertySchema.type === "object" && ( + {propertySchema.type === "object" && + hasRenderableAttributes(propertySchema) && ( )} - {"type" in def && propertySchema.type === "array" && ( + {propertySchema.type === "array" && + hasRenderableAttributes(propertySchema.items) && ( Date: Wed, 25 Feb 2026 12:14:23 +0100 Subject: [PATCH 2/3] fix(api): improve sub-schemas resolution --- src/components/ApiDocs/Schema.astro | 67 ++++++++++++++++++----------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/src/components/ApiDocs/Schema.astro b/src/components/ApiDocs/Schema.astro index 0c193312..6f4dc3e5 100644 --- a/src/components/ApiDocs/Schema.astro +++ b/src/components/ApiDocs/Schema.astro @@ -14,21 +14,21 @@ const isNonArraySchemaObject = ( ): object is OpenAPIV3_1.NonArraySchemaObject => !!object && !("items" in object); -const hasRenderableAttributes = ( +const getRenderableAttributesSchema = ( object: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject | undefined, -): boolean => { - if (!object) return false; +): OpenAPIV3_1.SchemaObject | null => { + if (!object) return null; const schema = resolveSchema(object); const hasProperties = Object.keys(schema.properties || {}).length > 0; - if (hasProperties) return true; + if (hasProperties) return schema; if (schema.type === "array" && "items" in schema) { - return hasRenderableAttributes(schema.items); + return getRenderableAttributesSchema(schema.items); } - return false; + return null; }; export interface Props { @@ -72,14 +72,20 @@ const schema = resolveSchema(obj); } {!nested && !collapsable &&

{schema.title || kind}

} { - schema.type === "array" && "items" in schema && ( -
- - {hasRenderableAttributes(schema.items) && ( - - )} -
- ) + schema.type === "array" && + "items" in schema && + (() => { + const attributesSchema = getRenderableAttributesSchema(schema.items); + + return ( +
+ + {attributesSchema && ( + + )} +
+ ); + })() }
    { @@ -111,19 +117,28 @@ const schema = resolveSchema(obj); {propertySchema.description} )} {propertySchema.type === "object" && - hasRenderableAttributes(propertySchema) && ( - - )} + getRenderableAttributesSchema(propertySchema) && ( + + )} {propertySchema.type === "array" && - hasRenderableAttributes(propertySchema.items) && ( - - )} + "items" in propertySchema && + (() => { + const attributesSchema = getRenderableAttributesSchema( + propertySchema.items, + ); + + return ( + attributesSchema && ( + + ) + ); + })()} {isNonArraySchemaObject(propertySchema) && propertySchema.example && (
    From 76c9bf6485c9af244f02b814e309665d2df4f5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matou=C5=A1=20Dzivjak?= Date: Wed, 25 Feb 2026 12:21:45 +0100 Subject: [PATCH 3/3] fix: missing descripton --- src/components/ApiDocs/Schema.astro | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/ApiDocs/Schema.astro b/src/components/ApiDocs/Schema.astro index 6f4dc3e5..a0e9a15c 100644 --- a/src/components/ApiDocs/Schema.astro +++ b/src/components/ApiDocs/Schema.astro @@ -116,11 +116,19 @@ const schema = resolveSchema(obj); {propertySchema.description && ( {propertySchema.description} )} + {propertySchema.type === "array" && + !propertySchema.description && + "items" in propertySchema && + resolveSchema(propertySchema.items).description && ( + + {resolveSchema(propertySchema.items).description} + + )} {propertySchema.type === "object" && getRenderableAttributesSchema(propertySchema) && ( - )} {propertySchema.type === "array" &&