diff --git a/src/components/ApiDocs/Schema.astro b/src/components/ApiDocs/Schema.astro
index cffbb092..a0e9a15c 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 getRenderableAttributesSchema = (
+ object: OpenAPIV3_1.SchemaObject | OpenAPIV3_1.ReferenceObject | undefined,
+): OpenAPIV3_1.SchemaObject | null => {
+ if (!object) return null;
+
+ const schema = resolveSchema(object);
+ const hasProperties = Object.keys(schema.properties || {}).length > 0;
+
+ if (hasProperties) return schema;
+
+ if (schema.type === "array" && "items" in schema) {
+ return getRenderableAttributesSchema(schema.items);
+ }
+
+ return null;
+};
+
export interface Props {
kind: string;
schema: OpenAPIV3_1.SchemaObject;
@@ -55,12 +72,20 @@ const schema = resolveSchema(obj);
}
{!nested && !collapsable &&
{schema.title || kind}
}
{
- schema.type === "array" && "items" in schema && (
-
- )
+ schema.type === "array" &&
+ "items" in schema &&
+ (() => {
+ const attributesSchema = getRenderableAttributesSchema(schema.items);
+
+ return (
+
+
+ {attributesSchema && (
+
+ )}
+
+ );
+ })()
}
{
@@ -91,18 +116,37 @@ const schema = resolveSchema(obj);
{propertySchema.description && (
{propertySchema.description}
)}
- {"type" in propertySchema && propertySchema.type === "object" && (
+ {propertySchema.type === "array" &&
+ !propertySchema.description &&
+ "items" in propertySchema &&
+ resolveSchema(propertySchema.items).description && (
+
+ {resolveSchema(propertySchema.items).description}
+
+ )}
+ {propertySchema.type === "object" &&
+ getRenderableAttributesSchema(propertySchema) && (
- )}
- {"type" in def && propertySchema.type === "array" && (
-
- )}
+ />
+ )}
+ {propertySchema.type === "array" &&
+ "items" in propertySchema &&
+ (() => {
+ const attributesSchema = getRenderableAttributesSchema(
+ propertySchema.items,
+ );
+
+ return (
+ attributesSchema && (
+
+ )
+ );
+ })()}
{isNonArraySchemaObject(propertySchema) &&
propertySchema.example && (