@stoplight/elements-core 7.5.2 → 7.5.6

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.
@@ -0,0 +1,3 @@
1
+ import { IHttpOperation } from '@stoplight/types';
2
+ export declare const httpOperation: IHttpOperation;
3
+ export default httpOperation;
@@ -2,3 +2,4 @@ declare const meta: import("@storybook/react").Meta<import("..").DocsComponentPr
2
2
  export default meta;
3
3
  export declare const Basic: import("@storybook/react").Story<import("..").DocsComponentProps<string | import("@stoplight/markdown/ast-types/mdast").Root> & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
4
4
  export declare const KitchenSink: import("@storybook/react").Story<import("..").DocsComponentProps<string | import("@stoplight/markdown/ast-types/mdast").Root> & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
5
+ export declare const MultipleTryIts: import("@storybook/react").Story<import("..").DocsComponentProps<string | import("@stoplight/markdown/ast-types/mdast").Root> & import("@stoplight/react-error-boundary").ErrorBoundaryProps<{}>>;
package/index.esm.js CHANGED
@@ -477,7 +477,8 @@ const getServerUrlWithDefaultValues = (server) => {
477
477
  if (url.is('relative') && typeof window !== 'undefined') {
478
478
  url = url.absoluteTo(window.location.origin);
479
479
  }
480
- return url.toString();
480
+ const stringifiedUrl = url.toString();
481
+ return stringifiedUrl.endsWith('/') ? stringifiedUrl.slice(0, -1) : stringifiedUrl;
481
482
  };
482
483
 
483
484
  const persistAtom = (key, atomInstance) => {
@@ -986,7 +987,7 @@ const booleanOptions = [
986
987
  { label: 'True', value: 'true' },
987
988
  ];
988
989
  function enumOptions(enumValues, required) {
989
- const options = map(enumValues, v => ({ value: Number.isNaN(Number(v)) ? String(v) : Number(v) }));
990
+ const options = map(enumValues, v => ({ value: typeof v === 'number' ? v : String(v) }));
990
991
  return required ? options : [{ label: 'Not Set', value: '' }, ...options];
991
992
  }
992
993
  function parameterOptions(parameter) {
@@ -1315,7 +1316,9 @@ function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, paramet
1315
1316
  const serverUrl = getServerUrl({ httpOperation, mockData, chosenServer, corsProxy });
1316
1317
  const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase());
1317
1318
  const queryParams = (_c = (_b = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.map(param => { var _a; return ({ name: param.name, value: (_a = parameterValues[param.name]) !== null && _a !== void 0 ? _a : '' }); }).filter(({ value }) => value.length > 0)) !== null && _c !== void 0 ? _c : [];
1318
- const rawHeaders = filterOutAuthorizationParams((_e = (_d = httpOperation.request) === null || _d === void 0 ? void 0 : _d.headers) !== null && _e !== void 0 ? _e : [], httpOperation.security).map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); });
1319
+ const rawHeaders = filterOutAuthorizationParams((_e = (_d = httpOperation.request) === null || _d === void 0 ? void 0 : _d.headers) !== null && _e !== void 0 ? _e : [], httpOperation.security)
1320
+ .map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); })
1321
+ .filter(({ value }) => value.length > 0);
1319
1322
  const [queryParamsWithAuth, headersWithAuth] = runAuthRequestEhancements(auth, queryParams, rawHeaders);
1320
1323
  const expandedPath = uriExpand(httpOperation.path, parameterValues);
1321
1324
  const url = new URL(URI(serverUrl).segment(expandedPath).toString());
@@ -2007,7 +2010,7 @@ const Body = ({ body, onChange }) => {
2007
2010
  React.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
2008
2011
  React.createElement(Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: (value) => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
2009
2012
  description && React.createElement(MarkdownViewer, { markdown: description }),
2010
- isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, schema: getOriginalObject(schema), viewMode: "write", hideExamples: true, renderRootTreeLines: true }))));
2013
+ isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true }))));
2011
2014
  };
2012
2015
  Body.displayName = 'HttpOperation.Body';
