From 850b5d0891b3f7c7ca96fbcd6a5158632be4df05 Mon Sep 17 00:00:00 2001 From: Steven Serrata <9343811+sserrata@users.noreply.github.com> Date: Thu, 21 Mar 2024 13:53:24 -0400 Subject: [PATCH] Fix allOf schema qualifier and type (#766) * ensure merged schema is used to generate schema name and qualifier * combine schema title and type when both are present * cleanup formatting --- .../src/markdown/createSchema.ts | 5 ++--- .../docusaurus-plugin-openapi-docs/src/markdown/schema.ts | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts index 6cd888885..15767905f 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts @@ -624,7 +624,6 @@ function createEdges({ }: { mergedSchemas: SchemaObject; required: string[] | boolean } = mergeAllOf(schema.allOf); const mergedSchemaName = getSchemaName(mergedSchemas); - if ( mergedSchemas.oneOf !== undefined || mergedSchemas.anyOf !== undefined @@ -685,8 +684,8 @@ function createEdges({ collapsible: false, name, required: Array.isArray(required) ? required.includes(name) : required, - schemaName: schemaName, - qualifierMessage: getQualifierMessage(schema), + schemaName: mergedSchemaName, + qualifierMessage: getQualifierMessage(mergedSchemas), schema: mergedSchemas, }); } diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.ts index be09c11cd..5ac9c92b9 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.ts +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.ts @@ -40,6 +40,10 @@ function prettyName(schema: SchemaObject, circular?: boolean) { // return schema.type; } + if (schema.title && schema.type) { + return `${schema.title} (${schema.type})`; + } + return schema.title ?? schema.type; }