Skip to content

Commit fa8827e

Browse files
committed
Ensure same-level properties and allOf are rendered (#904)
* 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
1 parent 9964299 commit fa8827e

File tree

6 files changed

+798
-84
lines changed

6 files changed

+798
-84
lines changed

demo/docusaurus.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ const config = {
7474
label: "Petstore (versioned)",
7575
to: "/category/petstore-versioned-api",
7676
},
77+
{
78+
label: "Tests",
79+
to: "/category/tests",
80+
},
7781
],
7882
},
7983
{
@@ -265,6 +269,16 @@ const config = {
265269
},
266270
showSchemas: true,
267271
},
272+
tests: {
273+
specPath: "examples/tests",
274+
outputDir: "docs/tests",
275+
sidebarOptions: {
276+
groupPathsBy: "tag",
277+
categoryLinkSource: "info",
278+
},
279+
hideSendButton: true,
280+
showSchemas: true,
281+
},
268282
},
269283
},
270284
],

demo/examples/tests/allOf.yaml

Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
openapi: 3.0.1
2+
info:
3+
title: AllOf Variations API
4+
description: Demonstrates various allOf schema combinations.
5+
version: 1.0.0
6+
tags:
7+
- name: allOf
8+
description: allOf tests
9+
paths:
10+
/multiple-allof-nested:
11+
get:
12+
tags:
13+
- allOf
14+
summary: Multiple allOf with Nested Properties
15+
description: |
16+
Schema:
17+
```yaml
18+
allOf:
19+
- type: object
20+
properties:
21+
outerProp1:
22+
type: object
23+
properties:
24+
innerProp1:
25+
type: string
26+
- type: object
27+
properties:
28+
outerProp2:
29+
type: object
30+
properties:
31+
innerProp2:
32+
type: number
33+
```
34+
responses:
35+
"200":
36+
description: Successful response
37+
content:
38+
application/json:
39+
schema:
40+
allOf:
41+
- type: object
42+
properties:
43+
outerProp1:
44+
type: object
45+
properties:
46+
innerProp1:
47+
type: string
48+
- type: object
49+
properties:
50+
outerProp2:
51+
type: object
52+
properties:
53+
innerProp2:
54+
type: number
55+
56+
/allof-shared-required:
57+
get:
58+
tags:
59+
- allOf
60+
summary: allOf with Shared Required Properties
61+
description: |
62+
Schema:
63+
```yaml
64+
allOf:
65+
- type: object
66+
properties:
67+
sharedProp:
68+
type: string
69+
required: [sharedProp]
70+
- type: object
71+
properties:
72+
anotherProp:
73+
type: number
74+
required: [anotherProp]
75+
```
76+
responses:
77+
"200":
78+
description: Successful response
79+
content:
80+
application/json:
81+
schema:
82+
allOf:
83+
- type: object
84+
properties:
85+
sharedProp:
86+
type: string
87+
required: [sharedProp]
88+
- type: object
89+
properties:
90+
anotherProp:
91+
type: number
92+
required: [anotherProp]
93+
94+
# /allof-conflicting-properties:
95+
# get:
96+
# tags:
97+
# - allOf
98+
# summary: allOf with Conflicting Properties
99+
# description: |
100+
# Schema:
101+
# ```yaml
102+
# allOf:
103+
# - type: object
104+
# properties:
105+
# conflictingProp:
106+
# type: string
107+
# - type: object
108+
# properties:
109+
# conflictingProp:
110+
# type: number
111+
# ```
112+
# responses:
113+
# '200':
114+
# description: Successful response
115+
# content:
116+
# application/json:
117+
# schema:
118+
# allOf:
119+
# - type: object
120+
# properties:
121+
# conflictingProp:
122+
# type: string
123+
# - type: object
124+
# properties:
125+
# conflictingProp:
126+
# type: number
127+
128+
# /allof-mixed-data-types:
129+
# get:
130+
# tags:
131+
# - allOf
132+
# summary: allOf with Mixed Data Types
133+
# description: |
134+
# Schema:
135+
# ```yaml
136+
# allOf:
137+
# - type: object
138+
# properties:
139+
# mixedTypeProp1:
140+
# type: string
141+
# - type: array
142+
# items:
143+
# type: number
144+
# ```
145+
# responses:
146+
# '200':
147+
# description: Successful response
148+
# content:
149+
# application/json:
150+
# schema:
151+
# allOf:
152+
# - type: object
153+
# properties:
154+
# mixedTypeProp1:
155+
# type: string
156+
# - type: array
157+
# items:
158+
# type: number
159+
160+
/allof-deep-merging:
161+
get:
162+
tags:
163+
- allOf
164+
summary: allOf with Deep Merging
165+
description: |
166+
Schema:
167+
```yaml
168+
allOf:
169+
- type: object
170+
properties:
171+
deepProp:
172+
type: object
173+
properties:
174+
innerProp1:
175+
type: string
176+
- type: object
177+
properties:
178+
deepProp:
179+
type: object
180+
properties:
181+
innerProp2:
182+
type: number
183+
```
184+
responses:
185+
"200":
186+
description: Successful response
187+
content:
188+
application/json:
189+
schema:
190+
allOf:
191+
- type: object
192+
properties:
193+
deepProp:
194+
type: object
195+
properties:
196+
innerProp1:
197+
type: string
198+
- type: object
199+
properties:
200+
deepProp:
201+
type: object
202+
properties:
203+
innerProp2:
204+
type: number
205+
206+
# /allof-discriminator:
207+
# get:
208+
# tags:
209+
# - allOf
210+
# summary: allOf with Discriminator
211+
# description: |
212+
# Schema:
213+
# ```yaml
214+
# allOf:
215+
# - type: object
216+
# discriminator:
217+
# propertyName: type
218+
# properties:
219+
# type:
220+
# type: string
221+
# - type: object
222+
# properties:
223+
# specificProp:
224+
# type: string
225+
# ```
226+
# responses:
227+
# "200":
228+
# description: Successful response
229+
# content:
230+
# application/json:
231+
# schema:
232+
# allOf:
233+
# - type: object
234+
# discriminator:
235+
# propertyName: type
236+
# properties:
237+
# type:
238+
# type: string
239+
# - type: object
240+
# properties:
241+
# specificProp:
242+
# type: string
243+
244+
/allof-same-level-properties:
245+
get:
246+
tags:
247+
- allOf
248+
summary: allOf with Same-Level Properties
249+
description: |
250+
Schema:
251+
```yaml
252+
allOf:
253+
- type: object
254+
properties:
255+
allOfProp1:
256+
type: string
257+
allOfProp2:
258+
type: string
259+
properties:
260+
parentProp1:
261+
type: string
262+
parentProp2:
263+
type: string
264+
```
265+
responses:
266+
"200":
267+
description: Successful response
268+
content:
269+
application/json:
270+
schema:
271+
allOf:
272+
- type: object
273+
properties:
274+
allOfProp1:
275+
type: string
276+
allOfProp2:
277+
type: string
278+
properties:
279+
parentProp1:
280+
type: string
281+
parentProp2:
282+
type: string

demo/sidebars.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ const sidebars = {
162162
items: require("./docs/petstore_versioned/1.0.0/sidebar.js"),
163163
},
164164
],
165+
166+
tests: [
167+
{
168+
type: "category",
169+
label: "Tests",
170+
link: {
171+
type: "generated-index",
172+
title: "Tests",
173+
description: "Various OpenAPI test cases",
174+
slug: "/category/tests",
175+
},
176+
items: require("./docs/tests/sidebar.js"),
177+
},
178+
],
165179
};
166180

167181
module.exports = sidebars;

0 commit comments

Comments
 (0)