Skip to content

Commit 893b432

Browse files
authored
Merge pull request #979 from PaloAltoNetworks/params-details
Implement React components to reduce emitted MDX output from plugin
2 parents 3d1cc0d + ef8b1d9 commit 893b432

File tree

35 files changed

+3289
-2031
lines changed

35 files changed

+3289
-2031
lines changed

demo/customMdGenerators.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,13 @@ export function myCustomApiMdGenerator({
4343
frontMatter,
4444
}: ApiPageMetadata) {
4545
return render([
46-
`import ApiTabs from "@theme/ApiTabs";\n`,
47-
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
4846
`import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";\n`,
49-
`import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";\n`,
50-
`import MimeTabs from "@theme/MimeTabs";\n`,
51-
`import ParamsItem from "@theme/ParamsItem";\n`,
52-
`import ResponseSamples from "@theme/ResponseSamples";\n`,
53-
`import SchemaItem from "@theme/SchemaItem";\n`,
54-
`import SchemaTabs from "@theme/SchemaTabs";\n`,
55-
`import Heading from "@theme/Heading";\n`,
47+
`import ParamsDetails from "@theme/ParamsDetails";\n`,
48+
`import RequestSchema from "@theme/RequestSchema";\n`,
49+
`import StatusCodes from "@theme/StatusCodes";\n`,
5650
`import OperationTabs from "@theme/OperationTabs";\n`,
57-
`import TabItem from "@theme/TabItem";\n\n`,
51+
`import TabItem from "@theme/TabItem";\n`,
52+
`import Heading from "@theme/Heading";\n\n`,
5853
createHeading(title),
5954
createMethodEndpoint(method, path),
6055
createServersTable(servers),
@@ -65,10 +60,7 @@ export function myCustomApiMdGenerator({
6560
createDeprecationNotice({ deprecated, description: deprecatedDescription }),
6661
createDescription(description),
6762
requestBody || parameters ? createRequestHeader("Request") : undefined,
68-
createParamsDetails({ parameters, type: "path" }),
69-
createParamsDetails({ parameters, type: "query" }),
70-
createParamsDetails({ parameters, type: "header" }),
71-
createParamsDetails({ parameters, type: "cookie" }),
63+
createParamsDetails({ parameters }),
7264
createRequestBodyDetails({
7365
title: "Body",
7466
body: requestBody,

demo/examples/tests/allOf.yaml

Lines changed: 172 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
openapi: 3.0.1
1+
openapi: 3.1.0
22
info:
33
title: AllOf Variations API
44
description: Demonstrates various allOf schema combinations.
@@ -91,72 +91,6 @@ paths:
9191
type: number
9292
required: [anotherProp]
9393

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-
16094
/allof-deep-merging:
16195
get:
16296
tags:
@@ -203,44 +137,6 @@ paths:
203137
innerProp2:
204138
type: number
205139

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-
244140
/allof-same-level-properties:
245141
get:
246142
tags:
@@ -280,3 +176,174 @@ paths:
280176
type: string
281177
parentProp2:
282178
type: string
179+
180+
/allof-array-items:
181+
get:
182+
tags:
183+
- allOf
184+
summary: allOf with Array Items
185+
description: |
186+
A list of books demonstrating allOf with items as children.
187+
188+
Schema:
189+
```yaml
190+
type: array
191+
items:
192+
$ref: '#/components/schemas/Book'
193+
```
194+
195+
Schema Components:
196+
```yaml
197+
BookBase:
198+
type: object
199+
required:
200+
- id
201+
- title
202+
- author
203+
properties:
204+
id:
205+
type: integer
206+
format: int64
207+
description: Unique identifier for the book
208+
title:
209+
type: string
210+
description: The title of the book
211+
author:
212+
type: string
213+
description: The author of the book
214+
215+
AdditionalBookInfo:
216+
type: object
217+
properties:
218+
publishedDate:
219+
type: string
220+
format: date
221+
description: The date the book was published
222+
genre:
223+
type: string
224+
description: The genre of the book
225+
tags:
226+
type: array
227+
items:
228+
type: string
229+
description: Tags associated with the book
230+
231+
Book:
232+
allOf:
233+
- $ref: '#/components/schemas/BookBase'
234+
- $ref: '#/components/schemas/AdditionalBookInfo'
235+
```
236+
responses:
237+
"200":
238+
description: A list of books
239+
content:
240+
application/json:
241+
schema:
242+
type: array
243+
items:
244+
$ref: "#/components/schemas/Book"
245+
246+
/allof-nested:
247+
get:
248+
tags:
249+
- allOf
250+
summary: allOf with Nested allOf
251+
description: |
252+
An example demonstrating nested allOf within allOf.
253+
254+
Schema:
255+
```yaml
256+
allOf:
257+
- type: object
258+
properties:
259+
outerProp:
260+
type: object
261+
allOf:
262+
- type: object
263+
properties:
264+
innerProp1:
265+
type: string
266+
- type: object
267+
properties:
268+
innerProp2:
269+
type: number
270+
- type: object
271+
properties:
272+
otherOuterProp:
273+
type: string
274+
```
275+
responses:
276+
"200":
277+
description: Successful response
278+
content:
279+
application/json:
280+
schema:
281+
allOf:
282+
- type: object
283+
properties:
284+
outerProp:
285+
type: object
286+
allOf:
287+
- type: object
288+
properties:
289+
innerProp1:
290+
type: string
291+
- type: object
292+
properties:
293+
innerProp2:
294+
type: number
295+
- type: object
296+
properties:
297+
otherOuterProp:
298+
type: string
299+
300+
components:
301+
schemas:
302+
# Your existing schemas are integrated here.
303+
ExistingSchema1:
304+
type: object
305+
properties: ...
306+
307+
ExistingSchema2:
308+
type: object
309+
properties: ...
310+
311+
# New schemas for Books demonstration
312+
BookBase:
313+
type: object
314+
required:
315+
- id
316+
- title
317+
- author
318+
properties:
319+
id:
320+
type: integer
321+
format: int64
322+
description: Unique identifier for the book
323+
title:
324+
type: string
325+
description: The title of the book
326+
author:
327+
type: string
328+
description: The author of the book
329+
330+
AdditionalBookInfo:
331+
type: object
332+
properties:
333+
publishedDate:
334+
type: string
335+
format: date
336+
description: The date the book was published
337+
genre:
338+
type: string
339+
description: The genre of the book
340+
tags:
341+
type: array
342+
items:
343+
type: string
344+
description: Tags associated with the book
345+
346+
Book:
347+
allOf:
348+
- $ref: "#/components/schemas/BookBase"
349+
- $ref: "#/components/schemas/AdditionalBookInfo"

packages/docusaurus-plugin-openapi-docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
"@docusaurus/utils": "^3.5.0",
4343
"@docusaurus/utils-validation": "^3.5.0",
4444
"@redocly/openapi-core": "^1.10.5",
45+
"allof-merge": "^0.6.6",
4546
"chalk": "^4.1.2",
4647
"clsx": "^1.1.1",
4748
"fs-extra": "^9.0.1",
4849
"json-pointer": "^0.6.2",
49-
"json-schema-merge-allof": "^0.8.1",
5050
"json5": "^2.2.3",
5151
"lodash": "^4.17.20",
5252
"mustache": "^4.2.0",

0 commit comments

Comments
 (0)