Skip to content

Commit

Permalink
Merge pull request #979 from PaloAltoNetworks/params-details
Browse files Browse the repository at this point in the history
Implement React components to reduce emitted MDX output from plugin
  • Loading branch information
sserrata authored Oct 16, 2024
2 parents 3d1cc0d + ef8b1d9 commit 893b432
Show file tree
Hide file tree
Showing 35 changed files with 3,289 additions and 2,031 deletions.
20 changes: 6 additions & 14 deletions demo/customMdGenerators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,13 @@ export function myCustomApiMdGenerator({
frontMatter,
}: ApiPageMetadata) {
return render([
`import ApiTabs from "@theme/ApiTabs";\n`,
`import DiscriminatorTabs from "@theme/DiscriminatorTabs";\n`,
`import MethodEndpoint from "@theme/ApiExplorer/MethodEndpoint";\n`,
`import SecuritySchemes from "@theme/ApiExplorer/SecuritySchemes";\n`,
`import MimeTabs from "@theme/MimeTabs";\n`,
`import ParamsItem from "@theme/ParamsItem";\n`,
`import ResponseSamples from "@theme/ResponseSamples";\n`,
`import SchemaItem from "@theme/SchemaItem";\n`,
`import SchemaTabs from "@theme/SchemaTabs";\n`,
`import Heading from "@theme/Heading";\n`,
`import ParamsDetails from "@theme/ParamsDetails";\n`,
`import RequestSchema from "@theme/RequestSchema";\n`,
`import StatusCodes from "@theme/StatusCodes";\n`,
`import OperationTabs from "@theme/OperationTabs";\n`,
`import TabItem from "@theme/TabItem";\n\n`,
`import TabItem from "@theme/TabItem";\n`,
`import Heading from "@theme/Heading";\n\n`,
createHeading(title),
createMethodEndpoint(method, path),
createServersTable(servers),
Expand All @@ -65,10 +60,7 @@ export function myCustomApiMdGenerator({
createDeprecationNotice({ deprecated, description: deprecatedDescription }),
createDescription(description),
requestBody || parameters ? createRequestHeader("Request") : undefined,
createParamsDetails({ parameters, type: "path" }),
createParamsDetails({ parameters, type: "query" }),
createParamsDetails({ parameters, type: "header" }),
createParamsDetails({ parameters, type: "cookie" }),
createParamsDetails({ parameters }),
createRequestBodyDetails({
title: "Body",
body: requestBody,
Expand Down
277 changes: 172 additions & 105 deletions demo/examples/tests/allOf.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
openapi: 3.0.1
openapi: 3.1.0
info:
title: AllOf Variations API
description: Demonstrates various allOf schema combinations.
Expand Down Expand Up @@ -91,72 +91,6 @@ paths:
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:
Expand Down Expand Up @@ -203,44 +137,6 @@ paths:
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:
Expand Down Expand Up @@ -280,3 +176,174 @@ paths:
type: string
parentProp2:
type: string

/allof-array-items:
get:
tags:
- allOf
summary: allOf with Array Items
description: |
A list of books demonstrating allOf with items as children.
Schema:
```yaml
type: array
items:
$ref: '#/components/schemas/Book'
```
Schema Components:
```yaml
BookBase:
type: object
required:
- id
- title
- author
properties:
id:
type: integer
format: int64
description: Unique identifier for the book
title:
type: string
description: The title of the book
author:
type: string
description: The author of the book
AdditionalBookInfo:
type: object
properties:
publishedDate:
type: string
format: date
description: The date the book was published
genre:
type: string
description: The genre of the book
tags:
type: array
items:
type: string
description: Tags associated with the book
Book:
allOf:
- $ref: '#/components/schemas/BookBase'
- $ref: '#/components/schemas/AdditionalBookInfo'
```
responses:
"200":
description: A list of books
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Book"

/allof-nested:
get:
tags:
- allOf
summary: allOf with Nested allOf
description: |
An example demonstrating nested allOf within allOf.
Schema:
```yaml
allOf:
- type: object
properties:
outerProp:
type: object
allOf:
- type: object
properties:
innerProp1:
type: string
- type: object
properties:
innerProp2:
type: number
- type: object
properties:
otherOuterProp:
type: string
```
responses:
"200":
description: Successful response
content:
application/json:
schema:
allOf:
- type: object
properties:
outerProp:
type: object
allOf:
- type: object
properties:
innerProp1:
type: string
- type: object
properties:
innerProp2:
type: number
- type: object
properties:
otherOuterProp:
type: string

components:
schemas:
# Your existing schemas are integrated here.
ExistingSchema1:
type: object
properties: ...

ExistingSchema2:
type: object
properties: ...

# New schemas for Books demonstration
BookBase:
type: object
required:
- id
- title
- author
properties:
id:
type: integer
format: int64
description: Unique identifier for the book
title:
type: string
description: The title of the book
author:
type: string
description: The author of the book

AdditionalBookInfo:
type: object
properties:
publishedDate:
type: string
format: date
description: The date the book was published
genre:
type: string
description: The genre of the book
tags:
type: array
items:
type: string
description: Tags associated with the book

Book:
allOf:
- $ref: "#/components/schemas/BookBase"
- $ref: "#/components/schemas/AdditionalBookInfo"
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-openapi-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
"@docusaurus/utils": "^3.5.0",
"@docusaurus/utils-validation": "^3.5.0",
"@redocly/openapi-core": "^1.10.5",
"allof-merge": "^0.6.6",
"chalk": "^4.1.2",
"clsx": "^1.1.1",
"fs-extra": "^9.0.1",
"json-pointer": "^0.6.2",
"json-schema-merge-allof": "^0.8.1",
"json5": "^2.2.3",
"lodash": "^4.17.20",
"mustache": "^4.2.0",
Expand Down
Loading

0 comments on commit 893b432

Please sign in to comment.