2013
2016
 
@@ -2141,7 +2144,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2141
2144
  React.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
2142
2145
  React.createElement(Flex, { flex: 1, justify: "end" },
2143
2146
  React.createElement(Select, { "aria-label": "Response Body Content Type", value: String(chosenContent), onChange: (value) => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" }))),
2144
- schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, viewMode: "read", hideExamples: true, parentCrumbs: ['responses', response.code], renderRootTreeLines: true }))))));
2147
+ schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true }))))));
2145
2148
  };
2146
2149
  Response.displayName = 'HttpOperation.Response';
2147
2150
  const codeToIntentVal = (code) => {
@@ -2392,6 +2395,20 @@ const Logo = ({ logo }) => {
2392
2395
  React.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))) : (React.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))));
2393
2396
  };
2394
2397
 
2398
+ function getDisplayName(WrappedComponent) {
2399
+ return WrappedComponent.displayName || WrappedComponent.name || 'Component';
2400
+ }
2401
+
2402
+ const PersistenceContextProvider = Provider;
2403
+ function withPersistenceBoundary(WrappedComponent) {
2404
+ const WithPersistenceBoundary = props => {
2405
+ return (React.createElement(PersistenceContextProvider, null,
2406
+ React.createElement(WrappedComponent, Object.assign({}, props))));
2407
+ };
2408
+ WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
2409
+ return WithPersistenceBoundary;
2410
+ }
2411
+
2395
2412
  function useParsedValue(value) {
2396
2413
  return React.useMemo(() => {
2397
2414
  let parsedValue = value;
@@ -2436,7 +2453,8 @@ const CodeComponent = props => {
2436
2453
  if (!isObject(parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
2437
2454
  return null;
2438
2455
  }
2439
- return (React__default.createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true }));
2456
+ return (React__default.createElement(PersistenceContextProvider, null,
2457
+ React__default.createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true })));
2440
2458
  }
2441
2459
  const DefaultCode = DefaultSMDComponents.code;
2442
2460
  return React__default.createElement(DefaultCode, Object.assign({}, props));
@@ -2449,23 +2467,40 @@ function parseHttpRequest(data) {
2449
2467
  method: data.method,
2450
2468
  path: uri.is('absolute') ? uri.path() : data.url,
2451
2469
  servers: [{ url: uri.is('absolute') ? uri.origin() : data.baseUrl || '' }],
2452
- request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => ({
2453
- name: key,
2454
- style: HttpParamStyles.Form,
2455
- schema: { default: Array.isArray(value) && value.length > 0 ? value[0] : value },
2456
- })), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
2470
+ request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => {
2471
+ const defaultVal = Array.isArray(value) ? value[0] : value;
2472
+ return {
2473
+ name: key,
2474
+ style: HttpParamStyles.Form,
2475
+ schema: { default: defaultVal },
2476
+ required: isHttpRequestParamRequired(defaultVal),
2477
+ };
2478
+ }), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
2457
2479
  name: key,
2458
2480
  style: HttpParamStyles.Simple,
2459
2481
  schema: { default: value },
2482
+ required: isHttpRequestParamRequired(value),
2460
2483
  })), path: pathParam === null || pathParam === void 0 ? void 0 : pathParam.map(name => ({
2461
2484
  name,
2462
2485
  style: HttpParamStyles.Simple,
2463
2486
  required: true,
2464
2487
  })) }, (data.body
2465
- ? { body: { contents: [{ mediaType: 'application/json', schema: { default: data.body } }] } }
2488
+ ? {
2489
+ body: {
2490
+ contents: [
2491
+ {
2492
+ mediaType: 'application/json',
2493
+ schema: { default: data.body },
2494
+ },
2495
+ ],
2496
+ },
2497
+ }
2466
2498
  : null)),
2467
2499
  responses: [],
2468
2500
  };
2501
+ }
2502
+ function isHttpRequestParamRequired(value) {
2503
+ return typeof value !== 'undefined';
2469
2504
  }
2470
2505
 
