@stoplight/elements-core 7.7.14 → 7.7.16
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/components/Docs/Article/Article.spec.d.ts +1 -0
- package/components/TryIt/build-request.d.ts +1 -0
- package/index.esm.js +33 -9
- package/index.js +32 -8
- package/index.mjs +33 -9
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -20,4 +20,5 @@ export declare const getQueryParams: ({ httpOperation, parameterValues, }: Pick<
|
|
|
20
20
|
}[];
|
|
21
21
|
export declare function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, parameterValues, mockData, auth, chosenServer, credentials, corsProxy, }: BuildRequestInput): Promise<Parameters<typeof fetch>>;
|
|
22
22
|
export declare function buildHarRequest({ httpOperation, bodyInput, parameterValues, mediaTypeContent, auth, mockData, chosenServer, corsProxy, }: BuildRequestInput): Promise<HarRequest>;
|
|
23
|
+
export declare function getAcceptedMimeTypes(httpOperation: IHttpOperation): string[];
|
|
23
24
|
export {};
|
package/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __rest, __awaiter } from 'tslib';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useContext, useMemo } from 'react';
|
|
4
4
|
import { convertToJsonSchema } from '@stoplight/http-spec/oas';
|
|
@@ -256,12 +256,22 @@ const MarkdownViewer = (props) => {
|
|
|
256
256
|
};
|
|
257
257
|
MarkdownViewer.displayName = 'MarkdownViewer';
|
|
258
258
|
|
|
259
|
-
const
|
|
259
|
+
const ArticleComponentForHashRouter = React.memo(({ data }) => {
|
|
260
260
|
const { pathname } = useLocation();
|
|
261
|
-
const
|
|
262
|
-
|
|
261
|
+
const basePath = `#${pathname.split('#')[0]}`;
|
|
262
|
+
return React.createElement(BaseArticleComponent, { data: data, tocBasePath: basePath });
|
|
263
|
+
});
|
|
264
|
+
const BaseArticleComponent = React.memo((_a) => {
|
|
265
|
+
var { data } = _a, props = __rest(_a, ["data"]);
|
|
263
266
|
return (React.createElement(Box, { className: "sl-elements-article" },
|
|
264
|
-
React.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true,
|
|
267
|
+
React.createElement(MarkdownViewer, Object.assign({ className: "sl-elements-article-content", markdown: data, includeToc: true }, props))));
|
|
268
|
+
});
|
|
269
|
+
const ArticleComponent = React.memo(({ data }) => {
|
|
270
|
+
const routerKind = useRouterType();
|
|
271
|
+
if (routerKind === 'hash') {
|
|
272
|
+
return React.createElement(ArticleComponentForHashRouter, { data: data });
|
|
273
|
+
}
|
|
274
|
+
return React.createElement(BaseArticleComponent, { data: data });
|
|
265
275
|
});
|
|
266
276
|
const Article = withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
|
|
267
277
|
|
|
@@ -1470,7 +1480,7 @@ function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, paramet
|
|
|
1470
1480
|
var _a, _b, _c;
|
|
1471
1481
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1472
1482
|
const serverUrl = getServerUrl({ httpOperation, mockData, chosenServer, corsProxy });
|
|
1473
|
-
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase());
|
|
1483
|
+
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase()) && bodyInput !== undefined;
|
|
1474
1484
|
const queryParams = getQueryParams({ httpOperation, parameterValues });
|
|
1475
1485
|
const rawHeaders = filterOutAuthorizationParams((_b = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.headers) !== null && _b !== void 0 ? _b : [], httpOperation.security)
|
|
1476
1486
|
.map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); })
|
|
@@ -1480,7 +1490,9 @@ function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, paramet
|
|
|
1480
1490
|
const urlObject = new URL(serverUrl + expandedPath);
|
|
1481
1491
|
urlObject.search = new URLSearchParams(queryParamsWithAuth.map(nameAndValueObjectToPair)).toString();
|
|
1482
1492
|
const body = typeof bodyInput === 'object' ? yield createRequestBody(mediaTypeContent, bodyInput) : bodyInput;
|
|
1483
|
-
const
|
|
1493
|
+
const acceptedMimeTypes = getAcceptedMimeTypes(httpOperation);
|
|
1494
|
+
const headers = Object.assign(Object.assign(Object.assign(Object.assign({}, (acceptedMimeTypes.length > 0 && { Accept: acceptedMimeTypes.join(', ') })), ((mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== 'multipart/form-data' &&
|
|
1495
|
+
shouldIncludeBody && {
|
|
1484
1496
|
'Content-Type': (_c = mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== null && _c !== void 0 ? _c : 'application/json',
|
|
1485
1497
|
})), Object.fromEntries(headersWithAuth.map(nameAndValueObjectToPair))), mockData === null || mockData === void 0 ? void 0 : mockData.header);
|
|
1486
1498
|
return [
|
|
@@ -1545,12 +1557,19 @@ function buildHarRequest({ httpOperation, bodyInput, parameterValues, mediaTypeC
|
|
|
1545
1557
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1546
1558
|
const serverUrl = getServerUrl({ httpOperation, mockData, chosenServer, corsProxy });
|
|
1547
1559
|
const mimeType = (_a = mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== null && _a !== void 0 ? _a : 'application/json';
|
|
1548
|
-
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase());
|
|
1560
|
+
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase()) && bodyInput !== undefined;
|
|
1549
1561
|
const queryParams = getQueryParams({ httpOperation, parameterValues });
|
|
1550
1562
|
const headerParams = (_d = (_c = (_b = httpOperation.request) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); })) !== null && _d !== void 0 ? _d : [];
|
|
1551
1563
|
if (mockData === null || mockData === void 0 ? void 0 : mockData.header) {
|
|
1552
1564
|
headerParams.push({ name: 'Prefer', value: mockData.header.Prefer });
|
|
1553
1565
|
}
|
|
1566
|
+
if (shouldIncludeBody) {
|
|
1567
|
+
headerParams.push({ name: 'Content-Type', value: mimeType });
|
|
1568
|
+
}
|
|
1569
|
+
const acceptedMimeTypes = getAcceptedMimeTypes(httpOperation);
|
|
1570
|
+
if (acceptedMimeTypes.length > 0) {
|
|
1571
|
+
headerParams.push({ name: 'Accept', value: acceptedMimeTypes.join(', ') });
|
|
1572
|
+
}
|
|
1554
1573
|
const [queryParamsWithAuth, headerParamsWithAuth] = runAuthRequestEhancements(auth, queryParams, headerParams);
|
|
1555
1574
|
const expandedPath = uriExpand(httpOperation.path, parameterValues);
|
|
1556
1575
|
const urlObject = new URL(serverUrl + expandedPath);
|
|
@@ -1581,7 +1600,7 @@ function buildHarRequest({ httpOperation, bodyInput, parameterValues, mediaTypeC
|
|
|
1581
1600
|
url: urlObject.href,
|
|
1582
1601
|
httpVersion: 'HTTP/1.1',
|
|
1583
1602
|
cookies: [],
|
|
1584
|
-
headers:
|
|
1603
|
+
headers: headerParamsWithAuth,
|
|
1585
1604
|
queryString: queryParamsWithAuth,
|
|
1586
1605
|
postData: postData,
|
|
1587
1606
|
headersSize: -1,
|
|
@@ -1596,6 +1615,11 @@ function uriExpand(uri, data) {
|
|
|
1596
1615
|
return uri.replace(/{([^#?]+?)}/g, (match, value) => {
|
|
1597
1616
|
return data[value] || value;
|
|
1598
1617
|
});
|
|
1618
|
+
}
|
|
1619
|
+
function getAcceptedMimeTypes(httpOperation) {
|
|
1620
|
+
return Array.from(new Set(httpOperation.responses.flatMap(response => response === undefined || response.contents === undefined
|
|
1621
|
+
? []
|
|
1622
|
+
: response.contents.map(contentType => contentType.mediaType))));
|
|
1599
1623
|
}
|
|
1600
1624
|
|
|
1601
1625
|
const formatMultiValueHeader = (...keyValuePairs) => {
|
package/index.js
CHANGED
|
@@ -309,12 +309,22 @@ const MarkdownViewer = (props) => {
|
|
|
309
309
|
};
|
|
310
310
|
MarkdownViewer.displayName = 'MarkdownViewer';
|
|
311
311
|
|
|
312
|
-
const
|
|
312
|
+
const ArticleComponentForHashRouter = React__namespace.memo(({ data }) => {
|
|
313
313
|
const { pathname } = reactRouterDom.useLocation();
|
|
314
|
-
const
|
|
315
|
-
|
|
314
|
+
const basePath = `#${pathname.split('#')[0]}`;
|
|
315
|
+
return React__namespace.createElement(BaseArticleComponent, { data: data, tocBasePath: basePath });
|
|
316
|
+
});
|
|
317
|
+
const BaseArticleComponent = React__namespace.memo((_a) => {
|
|
318
|
+
var { data } = _a, props = tslib.__rest(_a, ["data"]);
|
|
316
319
|
return (React__namespace.createElement(mosaic.Box, { className: "sl-elements-article" },
|
|
317
|
-
React__namespace.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true,
|
|
320
|
+
React__namespace.createElement(MarkdownViewer, Object.assign({ className: "sl-elements-article-content", markdown: data, includeToc: true }, props))));
|
|
321
|
+
});
|
|
322
|
+
const ArticleComponent = React__namespace.memo(({ data }) => {
|
|
323
|
+
const routerKind = useRouterType();
|
|
324
|
+
if (routerKind === 'hash') {
|
|
325
|
+
return React__namespace.createElement(ArticleComponentForHashRouter, { data: data });
|
|
326
|
+
}
|
|
327
|
+
return React__namespace.createElement(BaseArticleComponent, { data: data });
|
|
318
328
|
});
|
|
319
329
|
const Article = reactErrorBoundary.withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
|
|
320
330
|
|
|
@@ -1523,7 +1533,7 @@ function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, paramet
|
|
|
1523
1533
|
var _a, _b, _c;
|
|
1524
1534
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
1525
1535
|
const serverUrl = getServerUrl({ httpOperation, mockData, chosenServer, corsProxy });
|
|
1526
|
-
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase());
|
|
1536
|
+
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase()) && bodyInput !== undefined;
|
|
1527
1537
|
const queryParams = getQueryParams({ httpOperation, parameterValues });
|
|
1528
1538
|
const rawHeaders = filterOutAuthorizationParams((_b = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.headers) !== null && _b !== void 0 ? _b : [], httpOperation.security)
|
|
1529
1539
|
.map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); })
|
|
@@ -1533,7 +1543,9 @@ function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, paramet
|
|
|
1533
1543
|
const urlObject = new URL(serverUrl + expandedPath);
|
|
1534
1544
|
urlObject.search = new URLSearchParams(queryParamsWithAuth.map(nameAndValueObjectToPair)).toString();
|
|
1535
1545
|
const body = typeof bodyInput === 'object' ? yield createRequestBody(mediaTypeContent, bodyInput) : bodyInput;
|
|
1536
|
-
const
|
|
1546
|
+
const acceptedMimeTypes = getAcceptedMimeTypes(httpOperation);
|
|
1547
|
+
const headers = Object.assign(Object.assign(Object.assign(Object.assign({}, (acceptedMimeTypes.length > 0 && { Accept: acceptedMimeTypes.join(', ') })), ((mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== 'multipart/form-data' &&
|
|
1548
|
+
shouldIncludeBody && {
|
|
1537
1549
|
'Content-Type': (_c = mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== null && _c !== void 0 ? _c : 'application/json',
|
|
1538
1550
|
})), Object.fromEntries(headersWithAuth.map(nameAndValueObjectToPair))), mockData === null || mockData === void 0 ? void 0 : mockData.header);
|
|
1539
1551
|
return [
|
|
@@ -1598,12 +1610,19 @@ function buildHarRequest({ httpOperation, bodyInput, parameterValues, mediaTypeC
|
|
|
1598
1610
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
1599
1611
|
const serverUrl = getServerUrl({ httpOperation, mockData, chosenServer, corsProxy });
|
|
1600
1612
|
const mimeType = (_a = mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== null && _a !== void 0 ? _a : 'application/json';
|
|
1601
|
-
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase());
|
|
1613
|
+
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase()) && bodyInput !== undefined;
|
|
1602
1614
|
const queryParams = getQueryParams({ httpOperation, parameterValues });
|
|
1603
1615
|
const headerParams = (_d = (_c = (_b = httpOperation.request) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); })) !== null && _d !== void 0 ? _d : [];
|
|
1604
1616
|
if (mockData === null || mockData === void 0 ? void 0 : mockData.header) {
|
|
1605
1617
|
headerParams.push({ name: 'Prefer', value: mockData.header.Prefer });
|
|
1606
1618
|
}
|
|
1619
|
+
if (shouldIncludeBody) {
|
|
1620
|
+
headerParams.push({ name: 'Content-Type', value: mimeType });
|
|
1621
|
+
}
|
|
1622
|
+
const acceptedMimeTypes = getAcceptedMimeTypes(httpOperation);
|
|
1623
|
+
if (acceptedMimeTypes.length > 0) {
|
|
1624
|
+
headerParams.push({ name: 'Accept', value: acceptedMimeTypes.join(', ') });
|
|
1625
|
+
}
|
|
1607
1626
|
const [queryParamsWithAuth, headerParamsWithAuth] = runAuthRequestEhancements(auth, queryParams, headerParams);
|
|
1608
1627
|
const expandedPath = uriExpand(httpOperation.path, parameterValues);
|
|
1609
1628
|
const urlObject = new URL(serverUrl + expandedPath);
|
|
@@ -1634,7 +1653,7 @@ function buildHarRequest({ httpOperation, bodyInput, parameterValues, mediaTypeC
|
|
|
1634
1653
|
url: urlObject.href,
|
|
1635
1654
|
httpVersion: 'HTTP/1.1',
|
|
1636
1655
|
cookies: [],
|
|
1637
|
-
headers:
|
|
1656
|
+
headers: headerParamsWithAuth,
|
|
1638
1657
|
queryString: queryParamsWithAuth,
|
|
1639
1658
|
postData: postData,
|
|
1640
1659
|
headersSize: -1,
|
|
@@ -1649,6 +1668,11 @@ function uriExpand(uri, data) {
|
|
|
1649
1668
|
return uri.replace(/{([^#?]+?)}/g, (match, value) => {
|
|
1650
1669
|
return data[value] || value;
|
|
1651
1670
|
});
|
|
1671
|
+
}
|
|
1672
|
+
function getAcceptedMimeTypes(httpOperation) {
|
|
1673
|
+
return Array.from(new Set(httpOperation.responses.flatMap(response => response === undefined || response.contents === undefined
|
|
1674
|
+
? []
|
|
1675
|
+
: response.contents.map(contentType => contentType.mediaType))));
|
|
1652
1676
|
}
|
|
1653
1677
|
|
|
1654
1678
|
const formatMultiValueHeader = (...keyValuePairs) => {
|
package/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __rest, __awaiter } from 'tslib';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useContext, useMemo } from 'react';
|
|
4
4
|
import { convertToJsonSchema } from '@stoplight/http-spec/oas';
|
|
@@ -256,12 +256,22 @@ const MarkdownViewer = (props) => {
|
|
|
256
256
|
};
|
|
257
257
|
MarkdownViewer.displayName = 'MarkdownViewer';
|
|
258
258
|
|
|
259
|
-
const
|
|
259
|
+
const ArticleComponentForHashRouter = React.memo(({ data }) => {
|
|
260
260
|
const { pathname } = useLocation();
|
|
261
|
-
const
|
|
262
|
-
|
|
261
|
+
const basePath = `#${pathname.split('#')[0]}`;
|
|
262
|
+
return React.createElement(BaseArticleComponent, { data: data, tocBasePath: basePath });
|
|
263
|
+
});
|
|
264
|
+
const BaseArticleComponent = React.memo((_a) => {
|
|
265
|
+
var { data } = _a, props = __rest(_a, ["data"]);
|
|
263
266
|
return (React.createElement(Box, { className: "sl-elements-article" },
|
|
264
|
-
React.createElement(MarkdownViewer, { className: "sl-elements-article-content", markdown: data, includeToc: true,
|
|
267
|
+
React.createElement(MarkdownViewer, Object.assign({ className: "sl-elements-article-content", markdown: data, includeToc: true }, props))));
|
|
268
|
+
});
|
|
269
|
+
const ArticleComponent = React.memo(({ data }) => {
|
|
270
|
+
const routerKind = useRouterType();
|
|
271
|
+
if (routerKind === 'hash') {
|
|
272
|
+
return React.createElement(ArticleComponentForHashRouter, { data: data });
|
|
273
|
+
}
|
|
274
|
+
return React.createElement(BaseArticleComponent, { data: data });
|
|
265
275
|
});
|
|
266
276
|
const Article = withErrorBoundary(ArticleComponent, { recoverableProps: ['data'] });
|
|
267
277
|
|
|
@@ -1470,7 +1480,7 @@ function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, paramet
|
|
|
1470
1480
|
var _a, _b, _c;
|
|
1471
1481
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1472
1482
|
const serverUrl = getServerUrl({ httpOperation, mockData, chosenServer, corsProxy });
|
|
1473
|
-
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase());
|
|
1483
|
+
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase()) && bodyInput !== undefined;
|
|
1474
1484
|
const queryParams = getQueryParams({ httpOperation, parameterValues });
|
|
1475
1485
|
const rawHeaders = filterOutAuthorizationParams((_b = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.headers) !== null && _b !== void 0 ? _b : [], httpOperation.security)
|
|
1476
1486
|
.map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); })
|
|
@@ -1480,7 +1490,9 @@ function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, paramet
|
|
|
1480
1490
|
const urlObject = new URL(serverUrl + expandedPath);
|
|
1481
1491
|
urlObject.search = new URLSearchParams(queryParamsWithAuth.map(nameAndValueObjectToPair)).toString();
|
|
1482
1492
|
const body = typeof bodyInput === 'object' ? yield createRequestBody(mediaTypeContent, bodyInput) : bodyInput;
|
|
1483
|
-
const
|
|
1493
|
+
const acceptedMimeTypes = getAcceptedMimeTypes(httpOperation);
|
|
1494
|
+
const headers = Object.assign(Object.assign(Object.assign(Object.assign({}, (acceptedMimeTypes.length > 0 && { Accept: acceptedMimeTypes.join(', ') })), ((mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== 'multipart/form-data' &&
|
|
1495
|
+
shouldIncludeBody && {
|
|
1484
1496
|
'Content-Type': (_c = mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== null && _c !== void 0 ? _c : 'application/json',
|
|
1485
1497
|
})), Object.fromEntries(headersWithAuth.map(nameAndValueObjectToPair))), mockData === null || mockData === void 0 ? void 0 : mockData.header);
|
|
1486
1498
|
return [
|
|
@@ -1545,12 +1557,19 @@ function buildHarRequest({ httpOperation, bodyInput, parameterValues, mediaTypeC
|
|
|
1545
1557
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1546
1558
|
const serverUrl = getServerUrl({ httpOperation, mockData, chosenServer, corsProxy });
|
|
1547
1559
|
const mimeType = (_a = mediaTypeContent === null || mediaTypeContent === void 0 ? void 0 : mediaTypeContent.mediaType) !== null && _a !== void 0 ? _a : 'application/json';
|
|
1548
|
-
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase());
|
|
1560
|
+
const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase()) && bodyInput !== undefined;
|
|
1549
1561
|
const queryParams = getQueryParams({ httpOperation, parameterValues });
|
|
1550
1562
|
const headerParams = (_d = (_c = (_b = httpOperation.request) === null || _b === void 0 ? void 0 : _b.headers) === null || _c === void 0 ? void 0 : _c.map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); })) !== null && _d !== void 0 ? _d : [];
|
|
1551
1563
|
if (mockData === null || mockData === void 0 ? void 0 : mockData.header) {
|
|
1552
1564
|
headerParams.push({ name: 'Prefer', value: mockData.header.Prefer });
|
|
1553
1565
|
}
|
|
1566
|
+
if (shouldIncludeBody) {
|
|
1567
|
+
headerParams.push({ name: 'Content-Type', value: mimeType });
|
|
1568
|
+
}
|
|
1569
|
+
const acceptedMimeTypes = getAcceptedMimeTypes(httpOperation);
|
|
1570
|
+
if (acceptedMimeTypes.length > 0) {
|
|
1571
|
+
headerParams.push({ name: 'Accept', value: acceptedMimeTypes.join(', ') });
|
|
1572
|
+
}
|
|
1554
1573
|
const [queryParamsWithAuth, headerParamsWithAuth] = runAuthRequestEhancements(auth, queryParams, headerParams);
|
|
1555
1574
|
const expandedPath = uriExpand(httpOperation.path, parameterValues);
|
|
1556
1575
|
const urlObject = new URL(serverUrl + expandedPath);
|
|
@@ -1581,7 +1600,7 @@ function buildHarRequest({ httpOperation, bodyInput, parameterValues, mediaTypeC
|
|
|
1581
1600
|
url: urlObject.href,
|
|
1582
1601
|
httpVersion: 'HTTP/1.1',
|
|
1583
1602
|
cookies: [],
|
|
1584
|
-
headers:
|
|
1603
|
+
headers: headerParamsWithAuth,
|
|
1585
1604
|
queryString: queryParamsWithAuth,
|
|
1586
1605
|
postData: postData,
|
|
1587
1606
|
headersSize: -1,
|
|
@@ -1596,6 +1615,11 @@ function uriExpand(uri, data) {
|
|
|
1596
1615
|
return uri.replace(/{([^#?]+?)}/g, (match, value) => {
|
|
1597
1616
|
return data[value] || value;
|
|
1598
1617
|
});
|
|
1618
|
+
}
|
|
1619
|
+
function getAcceptedMimeTypes(httpOperation) {
|
|
1620
|
+
return Array.from(new Set(httpOperation.responses.flatMap(response => response === undefined || response.contents === undefined
|
|
1621
|
+
? []
|
|
1622
|
+
: response.contents.map(contentType => contentType.mediaType))));
|
|
1599
1623
|
}
|
|
1600
1624
|
|
|
1601
1625
|
const formatMultiValueHeader = (...keyValuePairs) => {
|