From c1075c85ad1c445f081f8d6a2c3388c8b4990d3d Mon Sep 17 00:00:00 2001 From: Steven Serrata <9343811+sserrata@users.noreply.github.com> Date: Tue, 1 Jul 2025 17:11:31 -0500 Subject: [PATCH 1/4] Add allOf required spec and fix items branch --- demo/examples/tests/allOfRequired.yaml | 53 +++++++++++++++++++ .../src/theme/Schema/index.tsx | 32 +++++------ 2 files changed, 67 insertions(+), 18 deletions(-) create mode 100644 demo/examples/tests/allOfRequired.yaml diff --git a/demo/examples/tests/allOfRequired.yaml b/demo/examples/tests/allOfRequired.yaml new file mode 100644 index 000000000..1e34bbae8 --- /dev/null +++ b/demo/examples/tests/allOfRequired.yaml @@ -0,0 +1,53 @@ +openapi: 3.1.0 +info: + title: allOf Required Inheritance API + description: Demonstrates property required flag inherited from parent when using allOf. + version: 1.0.0 +tags: + - name: allOfRequired + description: allOf required tests +paths: + /allof-parent-required: + get: + tags: + - allOfRequired + summary: allOf inherits parent required + description: | + Parent object marks the "pet" property as required while its schema is composed via allOf. + + Schema: + ```yaml + type: object + properties: + pet: + allOf: + - type: object + properties: + name: + type: string + - type: object + properties: + age: + type: integer + required: [pet] + ``` + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + pet: + allOf: + - type: object + properties: + name: + type: string + - type: object + properties: + age: + type: integer + required: + - pet 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 cc7bc3863..8f277100e 100644 --- a/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx +++ b/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx @@ -725,9 +725,7 @@ const SchemaEdge: React.FC = ({ name={name} schemaName={mergedSchemaName} required={ - Array.isArray(mergedSchemas.required) - ? mergedSchemas.required.includes(name) - : mergedSchemas.required + Array.isArray(required) ? required.includes(name) : required } nullable={mergedSchemas.nullable} schema={mergedSchemas} @@ -742,9 +740,7 @@ const SchemaEdge: React.FC = ({ name={name} schemaName={mergedSchemaName} required={ - Array.isArray(mergedSchemas.required) - ? mergedSchemas.required.includes(name) - : mergedSchemas.required + Array.isArray(required) ? required.includes(name) : required } nullable={mergedSchemas.nullable} schema={mergedSchemas} @@ -754,18 +750,18 @@ const SchemaEdge: React.FC = ({ } if (mergedSchemas.items?.properties) { - ; + return ( + + ); } return ( From 76f17b18e7c7518e204571f04041d5b994c8086e Mon Sep 17 00:00:00 2001 From: Steven Serrata <9343811+sserrata@users.noreply.github.com> Date: Tue, 1 Jul 2025 17:37:43 -0500 Subject: [PATCH 2/4] Place allOfRequired example in allOf category --- demo/examples/tests/allOfRequired.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/examples/tests/allOfRequired.yaml b/demo/examples/tests/allOfRequired.yaml index 1e34bbae8..dcf2d81e9 100644 --- a/demo/examples/tests/allOfRequired.yaml +++ b/demo/examples/tests/allOfRequired.yaml @@ -4,13 +4,13 @@ info: description: Demonstrates property required flag inherited from parent when using allOf. version: 1.0.0 tags: - - name: allOfRequired + - name: allOf description: allOf required tests paths: /allof-parent-required: get: tags: - - allOfRequired + - allOf summary: allOf inherits parent required description: | Parent object marks the "pet" property as required while its schema is composed via allOf. From 7f4f560f7527d506e97ea7757a53ab0bb5d67874 Mon Sep 17 00:00:00 2001 From: Steven Serrata Date: Tue, 1 Jul 2025 18:44:24 -0500 Subject: [PATCH 3/4] move test to allOf --- demo/examples/tests/allOf.yaml | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/demo/examples/tests/allOf.yaml b/demo/examples/tests/allOf.yaml index 9b58d21d7..309a95905 100644 --- a/demo/examples/tests/allOf.yaml +++ b/demo/examples/tests/allOf.yaml @@ -367,6 +367,51 @@ paths: otherOuterProp: type: string + /allof-parent-required: + get: + tags: + - allOf + summary: allOf inherits parent required + description: | + Parent object marks the "pet" property as required while its schema is composed via allOf. + + Schema: + ```yaml + type: object + properties: + pet: + allOf: + - type: object + properties: + name: + type: string + - type: object + properties: + age: + type: integer + required: [pet] + ``` + responses: + "200": + description: Successful response + content: + application/json: + schema: + type: object + properties: + pet: + allOf: + - type: object + properties: + name: + type: string + - type: object + properties: + age: + type: integer + required: + - pet + components: schemas: # Your existing schemas are integrated here. From 2e9391c73f4c77e3ac1d412b55448afd349ad0b9 Mon Sep 17 00:00:00 2001 From: Steven Serrata <9343811+sserrata@users.noreply.github.com> Date: Tue, 1 Jul 2025 18:55:58 -0500 Subject: [PATCH 4/4] Remove duplicate allOfRequired spec --- demo/examples/tests/allOfRequired.yaml | 53 -------------------------- 1 file changed, 53 deletions(-) delete mode 100644 demo/examples/tests/allOfRequired.yaml diff --git a/demo/examples/tests/allOfRequired.yaml b/demo/examples/tests/allOfRequired.yaml deleted file mode 100644 index dcf2d81e9..000000000 --- a/demo/examples/tests/allOfRequired.yaml +++ /dev/null @@ -1,53 +0,0 @@ -openapi: 3.1.0 -info: - title: allOf Required Inheritance API - description: Demonstrates property required flag inherited from parent when using allOf. - version: 1.0.0 -tags: - - name: allOf - description: allOf required tests -paths: - /allof-parent-required: - get: - tags: - - allOf - summary: allOf inherits parent required - description: | - Parent object marks the "pet" property as required while its schema is composed via allOf. - - Schema: - ```yaml - type: object - properties: - pet: - allOf: - - type: object - properties: - name: - type: string - - type: object - properties: - age: - type: integer - required: [pet] - ``` - responses: - "200": - description: Successful response - content: - application/json: - schema: - type: object - properties: - pet: - allOf: - - type: object - properties: - name: - type: string - - type: object - properties: - age: - type: integer - required: - - pet