2471
2506
  const MarkdownComponentsProvider = ({ value, children }) => {
@@ -2656,20 +2691,6 @@ const NonIdealState = ({ description, icon, title }) => {
2656
2691
  React.createElement(Text, null, description)));
2657
2692
  };
2658
2693
 
2659
- function getDisplayName(WrappedComponent) {
2660
- return WrappedComponent.displayName || WrappedComponent.name || 'Component';
2661
- }
2662
-
2663
- const PersistenceContextProvider = Provider;
2664
- function withPersistenceBoundary(WrappedComponent) {
2665
- const WithPersistenceBoundary = props => {
2666
- return (React.createElement(PersistenceContextProvider, null,
2667
- React.createElement(WrappedComponent, Object.assign({}, props))));
2668
- };
2669
- WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
2670
- return WithPersistenceBoundary;
2671
- }
2672
-
2673
2694
  function withMosaicProvider(WrappedComponent) {
2674
2695
  const WithMosaicProvider = (props) => {
2675
2696
  try {
package/index.js CHANGED
@@ -532,7 +532,8 @@ const getServerUrlWithDefaultValues = (server) => {
532
532
  if (url.is('relative') && typeof window !== 'undefined') {
533
533
  url = url.absoluteTo(window.location.origin);
534
534
  }
535
- return url.toString();
535
+ const stringifiedUrl = url.toString();
536
+ return stringifiedUrl.endsWith('/') ? stringifiedUrl.slice(0, -1) : stringifiedUrl;
536
537
  };
537
538
 
538
539
  const persistAtom = (key, atomInstance) => {
@@ -1041,7 +1042,7 @@ const booleanOptions = [
1041
1042
  { label: 'True', value: 'true' },
1042
1043
  ];
1043
1044
  function enumOptions(enumValues, required) {
1044
- const options = map__default["default"](enumValues, v => ({ value: Number.isNaN(Number(v)) ? String(v) : Number(v) }));
1045
+ const options = map__default["default"](enumValues, v => ({ value: typeof v === 'number' ? v : String(v) }));
1045
1046
  return required ? options : [{ label: 'Not Set', value: '' }, ...options];
1046
1047
  }
1047
1048
  function parameterOptions(parameter) {
@@ -1370,7 +1371,9 @@ function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, paramet
1370
1371
  const serverUrl = getServerUrl({ httpOperation, mockData, chosenServer, corsProxy });
1371
1372
  const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase());
1372
1373
  const queryParams = (_c = (_b = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.map(param => { var _a; return ({ name: param.name, value: (_a = parameterValues[param.name]) !== null && _a !== void 0 ? _a : '' }); }).filter(({ value }) => value.length > 0)) !== null && _c !== void 0 ? _c : [];
1373
- const rawHeaders = filterOutAuthorizationParams((_e = (_d = httpOperation.request) === null || _d === void 0 ? void 0 : _d.headers) !== null && _e !== void 0 ? _e : [], httpOperation.security).map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); });
1374
+ const rawHeaders = filterOutAuthorizationParams((_e = (_d = httpOperation.request) === null || _d === void 0 ? void 0 : _d.headers) !== null && _e !== void 0 ? _e : [], httpOperation.security)
1375
+ .map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); })
1376
+ .filter(({ value }) => value.length > 0);
1374
1377
  const [queryParamsWithAuth, headersWithAuth] = runAuthRequestEhancements(auth, queryParams, rawHeaders);
1375
1378
  const expandedPath = uriExpand(httpOperation.path, parameterValues);
1376
1379
  const url = new URL(URI__default["default"](serverUrl).segment(expandedPath).toString());
@@ -2062,7 +2065,7 @@ const Body = ({ body, onChange }) => {
2062
2065
  React__namespace.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
2063
2066
  React__namespace.createElement(mosaic.Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: (value) => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
2064
2067
  description && React__namespace.createElement(MarkdownViewer, { markdown: description }),
2065
- isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, schema: getOriginalObject(schema), viewMode: "write", hideExamples: true, renderRootTreeLines: true }))));
2068
+ isJSONSchema(schema) && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { resolveRef: refResolver, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true }))));
2066
2069
  };
