docusaurus-plugin-openapi-docs 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/markdown/createRequestSchema.js +1 -1
- package/lib/markdown/createResponseSchema.js +1 -1
- package/lib/openapi/openapi.js +11 -0
- package/package.json +2 -2
- package/src/markdown/createRequestSchema.ts +1 -1
- package/src/markdown/createResponseSchema.ts +1 -1
- package/src/openapi/openapi.ts +15 -0
|
@@ -566,7 +566,7 @@ function createRequestSchema({ title, body, ...rest }) {
|
|
|
566
566
|
const mimeTypes = Object.keys(body.content);
|
|
567
567
|
if (mimeTypes && mimeTypes.length > 1) {
|
|
568
568
|
return (0, utils_1.create)("MimeTabs", {
|
|
569
|
-
|
|
569
|
+
schemaType: "request",
|
|
570
570
|
children: mimeTypes.map((mimeType) => {
|
|
571
571
|
const firstBody = body.content[mimeType].schema;
|
|
572
572
|
if (firstBody === undefined) {
|
|
@@ -566,7 +566,7 @@ function createResponseSchema({ title, body, ...rest }) {
|
|
|
566
566
|
const mimeTypes = Object.keys(body.content);
|
|
567
567
|
if (mimeTypes && mimeTypes.length) {
|
|
568
568
|
return (0, utils_1.create)("MimeTabs", {
|
|
569
|
-
|
|
569
|
+
schemaType: "response",
|
|
570
570
|
children: mimeTypes.map((mimeType) => {
|
|
571
571
|
const responseExamples = body.content[mimeType].examples;
|
|
572
572
|
const responseExample = body.content[mimeType].example;
|
package/lib/openapi/openapi.js
CHANGED
|
@@ -18,6 +18,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
18
18
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
19
19
|
const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
|
|
20
20
|
const kebabCase_1 = __importDefault(require("lodash/kebabCase"));
|
|
21
|
+
const unionBy_1 = __importDefault(require("lodash/unionBy"));
|
|
21
22
|
const index_1 = require("../index");
|
|
22
23
|
const createRequestExample_1 = require("./createRequestExample");
|
|
23
24
|
const loadAndResolveSpec_1 = require("./utils/loadAndResolveSpec");
|
|
@@ -151,6 +152,16 @@ function createItems(openapiData, sidebarOptions) {
|
|
|
151
152
|
}
|
|
152
153
|
// TODO: Don't include summary temporarilly
|
|
153
154
|
const { summary, ...defaults } = operationObject;
|
|
155
|
+
// Merge common parameters with operation parameters
|
|
156
|
+
// Operation params take precendence over common params
|
|
157
|
+
if (parameters !== undefined) {
|
|
158
|
+
if (operationObject.parameters !== undefined) {
|
|
159
|
+
defaults.parameters = (0, unionBy_1.default)(operationObject.parameters, parameters, "name");
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
defaults.parameters = parameters;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
154
165
|
const apiPage = {
|
|
155
166
|
type: "api",
|
|
156
167
|
id: baseId,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docusaurus-plugin-openapi-docs",
|
|
3
3
|
"description": "OpenAPI plugin for Docusaurus.",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.3.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"openapi",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": ">=14"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "b599d062a8e4f1cff86b01ac9b82dc564defbf5f"
|
|
72
72
|
}
|
|
@@ -721,7 +721,7 @@ export function createRequestSchema({ title, body, ...rest }: Props) {
|
|
|
721
721
|
|
|
722
722
|
if (mimeTypes && mimeTypes.length > 1) {
|
|
723
723
|
return create("MimeTabs", {
|
|
724
|
-
|
|
724
|
+
schemaType: "request",
|
|
725
725
|
children: mimeTypes.map((mimeType) => {
|
|
726
726
|
const firstBody = body.content![mimeType].schema;
|
|
727
727
|
if (firstBody === undefined) {
|
|
@@ -721,7 +721,7 @@ export function createResponseSchema({ title, body, ...rest }: Props) {
|
|
|
721
721
|
|
|
722
722
|
if (mimeTypes && mimeTypes.length) {
|
|
723
723
|
return create("MimeTabs", {
|
|
724
|
-
|
|
724
|
+
schemaType: "response",
|
|
725
725
|
children: mimeTypes.map((mimeType: any) => {
|
|
726
726
|
const responseExamples = body.content![mimeType].examples;
|
|
727
727
|
const responseExample = body.content![mimeType].example;
|
package/src/openapi/openapi.ts
CHANGED
|
@@ -15,6 +15,7 @@ import chalk from "chalk";
|
|
|
15
15
|
import fs from "fs-extra";
|
|
16
16
|
import cloneDeep from "lodash/cloneDeep";
|
|
17
17
|
import kebabCase from "lodash/kebabCase";
|
|
18
|
+
import unionBy from "lodash/unionBy";
|
|
18
19
|
|
|
19
20
|
import { isURL } from "../index";
|
|
20
21
|
import {
|
|
@@ -193,6 +194,20 @@ function createItems(
|
|
|
193
194
|
// TODO: Don't include summary temporarilly
|
|
194
195
|
const { summary, ...defaults } = operationObject;
|
|
195
196
|
|
|
197
|
+
// Merge common parameters with operation parameters
|
|
198
|
+
// Operation params take precendence over common params
|
|
199
|
+
if (parameters !== undefined) {
|
|
200
|
+
if (operationObject.parameters !== undefined) {
|
|
201
|
+
defaults.parameters = unionBy(
|
|
202
|
+
operationObject.parameters,
|
|
203
|
+
parameters,
|
|
204
|
+
"name"
|
|
205
|
+
);
|
|
206
|
+
} else {
|
|
207
|
+
defaults.parameters = parameters;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
196
211
|
const apiPage: PartialPage<ApiPageMetadata> = {
|
|
197
212
|
type: "api",
|
|
198
213
|
id: baseId,
|