Skip to content

Commit

Permalink
Support anyOf/oneOf schema descriptions (#897)
Browse files Browse the repository at this point in the history
* add support for anyOf/oneOf schema descriptions

* add schema descriptions to Tag and Pet

* update test snapshot

* add schema summary class

* update test snapshot
  • Loading branch information
sserrata authored Jul 23, 2024
1 parent ecc7f33 commit a051895
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions demo/examples/petstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ components:
name: Order
Pet:
type: object
description: A pet
required:
- name
- photoUrls
Expand Down Expand Up @@ -1122,6 +1123,7 @@ components:
name: Pet
Tag:
type: object
description: A pet tag
properties:
id:
description: Tag ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ Array [
</span>
<SchemaTabs>
<TabItem label={\\"MOD1\\"} value={\\"0-item-properties\\"}>
<div
style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}
className={\\"openapi-schema__summary\\"}
>
Clown's nose length
</div>
<SchemaItem
collapsible={false}
name={\\"noseLength\\"}
Expand All @@ -250,6 +256,12 @@ Array [
></SchemaItem>
</TabItem>
<TabItem label={\\"MOD2\\"} value={\\"1-item-properties\\"}>
<div
style={{ marginTop: \\".5rem\\", marginBottom: \\".5rem\\" }}
className={\\"openapi-schema__summary\\"}
>
Array of strings
</div>
<li>
<div
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ function createAnyOneOf(schema: SchemaObject): any {
: `MOD${index + 1}`;
const anyOneChildren = [];

if (anyOneSchema.description) {
anyOneChildren.push(
create("div", {
style: { marginTop: ".5rem", marginBottom: ".5rem" },
className: "openapi-schema__summary",
children: createDescription(anyOneSchema.description),
})
);
}

if (
anyOneSchema.type === "object" &&
!anyOneSchema.properties &&
Expand Down

0 comments on commit a051895

Please sign in to comment.