2067
2070
  Body.displayName = 'HttpOperation.Body';
2068
2071
 
@@ -2196,7 +2199,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2196
2199
  React__namespace.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
2197
2200
  React__namespace.createElement(mosaic.Flex, { flex: 1, justify: "end" },
2198
2201
  React__namespace.createElement(mosaic.Select, { "aria-label": "Response Body Content Type", value: String(chosenContent), onChange: (value) => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" }))),
2199
- schema && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, viewMode: "read", hideExamples: true, parentCrumbs: ['responses', response.code], renderRootTreeLines: true }))))));
2202
+ schema && (React__namespace.createElement(jsonSchemaViewer.JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true }))))));
2200
2203
  };
2201
2204
  Response.displayName = 'HttpOperation.Response';
2202
2205
  const codeToIntentVal = (code) => {
@@ -2447,6 +2450,20 @@ const Logo = ({ logo }) => {
2447
2450
  React__namespace.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))) : (React__namespace.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))));
2448
2451
  };
2449
2452
 
2453
+ function getDisplayName(WrappedComponent) {
2454
+ return WrappedComponent.displayName || WrappedComponent.name || 'Component';
2455
+ }
2456
+
2457
+ const PersistenceContextProvider = jotai.Provider;
2458
+ function withPersistenceBoundary(WrappedComponent) {
2459
+ const WithPersistenceBoundary = props => {
2460
+ return (React__namespace.createElement(PersistenceContextProvider, null,
2461
+ React__namespace.createElement(WrappedComponent, Object.assign({}, props))));
2462
+ };
2463
+ WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
2464
+ return WithPersistenceBoundary;
2465
+ }
2466
+
2450
2467
  function useParsedValue(value) {
2451
2468
  return React__namespace.useMemo(() => {
2452
2469
  let parsedValue = value;
@@ -2491,7 +2508,8 @@ const CodeComponent = props => {
2491
2508
  if (!isObject__default["default"](parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
2492
2509
  return null;
2493
2510
  }
2494
- return (React__default["default"].createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true }));
2511
+ return (React__default["default"].createElement(PersistenceContextProvider, null,
2512
+ React__default["default"].createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true })));
2495
2513
  }
2496
2514
  const DefaultCode = markdownViewer.DefaultSMDComponents.code;
2497
2515
  return React__default["default"].createElement(DefaultCode, Object.assign({}, props));
@@ -2504,23 +2522,40 @@ function parseHttpRequest(data) {
2504
2522
  method: data.method,
2505
2523
  path: uri.is('absolute') ? uri.path() : data.url,
2506
2524
  servers: [{ url: uri.is('absolute') ? uri.origin() : data.baseUrl || '' }],
2507
- request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => ({
2508
- name: key,
2509
- style: types.HttpParamStyles.Form,
2510
- schema: { default: Array.isArray(value) && value.length > 0 ? value[0] : value },
2511
- })), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
2525
+ request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => {
2526
+ const defaultVal = Array.isArray(value) ? value[0] : value;
2527
+ return {
2528
+ name: key,
2529
+ style: types.HttpParamStyles.Form,
2530
+ schema: { default: defaultVal },
2531
+ required: isHttpRequestParamRequired(defaultVal),
2532
+ };
2533
+ }), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
2512
2534
  name: key,
2513
2535
  style: types.HttpParamStyles.Simple,
2514
2536
  schema: { default: value },
2537
+ required: isHttpRequestParamRequired(value),
2515
2538
  })), path: pathParam === null || pathParam === void 0 ? void 0 : pathParam.map(name => ({
2516
2539
  name,
2517
2540
  style: types.HttpParamStyles.Simple,
2518
2541
  required: true,
2519
2542
  })) }, (data.body
2520
- ? { body: { contents: [{ mediaType: 'application/json', schema: { default: data.body } }] } }
2543
+ ? {
2544
+ body: {
2545
+ contents: [
2546
+ {
2547
+ mediaType: 'application/json',
2548
+ schema: { default: data.body },
2549
+ },
2550
+ ],
2551
+ },
2552
+ }
2521
2553
  : null)),
