Skip to content
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

Implement React components to reduce emitted MDX output from plugin #979

Merged
merged 71 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
9c46625
add new ParamsDetails component
sserrata Sep 28, 2024
8e3715c
add className to Props
sserrata Sep 28, 2024
247e7f1
refactor createParamsDetails to use component
sserrata Sep 28, 2024
66e5b7a
add ParamsDetails to imports
sserrata Sep 28, 2024
583e5db
fix import name
sserrata Sep 28, 2024
085f484
switch to docusaurus Details component
sserrata Sep 29, 2024
310bb31
remove code comment
sserrata Sep 29, 2024
aee62e3
reduce params details to single component for all types
sserrata Sep 29, 2024
d01ce39
add new RequestSchema and Schema components
sserrata Sep 29, 2024
e72d99a
extend MediaTypeObject type
sserrata Sep 29, 2024
a547762
refactor to use new theme components
sserrata Sep 29, 2024
68e289b
update imports
sserrata Sep 29, 2024
bc00fcc
fix linter errors
sserrata Sep 29, 2024
33d4ccc
fix details summaries
sserrata Sep 30, 2024
93c6f02
move array brackets to component
sserrata Sep 30, 2024
9162b80
remove unused imports
sserrata Sep 30, 2024
2ebc40f
add new ResponseSchema component
sserrata Oct 1, 2024
bf4e563
switch to new ResponseSchema component
sserrata Oct 1, 2024
c392720
import new ResponseSchema component
sserrata Oct 1, 2024
e797d4d
add ResponseExamples component
sserrata Oct 1, 2024
e518e96
update imports
sserrata Oct 1, 2024
2ffcbd4
add response examples
sserrata Oct 1, 2024
d629c8c
remove unused imports
sserrata Oct 1, 2024
c44bb96
rename 'from schema' to 'generated' and cleanup examples
sserrata Oct 2, 2024
6a90713
experiment with CSR for request and response schemas
sserrata Oct 2, 2024
a276826
remove unused imports
sserrata Oct 2, 2024
a7c142d
render ParamsDetails client-side
sserrata Oct 2, 2024
8b79f4b
use ExecutionEnvironment to avoid SSR
sserrata Oct 2, 2024
aca4b79
update imports
sserrata Oct 2, 2024
257a59b
add StatusCodes component
sserrata Oct 2, 2024
3a7150a
cleanup code comments
sserrata Oct 2, 2024
96b83b5
remove unnecessary div
sserrata Oct 2, 2024
c6b051e
revert CSR experiment
sserrata Oct 2, 2024
606474e
remove unneccessary div
sserrata Oct 2, 2024
86d29d1
add DetailsNode component and markdown rendering for description and …
sserrata Oct 2, 2024
08b6d62
make props optional
sserrata Oct 2, 2024
c208370
support single mimtype schemas
sserrata Oct 2, 2024
92b57ae
improve allOf handling
sserrata Oct 2, 2024
613ed37
add additional schema support to edge
sserrata Oct 2, 2024
9cc56ee
port x-enumDescription fix from #981
sserrata Oct 3, 2024
74a494d
add markdown component and cleanup AnyOneOf
sserrata Oct 3, 2024
6df4c6f
cleanup Properties and add missing props
sserrata Oct 3, 2024
4eeb12c
rename SchemaComponent to SchemaNode
sserrata Oct 3, 2024
c677b2b
rename Edge to SchemaEdge and fix props and types
sserrata Oct 3, 2024
1c6c7b4
remove unused import
sserrata Oct 3, 2024
bb34a6b
cleanup PropertyDiscriminator and Markdown types
sserrata Oct 3, 2024
778e041
cleanup AdditionalProperties types and logic
sserrata Oct 3, 2024
20650cd
add Summary component, cleanup PropertyDiscriminator and SchemaNodeDe…
sserrata Oct 3, 2024
4f6d90e
avoid returning on first schema match and improve support for AnyOneOf
sserrata Oct 7, 2024
d14ce50
improve support for allOf
sserrata Oct 7, 2024
e1ab051
use type instead of schemaName for anyOneOf primitives
sserrata Oct 7, 2024
504cb2a
change label from generated to auto
sserrata Oct 7, 2024
e9b88c9
improve Items support for allOf and primitives
sserrata Oct 7, 2024
e49ad3a
add margin top to enum descriptions
sserrata Oct 7, 2024
e5973ef
cleanup api doc template imports
sserrata Oct 7, 2024
3b96019
add default logo for http and shell
sserrata Oct 7, 2024
8800eff
add language tabs back
sserrata Oct 7, 2024
d3700e7
experiment with lazy render
sserrata Oct 7, 2024
7552538
render loading spinner instead of text
sserrata Oct 7, 2024
8cca337
implement lazy loading without BrowserOnly
sserrata Oct 7, 2024
6845e76
try lazy loading on all
sserrata Oct 7, 2024
3880c89
implement skeleton loader component
sserrata Oct 10, 2024
a7b9d3f
remove unused imports
sserrata Oct 10, 2024
6c6071e
improve handling of top-level primitives
sserrata Oct 10, 2024
f10ceb8
migrate to allof-merge library to improve merging
sserrata Oct 10, 2024
5d0684d
fix create allof request/response samples
sserrata Oct 10, 2024
6db4252
update test snapshot
sserrata Oct 10, 2024
fb837ea
fix linter errors
sserrata Oct 10, 2024
e264812
extend allOf tests
sserrata Oct 16, 2024
ae8639b
Merge branch 'main' into params-details
sserrata Oct 16, 2024
ef8b1d9
refactor items allof to new pattern/library
sserrata Oct 16, 2024
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
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
Loading