Skip to content

Commit

Permalink
Ensure same-level properties and allOf are rendered (#904)
Browse files Browse the repository at this point in the history
* process properties before allOf to ensure rendering

* update tests

* remove delete schema lines added for testing

* add additional allOf test cases

* add tests to documentation

* hide allOf discriminator example

* fix linter issues

* define global tags
  • Loading branch information
sserrata committed Aug 6, 2024
1 parent 9964299 commit fa8827e
Show file tree
Hide file tree
Showing 6 changed files with 798 additions and 84 deletions.
14 changes: 14 additions & 0 deletions demo/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ const config = {
label: "Petstore (versioned)",
to: "/category/petstore-versioned-api",
},
{
label: "Tests",
to: "/category/tests",
},
],
},
{
Expand Down Expand Up @@ -265,6 +269,16 @@ const config = {
},
showSchemas: true,
},
tests: {
specPath: "examples/tests",
outputDir: "docs/tests",
sidebarOptions: {
groupPathsBy: "tag",
categoryLinkSource: "info",
},
hideSendButton: true,
showSchemas: true,
},
},
},
],
Expand Down
282 changes: 282 additions & 0 deletions demo/examples/tests/allOf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
openapi: 3.0.1
info:
title: AllOf Variations API
description: Demonstrates various allOf schema combinations.
version: 1.0.0
tags:
- name: allOf
description: allOf tests
paths:
/multiple-allof-nested:
get:
tags:
- allOf
summary: Multiple allOf with Nested Properties
description: |
Schema:
```yaml
allOf:
- type: object
properties:
outerProp1:
type: object
properties:
innerProp1:
type: string
- type: object
properties:
outerProp2:
type: object
properties:
innerProp2:
type: number
```
responses:
"200":
description: Successful response
content:
application/json:
schema:
allOf:
- type: object
properties:
outerProp1:
type: object
properties:
innerProp1:
type: string
- type: object
properties:
outerProp2:
type: object
properties:
innerProp2:
type: number

/allof-shared-required:
get:
tags:
- allOf
summary: allOf with Shared Required Properties
description: |
Schema:
```yaml
allOf:
- type: object
properties:
sharedProp:
type: string
required: [sharedProp]
- type: object
properties:
anotherProp:
type: number
required: [anotherProp]
```
responses:
"200":
description: Successful response
content:
application/json:
schema:
allOf:
- type: object
properties:
sharedProp:
type: string
required: [sharedProp]
- type: object
properties:
anotherProp:
type: number
required: [anotherProp]

# /allof-conflicting-properties:
# get:
# tags:
# - allOf
# summary: allOf with Conflicting Properties
# description: |
# Schema:
# ```yaml
# allOf:
# - type: object
# properties:
# conflictingProp:
# type: string
# - type: object
# properties:
# conflictingProp:
# type: number
# ```
# responses:
# '200':
# description: Successful response
# content:
# application/json:
# schema:
# allOf:
# - type: object
# properties:
# conflictingProp:
# type: string
# - type: object
# properties:
# conflictingProp:
# type: number

# /allof-mixed-data-types:
# get:
# tags:
# - allOf
# summary: allOf with Mixed Data Types
# description: |
# Schema:
# ```yaml
# allOf:
# - type: object
# properties:
# mixedTypeProp1:
# type: string
# - type: array
# items:
# type: number
# ```
# responses:
# '200':
# description: Successful response
# content:
# application/json:
# schema:
# allOf:
# - type: object
# properties:
# mixedTypeProp1:
# type: string
# - type: array
# items:
# type: number

/allof-deep-merging:
get:
tags:
- allOf
summary: allOf with Deep Merging
description: |
Schema:
```yaml
allOf:
- type: object
properties:
deepProp:
type: object
properties:
innerProp1:
type: string
- type: object
properties:
deepProp:
type: object
properties:
innerProp2:
type: number
```
responses:
"200":
description: Successful response
content:
application/json:
schema:
allOf:
- type: object
properties:
deepProp:
type: object
properties:
innerProp1:
type: string
- type: object
properties:
deepProp:
type: object
properties:
innerProp2:
type: number

# /allof-discriminator:
# get:
# tags:
# - allOf
# summary: allOf with Discriminator
# description: |
# Schema:
# ```yaml
# allOf:
# - type: object
# discriminator:
# propertyName: type
# properties:
# type:
# type: string
# - type: object
# properties:
# specificProp:
# type: string
# ```
# responses:
# "200":
# description: Successful response
# content:
# application/json:
# schema:
# allOf:
# - type: object
# discriminator:
# propertyName: type
# properties:
# type:
# type: string
# - type: object
# properties:
# specificProp:
# type: string

/allof-same-level-properties:
get:
tags:
- allOf
summary: allOf with Same-Level Properties
description: |
Schema:
```yaml
allOf:
- type: object
properties:
allOfProp1:
type: string
allOfProp2:
type: string
properties:
parentProp1:
type: string
parentProp2:
type: string
```
responses:
"200":
description: Successful response
content:
application/json:
schema:
allOf:
- type: object
properties:
allOfProp1:
type: string
allOfProp2:
type: string
properties:
parentProp1:
type: string
parentProp2:
type: string
14 changes: 14 additions & 0 deletions demo/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,20 @@ const sidebars = {
items: require("./docs/petstore_versioned/1.0.0/sidebar.js"),
},
],

tests: [
{
type: "category",
label: "Tests",
link: {
type: "generated-index",
title: "Tests",
description: "Various OpenAPI test cases",
slug: "/category/tests",
},
items: require("./docs/tests/sidebar.js"),
},
],
};

module.exports = sidebars;
Loading

0 comments on commit fa8827e

Please sign in to comment.