2522
2554
  responses: [],
2523
2555
  };
2556
+ }
2557
+ function isHttpRequestParamRequired(value) {
2558
+ return typeof value !== 'undefined';
2524
2559
  }
2525
2560
 
2526
2561
  const MarkdownComponentsProvider = ({ value, children }) => {
@@ -2711,20 +2746,6 @@ const NonIdealState = ({ description, icon, title }) => {
2711
2746
  React__namespace.createElement(mosaic.Text, null, description)));
2712
2747
  };
2713
2748
 
2714
- function getDisplayName(WrappedComponent) {
2715
- return WrappedComponent.displayName || WrappedComponent.name || 'Component';
2716
- }
2717
-
2718
- const PersistenceContextProvider = jotai.Provider;
2719
- function withPersistenceBoundary(WrappedComponent) {
2720
- const WithPersistenceBoundary = props => {
2721
- return (React__namespace.createElement(PersistenceContextProvider, null,
2722
- React__namespace.createElement(WrappedComponent, Object.assign({}, props))));
2723
- };
2724
- WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
2725
- return WithPersistenceBoundary;
2726
- }
2727
-
2728
2749
  function withMosaicProvider(WrappedComponent) {
2729
2750
  const WithMosaicProvider = (props) => {
2730
2751
  try {
package/index.mjs CHANGED
@@ -477,7 +477,8 @@ const getServerUrlWithDefaultValues = (server) => {
477
477
  if (url.is('relative') && typeof window !== 'undefined') {
478
478
  url = url.absoluteTo(window.location.origin);
479
479
  }
480
- return url.toString();
480
+ const stringifiedUrl = url.toString();
481
+ return stringifiedUrl.endsWith('/') ? stringifiedUrl.slice(0, -1) : stringifiedUrl;
481
482
  };
482
483
 
483
484
  const persistAtom = (key, atomInstance) => {
@@ -986,7 +987,7 @@ const booleanOptions = [
986
987
  { label: 'True', value: 'true' },
987
988
  ];
988
989
  function enumOptions(enumValues, required) {
989
- const options = map(enumValues, v => ({ value: Number.isNaN(Number(v)) ? String(v) : Number(v) }));
990
+ const options = map(enumValues, v => ({ value: typeof v === 'number' ? v : String(v) }));
990
991
  return required ? options : [{ label: 'Not Set', value: '' }, ...options];
991
992
  }
992
993
  function parameterOptions(parameter) {
@@ -1315,7 +1316,9 @@ function buildFetchRequest({ httpOperation, mediaTypeContent, bodyInput, paramet
1315
1316
  const serverUrl = getServerUrl({ httpOperation, mockData, chosenServer, corsProxy });
1316
1317
  const shouldIncludeBody = ['PUT', 'POST', 'PATCH'].includes(httpOperation.method.toUpperCase());
1317
1318
  const queryParams = (_c = (_b = (_a = httpOperation.request) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.map(param => { var _a; return ({ name: param.name, value: (_a = parameterValues[param.name]) !== null && _a !== void 0 ? _a : '' }); }).filter(({ value }) => value.length > 0)) !== null && _c !== void 0 ? _c : [];
1318
- const rawHeaders = filterOutAuthorizationParams((_e = (_d = httpOperation.request) === null || _d === void 0 ? void 0 : _d.headers) !== null && _e !== void 0 ? _e : [], httpOperation.security).map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); });
1319
+ const rawHeaders = filterOutAuthorizationParams((_e = (_d = httpOperation.request) === null || _d === void 0 ? void 0 : _d.headers) !== null && _e !== void 0 ? _e : [], httpOperation.security)
1320
+ .map(header => { var _a; return ({ name: header.name, value: (_a = parameterValues[header.name]) !== null && _a !== void 0 ? _a : '' }); })
1321
+ .filter(({ value }) => value.length > 0);
1319
1322
  const [queryParamsWithAuth, headersWithAuth] = runAuthRequestEhancements(auth, queryParams, rawHeaders);
1320
1323
  const expandedPath = uriExpand(httpOperation.path, parameterValues);
1321
1324
  const url = new URL(URI(serverUrl).segment(expandedPath).toString());
@@ -2007,7 +2010,7 @@ const Body = ({ body, onChange }) => {
2007
2010
  React.createElement(SectionSubtitle, { title: "Body", id: "request-body" }, contents.length > 0 && (React.createElement(Flex, { flex: 1, justify: "end" },
2008
2011
  React.createElement(Select, { "aria-label": "Request Body Content Type", value: String(chosenContent), onChange: (value) => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" })))),
2009
2012
  description && React.createElement(MarkdownViewer, { markdown: description }),
2010
- isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, schema: getOriginalObject(schema), viewMode: "write", hideExamples: true, renderRootTreeLines: true }))));
2013
+ isJSONSchema(schema) && (React.createElement(JsonSchemaViewer, { resolveRef: refResolver, schema: getOriginalObject(schema), viewMode: "write", renderRootTreeLines: true }))));
2011
2014
  };
2012
2015
  Body.displayName = 'HttpOperation.Body';
2013
2016
 
@@ -2141,7 +2144,7 @@ const Response = ({ response, onMediaTypeChange }) => {
2141
2144
  React.createElement(SectionSubtitle, { title: "Body", id: "response-body" },
2142
2145
  React.createElement(Flex, { flex: 1, justify: "end" },
2143
2146
  React.createElement(Select, { "aria-label": "Response Body Content Type", value: String(chosenContent), onChange: (value) => setChosenContent(parseInt(String(value), 10)), options: contents.map((content, index) => ({ label: content.mediaType, value: index })), size: "sm" }))),
2144
- schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, viewMode: "read", hideExamples: true, parentCrumbs: ['responses', response.code], renderRootTreeLines: true }))))));
2147
+ schema && (React.createElement(JsonSchemaViewer, { schema: getOriginalObject(schema), resolveRef: refResolver, viewMode: "read", parentCrumbs: ['responses', response.code], renderRootTreeLines: true }))))));
2145
2148
  };
