Skip to content

Commit c9e69d7

Browse files
committed
Merge branch 'main' of https://github.com/blindaa121/docusaurus-openapi-docs into codex/update-packages-and-run-tests
2 parents 4e3a0de + 76bfb5b commit c9e69d7

File tree

11 files changed

+142
-24
lines changed

11 files changed

+142
-24
lines changed

.github/workflows/build-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
1818
- uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
1919
with:
20-
node-version: "18"
20+
node-version: "20"
2121
cache: yarn
2222
- uses: preactjs/compressed-size-action@946a292cd35bd1088e0d7eb92b69d1a8d5b5d76a # v2
2323
with:

.github/workflows/canary-beta-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Node
2424
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
2525
with:
26-
node-version: "18"
26+
node-version: "20"
2727
cache: yarn
2828
- name: Prepare git
2929
run: |

.github/workflows/canary-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up Node
2424
uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4
2525
with:
26-
node-version: "18"
26+
node-version: "20"
2727
cache: yarn
2828
- name: Prepare git
2929
run: |

AGENTS.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,23 @@ yarn test
5757
```bash
5858
yarn release:changelog
5959
```
60-
Copy the output to the top of `CHANGELOG.md` with the current date. Update the "High level enhancements" section and clean up the history for public release.
60+
Copy the output to the top of `CHANGELOG.md` with the current date. Update the "High level enhancements" section (high-level summary of new features or bug fixes) and clean up the history for public release.
6161
3. **Cleanup documentation** in `README.md`, `packages/docusaurus-plugin-openapi-docs/README.md` and `demo/docs/intro.mdx`.
6262
4. **Commit** all changes with the message `Prepare release vX.Y.Z`.
6363

6464
Once merged, the `release.yaml` workflow will publish the release automatically.
65+
66+
## Handling Issues and Pull Requests
67+
68+
### Issues
69+
70+
- Triage each report to figure out whether it's a question, documentation request, or bug.
71+
- Investigate carefully to confirm the problem is within this project and not caused by user error, dependency mismatches, or other external factors.
72+
- Consider how a fix might affect existing features and avoid any regression or breaking change.
73+
74+
### Pull Requests
75+
76+
- Start by checking if the contribution updates documentation, fixes a bug, or adds or enhances a feature.
77+
- Ensure the proposal fits the scope of the project and doesn't duplicate existing docs or functionality.
78+
- Provide a summary of whether the pull request is ready to merge or what changes are still needed from the contributor.
79+
- Consider how merging the pull request might affect existing features and make sure it does not introduce regressions or breaking changes.

demo/examples/tests/allOf.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,51 @@ paths:
367367
otherOuterProp:
368368
type: string
369369

370+
/allof-parent-required:
371+
get:
372+
tags:
373+
- allOf
374+
summary: allOf inherits parent required
375+
description: |
376+
Parent object marks the "pet" property as required while its schema is composed via allOf.
377+
378+
Schema:
379+
```yaml
380+
type: object
381+
properties:
382+
pet:
383+
allOf:
384+
- type: object
385+
properties:
386+
name:
387+
type: string
388+
- type: object
389+
properties:
390+
age:
391+
type: integer
392+
required: [pet]
393+
```
394+
responses:
395+
"200":
396+
description: Successful response
397+
content:
398+
application/json:
399+
schema:
400+
type: object
401+
properties:
402+
pet:
403+
allOf:
404+
- type: object
405+
properties:
406+
name:
407+
type: string
408+
- type: object
409+
properties:
410+
age:
411+
type: integer
412+
required:
413+
- pet
414+
370415
components:
371416
schemas:
372417
# Your existing schemas are integrated here.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
openapi: 3.0.3
2+
info:
3+
title: Webhook Example
4+
version: 1.0.0
5+
paths: {}
6+
webhooks:
7+
order.created:
8+
post:
9+
requestBody:
10+
description: example body
11+
content:
12+
application/json:
13+
schema:
14+
type: object
15+
responses:
16+
"200":
17+
description: OK

packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,19 @@ function createItems(
274274
for (let [path, pathObject] of Object.entries(
275275
openapiData["x-webhooks"] ?? openapiData["webhooks"] ?? {}
276276
)) {
277+
const eventName = path;
277278
path = "webhook";
278279
const { $ref, description, parameters, servers, summary, ...rest } =
279280
pathObject;
280281
for (let [method, operationObject] of Object.entries({ ...rest })) {
281282
method = "event";
283+
if (
284+
operationObject.summary === undefined &&
285+
operationObject.operationId === undefined
286+
) {
287+
operationObject.summary = eventName;
288+
}
289+
282290
const title =
283291
operationObject.summary ??
284292
operationObject.operationId ??
@@ -290,7 +298,7 @@ function createItems(
290298

291299
const baseId = operationObject.operationId
292300
? kebabCase(operationObject.operationId)
293-
: kebabCase(operationObject.summary);
301+
: kebabCase(operationObject.summary ?? eventName);
294302

295303
const extensions = [];
296304
const commonExtensions = ["x-codeSamples"];
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* ============================================================================
2+
* Copyright (c) Palo Alto Networks
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
* ========================================================================== */
7+
8+
import path from "path";
9+
10+
// eslint-disable-next-line import/no-extraneous-dependencies
11+
import { posixPath } from "@docusaurus/utils";
12+
13+
import { readOpenapiFiles, processOpenapiFiles } from ".";
14+
15+
describe("webhooks", () => {
16+
it("uses event name when summary and operationId are missing", async () => {
17+
const files = await readOpenapiFiles(
18+
posixPath(path.join(__dirname, "__fixtures__/webhook/openapi.yaml"))
19+
);
20+
21+
const [items] = await processOpenapiFiles(
22+
files,
23+
{ specPath: "", outputDir: "" } as any,
24+
{}
25+
);
26+
27+
const webhookItem = items.find((item) => item.type === "api");
28+
expect(webhookItem?.id).toBe("order-created");
29+
});
30+
});

packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/CodeTabs/_CodeTabs.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,11 @@ body[class="ReactModal__Body--open"] {
197197
}
198198

199199
&.active {
200-
box-shadow: 0 0 0 3px var(--openapi-code-tab-shadow-color-curl);
200+
box-shadow: 0 0 0 3px
201+
var(
202+
--openapi-code-tab-shadow-color-curl,
203+
var(--openapi-code-tab-shadow-color-bash)
204+
);
201205
border-color: var(--ifm-color-danger);
202206
}
203207
}

packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,7 @@ const SchemaEdge: React.FC<SchemaEdgeProps> = ({
725725
name={name}
726726
schemaName={mergedSchemaName}
727727
required={
728-
Array.isArray(mergedSchemas.required)
729-
? mergedSchemas.required.includes(name)
730-
: mergedSchemas.required
728+
Array.isArray(required) ? required.includes(name) : required
731729
}
732730
nullable={mergedSchemas.nullable}
733731
schema={mergedSchemas}
@@ -742,9 +740,7 @@ const SchemaEdge: React.FC<SchemaEdgeProps> = ({
742740
name={name}
743741
schemaName={mergedSchemaName}
744742
required={
745-
Array.isArray(mergedSchemas.required)
746-
? mergedSchemas.required.includes(name)
747-
: mergedSchemas.required
743+
Array.isArray(required) ? required.includes(name) : required
748744
}
749745
nullable={mergedSchemas.nullable}
750746
schema={mergedSchemas}
@@ -754,18 +750,18 @@ const SchemaEdge: React.FC<SchemaEdgeProps> = ({
754750
}
755751

756752
if (mergedSchemas.items?.properties) {
757-
<SchemaNodeDetails
758-
name={name}
759-
schemaName={mergedSchemaName}
760-
required={
761-
Array.isArray(mergedSchemas.required)
762-
? mergedSchemas.required.includes(name)
763-
: mergedSchemas.required
764-
}
765-
nullable={mergedSchemas.nullable}
766-
schema={mergedSchemas}
767-
schemaType={schemaType}
768-
/>;
753+
return (
754+
<SchemaNodeDetails
755+
name={name}
756+
schemaName={mergedSchemaName}
757+
required={
758+
Array.isArray(required) ? required.includes(name) : required
759+
}
760+
nullable={mergedSchemas.nullable}
761+
schema={mergedSchemas}
762+
schemaType={schemaType}
763+
/>
764+
);
769765
}
770766

771767
return (

0 commit comments

Comments
 (0)