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: 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 }) => {