2146
2149
  Response.displayName = 'HttpOperation.Response';
2147
2150
  const codeToIntentVal = (code) => {
@@ -2392,6 +2395,20 @@ const Logo = ({ logo }) => {
2392
2395
  React.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))) : (React.createElement("img", { src: logo.url, height: "30px", width: "30px", alt: logo.altText }))));
2393
2396
  };
2394
2397
 
2398
+ function getDisplayName(WrappedComponent) {
2399
+ return WrappedComponent.displayName || WrappedComponent.name || 'Component';
2400
+ }
2401
+
2402
+ const PersistenceContextProvider = Provider;
2403
+ function withPersistenceBoundary(WrappedComponent) {
2404
+ const WithPersistenceBoundary = props => {
2405
+ return (React.createElement(PersistenceContextProvider, null,
2406
+ React.createElement(WrappedComponent, Object.assign({}, props))));
2407
+ };
2408
+ WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
2409
+ return WithPersistenceBoundary;
2410
+ }
2411
+
2395
2412
  function useParsedValue(value) {
2396
2413
  return React.useMemo(() => {
2397
2414
  let parsedValue = value;
@@ -2436,7 +2453,8 @@ const CodeComponent = props => {
2436
2453
  if (!isObject(parsedValue) || (!isPartialHttpRequest(parsedValue) && !isHttpOperation(parsedValue))) {
2437
2454
  return null;
2438
2455
  }
2439
- return (React__default.createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true }));
2456
+ return (React__default.createElement(PersistenceContextProvider, null,
2457
+ React__default.createElement(TryIt, { httpOperation: isHttpOperation(parsedValue) ? parsedValue : parseHttpRequest(parsedValue), embeddedInMd: true })));
2440
2458
  }
2441
2459
  const DefaultCode = DefaultSMDComponents.code;
2442
2460
  return React__default.createElement(DefaultCode, Object.assign({}, props));
@@ -2449,23 +2467,40 @@ function parseHttpRequest(data) {
2449
2467
  method: data.method,
2450
2468
  path: uri.is('absolute') ? uri.path() : data.url,
2451
2469
  servers: [{ url: uri.is('absolute') ? uri.origin() : data.baseUrl || '' }],
2452
- request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => ({
2453
- name: key,
2454
- style: HttpParamStyles.Form,
2455
- schema: { default: Array.isArray(value) && value.length > 0 ? value[0] : value },
2456
- })), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
2470
+ request: Object.assign({ query: Object.entries(data.query || {}).map(([key, value]) => {
2471
+ const defaultVal = Array.isArray(value) ? value[0] : value;
2472
+ return {
2473
+ name: key,
2474
+ style: HttpParamStyles.Form,
2475
+ schema: { default: defaultVal },
2476
+ required: isHttpRequestParamRequired(defaultVal),
2477
+ };
2478
+ }), headers: Object.entries(data.headers || {}).map(([key, value]) => ({
2457
2479
  name: key,
2458
2480
  style: HttpParamStyles.Simple,
2459
2481
  schema: { default: value },
2482
+ required: isHttpRequestParamRequired(value),
2460
2483
  })), path: pathParam === null || pathParam === void 0 ? void 0 : pathParam.map(name => ({
2461
2484
  name,
2462
2485
  style: HttpParamStyles.Simple,
2463
2486
  required: true,
2464
2487
  })) }, (data.body
2465
- ? { body: { contents: [{ mediaType: 'application/json', schema: { default: data.body } }] } }
2488
+ ? {
2489
+ body: {
2490
+ contents: [
2491
+ {
2492
+ mediaType: 'application/json',
2493
+ schema: { default: data.body },
2494
+ },
2495
+ ],
2496
+ },
2497
+ }
2466
2498
  : null)),
2467
2499
  responses: [],
2468
2500
  };
2501
+ }
2502
+ function isHttpRequestParamRequired(value) {
2503
+ return typeof value !== 'undefined';
2469
2504
  }
2470
2505
 
2471
2506
  const MarkdownComponentsProvider = ({ value, children }) => {
@@ -2656,20 +2691,6 @@ const NonIdealState = ({ description, icon, title }) => {
2656
2691
  React.createElement(Text, null, description)));
2657
2692
  };
2658
2693
 
2659
- function getDisplayName(WrappedComponent) {
2660
- return WrappedComponent.displayName || WrappedComponent.name || 'Component';
2661
- }
2662
-
2663
- const PersistenceContextProvider = Provider;
2664
- function withPersistenceBoundary(WrappedComponent) {
2665
- const WithPersistenceBoundary = props => {
2666
- return (React.createElement(PersistenceContextProvider, null,
2667
- React.createElement(WrappedComponent, Object.assign({}, props))));
2668
- };
2669
- WithPersistenceBoundary.displayName = `withPersistenceBoundary(${getDisplayName(WrappedComponent)})`;
2670
- return WithPersistenceBoundary;
2671
- }
2672
-
2673
2694
  function withMosaicProvider(WrappedComponent) {
2674
2695
  const WithMosaicProvider = (props) => {
2675
2696
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "7.5.2",
3
+ "version": "7.5.6",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",
@@ -31,9 +31,9 @@
31
31
  "@stoplight/json-schema-viewer": "^4.4.2",
32
32
  "@stoplight/markdown": "^3.1.1",
33
33
  "@stoplight/markdown-viewer": "^5.3.2",
34
- "@stoplight/mosaic": "^1.14.0",
35
- "@stoplight/mosaic-code-editor": "^1.14.0",
36
- "@stoplight/mosaic-code-viewer": "^1.14.0",
34
+ "@stoplight/mosaic": "^1.15.2",
35
+ "@stoplight/mosaic-code-editor": "^1.15.2",
36
+ "@stoplight/mosaic-code-viewer": "^1.15.2",
37
37
  "@stoplight/path": "^1.3.2",
38
38
  "@stoplight/react-error-boundary": "^2.0.0",
39
39
  "@stoplight/types": "^12.0.0",