Skip to content

Support anyOf/oneOf schema descriptions #897

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading