From 4dfaf8a5d968e8cff70bb4597710d61e7fe1a61d Mon Sep 17 00:00:00 2001 From: Josh Wulf Date: Fri, 19 Dec 2025 13:40:26 -0600 Subject: [PATCH 1/2] feat: display format for oneOf primitive arms Uses getSchemaName() to properly display format information (e.g., 'string') for primitive arms in oneOf/anyOf schemas, instead of just showing the raw type ('string'). Closes #1230 Co-authored-by: Josh Wulf --- .../src/theme/Schema/index.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx index be9f9a289..a73d37aec 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx @@ -145,9 +145,13 @@ const AnyOneOf: React.FC = ({ schema, schemaType }) => { {schema[key]?.map((anyOneSchema: any, index: number) => { + // Use getSchemaName to include format info (e.g., "string") + const computedSchemaName = getSchemaName(anyOneSchema); + // Determine label for the tab - // If schema is just oneOf/anyOf without title/type, use a generic label - let label = anyOneSchema.title || anyOneSchema.type; + // Prefer explicit title, then computed schema name, then raw type + let label = + anyOneSchema.title || computedSchemaName || anyOneSchema.type; if (!label) { if (anyOneSchema.oneOf) { label = translate({ @@ -175,7 +179,7 @@ const AnyOneOf: React.FC = ({ schema, schemaType }) => { = ({ schema, schemaType }) => { Date: Fri, 19 Dec 2025 13:46:39 -0600 Subject: [PATCH 2/2] test: add oneOf primitive format types example Adds test case for oneOf schemas with primitive types that have format specifiers (e.g., string with date-time, email, integer with int64). This verifies the fix displays 'string' instead of just 'string'. --- demo/examples/tests/oneOf.yaml | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/demo/examples/tests/oneOf.yaml b/demo/examples/tests/oneOf.yaml index 2044f1719..8d7f84d77 100644 --- a/demo/examples/tests/oneOf.yaml +++ b/demo/examples/tests/oneOf.yaml @@ -39,6 +39,46 @@ paths: - type: boolean - type: "null" + /oneof-primitive-formats: + get: + tags: + - oneOf + summary: oneOf with Primitive Format Types + description: | + Primitive types with format should display as `type` (e.g., `string`). + + Schema: + ```yaml + type: object + properties: + oneOfProperty: + oneOf: + - type: string + format: date-time + - type: string + format: email + - type: integer + format: int64 + - type: string + ``` + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + oneOfProperty: + oneOf: + - type: string + format: date-time + - type: string + format: email + - type: integer + format: int64 + - type: string + /oneof-complex-types: get: tags: