@stoplight/elements-core 7.7.12 → 7.7.14

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.
@@ -3,7 +3,7 @@ export interface BodyProps {
3
3
  body: IHttpOperationRequestBody;
4
4
  onChange: (requestBodyIndex: number) => void;
5
5
  }
6
- export declare const isBodyEmpty: (body?: IHttpOperationRequestBody<false> | undefined) => boolean;
6
+ export declare const isBodyEmpty: (body?: BodyProps['body']) => boolean;
7
7
  export declare const Body: {
8
8
  ({ body, onChange }: BodyProps): JSX.Element | null;
9
9
  displayName: string;
@@ -9,5 +9,5 @@ interface HelperReturn<P extends Partial<DocsProps>> {
9
9
  createStory(name: string, input: Partial<P>): Story<P>;
10
10
  createHoistedStory(input: Partial<P>): Story<P>;
11
11
  }
12
- export declare const createStoriesForDocsComponent: <P extends Partial<DocsProps> = DocsProps>(Component: React.ComponentType<P>, title?: string | undefined) => HelperReturn<P>;
12
+ export declare const createStoriesForDocsComponent: <P extends Partial<DocsProps> = DocsProps>(Component: React.ComponentType<P>, title?: string) => HelperReturn<P>;
13
13
  export {};
@@ -1,2 +1,2 @@
1
1
  import { Request as HarFormatRequest } from 'har-format';
2
- export declare const convertRequestToSample: (language: string, library: string | undefined, request: HarFormatRequest) => string | null;
2
+ export declare const convertRequestToSample: (language: string, library: string | undefined, request: HarFormatRequest) => Promise<string | null>;
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  export declare type BodyParameterValues = Record<string, string | File>;
4
4
  export declare type ParameterOptional = Record<string, boolean>;
5
5
  export declare const isFormDataContent: (content: IMediaTypeContent) => boolean;
6
- export declare function createRequestBody(mediaTypeContent: IMediaTypeContent | undefined, bodyParameterValues: BodyParameterValues | undefined): Promise<string | Blob | ArrayBuffer | ArrayBufferView | FormData | ReadableStream<Uint8Array> | undefined>;
6
+ export declare function createRequestBody(mediaTypeContent: IMediaTypeContent | undefined, bodyParameterValues: BodyParameterValues | undefined): Promise<string | Blob | ArrayBuffer | ReadableStream<any> | ArrayBufferView | FormData | undefined>;
7
7
  export declare const useBodyParameterState: (mediaTypeContent: IMediaTypeContent | undefined) => readonly [BodyParameterValues, React.Dispatch<React.SetStateAction<BodyParameterValues>>, ParameterOptional, React.Dispatch<React.SetStateAction<ParameterOptional>>, {
8
8
  readonly isFormDataBody: true;
9
9
  readonly bodySpecification: IMediaTypeContent<false>;
@@ -28,6 +28,6 @@ export declare function mapSchemaPropertiesToParameters(properties: {
28
28
  schema: import("json-schema").JSONSchema7 | undefined;
29
29
  examples: {
30
30
  key: string;
31
- value: string | number | true | import("json-schema").JSONSchema7Object | import("json-schema").JSONSchema7Array;
31
+ value: any;
32
32
  }[] | undefined;
33
33
  }[];
@@ -4,7 +4,7 @@ interface RouterProps {
4
4
  basename?: string;
5
5
  location?: string;
6
6
  }
7
- export declare const useRouter: (router: RouterType, basePath: string, staticRouterPath?: string | undefined) => {
7
+ export declare const useRouter: (router: RouterType, basePath: string, staticRouterPath?: string) => {
8
8
  Router: React.ComponentType<{}>;
9
9
  routerProps: RouterProps;
10
10
  };
package/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { __rest, __awaiter } from 'tslib';
1
+ import { __awaiter, __rest } 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';
@@ -18,7 +18,7 @@ import { atomWithStorage, useAtomValue } from 'jotai/utils';
18
18
  import { atom, useAtom, Provider } from 'jotai';
19
19
  import URI from 'urijs';
20
20
  import { CodeViewer } from '@stoplight/mosaic-code-viewer';
21
- import HTTPSnippet from 'httpsnippet';
21
+ import { isValidTargetId, HTTPSnippet } from 'httpsnippet-lite';
22
22
  import flatten from 'lodash/flatten.js';
23
23
  import capitalize from 'lodash/capitalize.js';
24
24
  import filter from 'lodash/filter.js';
@@ -85,7 +85,7 @@ const recursivelyCreateResolvedObject = (currentObject, rootCurrentObject, prope
85
85
  resolvedValue = mergedOptions.resolver({ pointer: value.$ref, source: null }, newPropertyPath, rootCurrentObject);
86
86
  }
87
87
  catch (e) {
88
- resolvedValue = Object.assign(Object.assign({}, value), { $error: e.message });
88
+ resolvedValue = Object.assign(Object.assign({}, value), { $error: e instanceof Error ? e.message : String(e) });
89
89
  }
90
90
  }
91
91
  else {
@@ -537,16 +537,22 @@ const persistAtom = (key, atomInstance) => {
537
537
  });
538
538
  };
539
539
 
540
- const convertRequestToSample = (language, library, request) => {
540
+ const convertRequestToSample = (language, library, request) => __awaiter(void 0, void 0, void 0, function* () {
541
+ if (!isValidTargetId(language))
542
+ return null;
541
543
  try {
542
544
  const snippet = new HTTPSnippet(request);
543
- return snippet.convert(language, library) || null;
545
+ const converted = yield snippet.convert(language, library);
546
+ if (Array.isArray(converted)) {
547
+ return converted[0];
548
+ }
549
+ return converted || null;
544
550
  }
545
551
  catch (err) {
546
552
  console.error(err);
547
553
  return null;
548
554
  }
549
- };
555
+ });
550
556
 
551
557
  const requestSampleConfigs = {
552
558
  Shell: {
@@ -572,7 +578,7 @@ const requestSampleConfigs = {
572
578
  httpSnippetLibrary: 'fetch',
573
579
  },
574
580
  XMLHttpRequest: {
575
- httpSnippetLibrary: 'xmlhttprequest',
581
+ httpSnippetLibrary: 'xhr',
576
582
  },
577
583
  jQuery: {
578
584
  httpSnippetLibrary: 'jquery',
@@ -664,6 +670,11 @@ const requestSampleConfigs = {
664
670
  Http: {
665
671
  mosaicCodeViewerLanguage: 'http',
666
672
  httpSnippetLanguage: 'http',
673
+ libraries: {
674
+ 'Http1.1': {
675
+ httpSnippetLibrary: 'http1.1',
676
+ },
677
+ },
667
678
  },
668
679
  Clojure: {
669
680
  mosaicCodeViewerLanguage: 'clojure',
@@ -724,7 +735,24 @@ const RequestSamples = React__default.memo(({ request, embeddedInMd = false }) =
724
735
  const [selectedLanguage, setSelectedLanguage] = useAtom(selectedLanguageAtom);
725
736
  const [selectedLibrary, setSelectedLibrary] = useAtom(selectedLibraryAtom);
726
737
  const { httpSnippetLanguage, httpSnippetLibrary, mosaicCodeViewerLanguage } = getConfigFor(selectedLanguage, selectedLibrary);
727
- const requestSample = convertRequestToSample(httpSnippetLanguage, httpSnippetLibrary, request);
738
+ const [requestSample, setRequestSample] = React__default.useState(null);
739
+ React__default.useEffect(() => {
740
+ let isStale = false;
741
+ convertRequestToSample(httpSnippetLanguage, httpSnippetLibrary, request)
742
+ .then(example => {
743
+ if (!isStale) {
744
+ setRequestSample(example);
745
+ }
746
+ })
747
+ .catch(() => {
748
+ if (!isStale) {
749
+ setRequestSample(fallbackText);
750
+ }
751
+ });
752
+ return () => {
753
+ isStale = true;
754
+ };
755
+ }, [request, httpSnippetLanguage, httpSnippetLibrary]);
728
756
  const menuItems = useMemo(() => {
729
757
  const items = Object.entries(requestSampleConfigs).map(([language, config]) => {
730
758
  const hasLibraries = config.libraries && Object.keys(config.libraries).length > 0;
@@ -761,13 +789,12 @@ const RequestSamples = React__default.memo(({ request, embeddedInMd = false }) =
761
789
  selectedLanguage,
762
790
  " ",
763
791
  selectedLibrary ? ` / ${selectedLibrary}` : '')) }))),
764
- React__default.createElement(Panel.Content, { p: 0 },
765
- React__default.createElement(CodeViewer, { "aria-label": requestSample !== null && requestSample !== void 0 ? requestSample : fallbackText, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample || fallbackText, style: embeddedInMd
766
- ? undefined
767
- :
768
- {
769
- '--fs-code': 12,
770
- } }))));
792
+ React__default.createElement(Panel.Content, { p: 0 }, requestSample !== null && (React__default.createElement(CodeViewer, { "aria-label": requestSample, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample, style: embeddedInMd
793
+ ? undefined
794
+ :
795
+ {
796
+ '--fs-code': 12,
797
+ } })))));
771
798
  });
772
799
 
773
800
  function getReadableSecurityName(securityScheme, includeKey = false) {
@@ -1094,7 +1121,9 @@ const initialParameterValues = params => {
1094
1121
  return mapValues(paramsByName, param => getInitialValueForParameter(param));
1095
1122
  };
1096
1123
  function mapSchemaPropertiesToParameters(properties, required) {
1097
- return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples ? [{ key: 'example', value: schema.examples }] : undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
1124
+ return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples && schema.examples[0]
1125
+ ? [{ key: 'example', value: schema.examples[0] }]
1126
+ : undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
1098
1127
  }
1099
1128
 
1100
1129
  const ParameterEditor = ({ parameter, value, onChange, isOptional, onChangeOptional, canChangeOptional, validate, }) => {
package/index.js CHANGED
@@ -20,7 +20,7 @@ var utils = require('jotai/utils');
20
20
  var jotai = require('jotai');
21
21
  var URI = require('urijs');
22
22
  var mosaicCodeViewer = require('@stoplight/mosaic-code-viewer');
23
- var HTTPSnippet = require('httpsnippet');
23
+ var httpsnippetLite = require('httpsnippet-lite');
24
24
  var flatten = require('lodash/flatten.js');
25
25
  var capitalize = require('lodash/capitalize.js');
26
26
  var filter = require('lodash/filter.js');
@@ -77,7 +77,6 @@ var isPlainObject__default = /*#__PURE__*/_interopDefaultLegacy(isPlainObject);
77
77
  var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
78
78
  var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
79
79
  var URI__default = /*#__PURE__*/_interopDefaultLegacy(URI);
80
- var HTTPSnippet__default = /*#__PURE__*/_interopDefaultLegacy(HTTPSnippet);
81
80
  var flatten__default = /*#__PURE__*/_interopDefaultLegacy(flatten);
82
81
  var capitalize__default = /*#__PURE__*/_interopDefaultLegacy(capitalize);
83
82
  var filter__default = /*#__PURE__*/_interopDefaultLegacy(filter);
@@ -139,7 +138,7 @@ const recursivelyCreateResolvedObject = (currentObject, rootCurrentObject, prope
139
138
  resolvedValue = mergedOptions.resolver({ pointer: value.$ref, source: null }, newPropertyPath, rootCurrentObject);
140
139
  }
141
140
  catch (e) {
142
- resolvedValue = Object.assign(Object.assign({}, value), { $error: e.message });
141
+ resolvedValue = Object.assign(Object.assign({}, value), { $error: e instanceof Error ? e.message : String(e) });
143
142
  }
144
143
  }
145
144
  else {
@@ -591,16 +590,22 @@ const persistAtom = (key, atomInstance) => {
591
590
  });
592
591
  };
593
592
 
594
- const convertRequestToSample = (language, library, request) => {
593
+ const convertRequestToSample = (language, library, request) => tslib.__awaiter(void 0, void 0, void 0, function* () {
594
+ if (!httpsnippetLite.isValidTargetId(language))
595
+ return null;
595
596
  try {
596
- const snippet = new HTTPSnippet__default["default"](request);
597
- return snippet.convert(language, library) || null;
597
+ const snippet = new httpsnippetLite.HTTPSnippet(request);
598
+ const converted = yield snippet.convert(language, library);
599
+ if (Array.isArray(converted)) {
600
+ return converted[0];
601
+ }
602
+ return converted || null;
598
603
  }
599
604
  catch (err) {
600
605
  console.error(err);
601
606
  return null;
602
607
  }
603
- };
608
+ });
604
609
 
605
610
  const requestSampleConfigs = {
606
611
  Shell: {
@@ -626,7 +631,7 @@ const requestSampleConfigs = {
626
631
  httpSnippetLibrary: 'fetch',
627
632
  },
628
633
  XMLHttpRequest: {
629
- httpSnippetLibrary: 'xmlhttprequest',
634
+ httpSnippetLibrary: 'xhr',
630
635
  },
631
636
  jQuery: {
632
637
  httpSnippetLibrary: 'jquery',
@@ -718,6 +723,11 @@ const requestSampleConfigs = {
718
723
  Http: {
719
724
  mosaicCodeViewerLanguage: 'http',
720
725
  httpSnippetLanguage: 'http',
726
+ libraries: {
727
+ 'Http1.1': {
728
+ httpSnippetLibrary: 'http1.1',
729
+ },
730
+ },
721
731
  },
722
732
  Clojure: {
723
733
  mosaicCodeViewerLanguage: 'clojure',
@@ -778,7 +788,24 @@ const RequestSamples = React__default["default"].memo(({ request, embeddedInMd =
778
788
  const [selectedLanguage, setSelectedLanguage] = jotai.useAtom(selectedLanguageAtom);
779
789
  const [selectedLibrary, setSelectedLibrary] = jotai.useAtom(selectedLibraryAtom);
780
790
  const { httpSnippetLanguage, httpSnippetLibrary, mosaicCodeViewerLanguage } = getConfigFor(selectedLanguage, selectedLibrary);
781
- const requestSample = convertRequestToSample(httpSnippetLanguage, httpSnippetLibrary, request);
791
+ const [requestSample, setRequestSample] = React__default["default"].useState(null);
792
+ React__default["default"].useEffect(() => {
793
+ let isStale = false;
794
+ convertRequestToSample(httpSnippetLanguage, httpSnippetLibrary, request)
795
+ .then(example => {
796
+ if (!isStale) {
797
+ setRequestSample(example);
798
+ }
799
+ })
800
+ .catch(() => {
801
+ if (!isStale) {
802
+ setRequestSample(fallbackText);
803
+ }
804
+ });
805
+ return () => {
806
+ isStale = true;
807
+ };
808
+ }, [request, httpSnippetLanguage, httpSnippetLibrary]);
782
809
  const menuItems = React.useMemo(() => {
783
810
  const items = Object.entries(requestSampleConfigs).map(([language, config]) => {
784
811
  const hasLibraries = config.libraries && Object.keys(config.libraries).length > 0;
@@ -815,13 +842,12 @@ const RequestSamples = React__default["default"].memo(({ request, embeddedInMd =
815
842
  selectedLanguage,
816
843
  " ",
817
844
  selectedLibrary ? ` / ${selectedLibrary}` : '')) }))),
818
- React__default["default"].createElement(mosaic.Panel.Content, { p: 0 },
819
- React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": requestSample !== null && requestSample !== void 0 ? requestSample : fallbackText, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample || fallbackText, style: embeddedInMd
820
- ? undefined
821
- :
822
- {
823
- '--fs-code': 12,
824
- } }))));
845
+ React__default["default"].createElement(mosaic.Panel.Content, { p: 0 }, requestSample !== null && (React__default["default"].createElement(mosaicCodeViewer.CodeViewer, { "aria-label": requestSample, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample, style: embeddedInMd
846
+ ? undefined
847
+ :
848
+ {
849
+ '--fs-code': 12,
850
+ } })))));
825
851
  });
826
852
 
827
853
  function getReadableSecurityName(securityScheme, includeKey = false) {
@@ -1148,7 +1174,9 @@ const initialParameterValues = params => {
1148
1174
  return mapValues__default["default"](paramsByName, param => getInitialValueForParameter(param));
1149
1175
  };
1150
1176
  function mapSchemaPropertiesToParameters(properties, required) {
1151
- return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples ? [{ key: 'example', value: schema.examples }] : undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
1177
+ return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples && schema.examples[0]
1178
+ ? [{ key: 'example', value: schema.examples[0] }]
1179
+ : undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
1152
1180
  }
1153
1181
 
1154
1182
  const ParameterEditor = ({ parameter, value, onChange, isOptional, onChangeOptional, canChangeOptional, validate, }) => {
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { __rest, __awaiter } from 'tslib';
1
+ import { __awaiter, __rest } 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';
@@ -18,7 +18,7 @@ import { atomWithStorage, useAtomValue } from 'jotai/utils';
18
18
  import { atom, useAtom, Provider } from 'jotai';
19
19
  import URI from 'urijs';
20
20
  import { CodeViewer } from '@stoplight/mosaic-code-viewer';
21
- import HTTPSnippet from 'httpsnippet';
21
+ import { isValidTargetId, HTTPSnippet } from 'httpsnippet-lite';
22
22
  import flatten from 'lodash/flatten.js';
23
23
  import capitalize from 'lodash/capitalize.js';
24
24
  import filter from 'lodash/filter.js';
@@ -85,7 +85,7 @@ const recursivelyCreateResolvedObject = (currentObject, rootCurrentObject, prope
85
85
  resolvedValue = mergedOptions.resolver({ pointer: value.$ref, source: null }, newPropertyPath, rootCurrentObject);
86
86
  }
87
87
  catch (e) {
88
- resolvedValue = Object.assign(Object.assign({}, value), { $error: e.message });
88
+ resolvedValue = Object.assign(Object.assign({}, value), { $error: e instanceof Error ? e.message : String(e) });
89
89
  }
90
90
  }
91
91
  else {
@@ -537,16 +537,22 @@ const persistAtom = (key, atomInstance) => {
537
537
  });
538
538
  };
539
539
 
540
- const convertRequestToSample = (language, library, request) => {
540
+ const convertRequestToSample = (language, library, request) => __awaiter(void 0, void 0, void 0, function* () {
541
+ if (!isValidTargetId(language))
542
+ return null;
541
543
  try {
542
544
  const snippet = new HTTPSnippet(request);
543
- return snippet.convert(language, library) || null;
545
+ const converted = yield snippet.convert(language, library);
546
+ if (Array.isArray(converted)) {
547
+ return converted[0];
548
+ }
549
+ return converted || null;
544
550
  }
545
551
  catch (err) {
546
552
  console.error(err);
547
553
  return null;
548
554
  }
549
- };
555
+ });
550
556
 
551
557
  const requestSampleConfigs = {
552
558
  Shell: {
@@ -572,7 +578,7 @@ const requestSampleConfigs = {
572
578
  httpSnippetLibrary: 'fetch',
573
579
  },
574
580
  XMLHttpRequest: {
575
- httpSnippetLibrary: 'xmlhttprequest',
581
+ httpSnippetLibrary: 'xhr',
576
582
  },
577
583
  jQuery: {
578
584
  httpSnippetLibrary: 'jquery',
@@ -664,6 +670,11 @@ const requestSampleConfigs = {
664
670
  Http: {
665
671
  mosaicCodeViewerLanguage: 'http',
666
672
  httpSnippetLanguage: 'http',
673
+ libraries: {
674
+ 'Http1.1': {
675
+ httpSnippetLibrary: 'http1.1',
676
+ },
677
+ },
667
678
  },
668
679
  Clojure: {
669
680
  mosaicCodeViewerLanguage: 'clojure',
@@ -724,7 +735,24 @@ const RequestSamples = React__default.memo(({ request, embeddedInMd = false }) =
724
735
  const [selectedLanguage, setSelectedLanguage] = useAtom(selectedLanguageAtom);
725
736
  const [selectedLibrary, setSelectedLibrary] = useAtom(selectedLibraryAtom);
726
737
  const { httpSnippetLanguage, httpSnippetLibrary, mosaicCodeViewerLanguage } = getConfigFor(selectedLanguage, selectedLibrary);
727
- const requestSample = convertRequestToSample(httpSnippetLanguage, httpSnippetLibrary, request);
738
+ const [requestSample, setRequestSample] = React__default.useState(null);
739
+ React__default.useEffect(() => {
740
+ let isStale = false;
741
+ convertRequestToSample(httpSnippetLanguage, httpSnippetLibrary, request)
742
+ .then(example => {
743
+ if (!isStale) {
744
+ setRequestSample(example);
745
+ }
746
+ })
747
+ .catch(() => {
748
+ if (!isStale) {
749
+ setRequestSample(fallbackText);
750
+ }
751
+ });
752
+ return () => {
753
+ isStale = true;
754
+ };
755
+ }, [request, httpSnippetLanguage, httpSnippetLibrary]);
728
756
  const menuItems = useMemo(() => {
729
757
  const items = Object.entries(requestSampleConfigs).map(([language, config]) => {
730
758
  const hasLibraries = config.libraries && Object.keys(config.libraries).length > 0;
@@ -761,13 +789,12 @@ const RequestSamples = React__default.memo(({ request, embeddedInMd = false }) =
761
789
  selectedLanguage,
762
790
  " ",
763
791
  selectedLibrary ? ` / ${selectedLibrary}` : '')) }))),
764
- React__default.createElement(Panel.Content, { p: 0 },
765
- React__default.createElement(CodeViewer, { "aria-label": requestSample !== null && requestSample !== void 0 ? requestSample : fallbackText, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample || fallbackText, style: embeddedInMd
766
- ? undefined
767
- :
768
- {
769
- '--fs-code': 12,
770
- } }))));
792
+ React__default.createElement(Panel.Content, { p: 0 }, requestSample !== null && (React__default.createElement(CodeViewer, { "aria-label": requestSample, noCopyButton: true, maxHeight: "400px", language: mosaicCodeViewerLanguage, value: requestSample, style: embeddedInMd
793
+ ? undefined
794
+ :
795
+ {
796
+ '--fs-code': 12,
797
+ } })))));
771
798
  });
772
799
 
773
800
  function getReadableSecurityName(securityScheme, includeKey = false) {
@@ -1094,7 +1121,9 @@ const initialParameterValues = params => {
1094
1121
  return mapValues(paramsByName, param => getInitialValueForParameter(param));
1095
1122
  };
1096
1123
  function mapSchemaPropertiesToParameters(properties, required) {
1097
- return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples ? [{ key: 'example', value: schema.examples }] : undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
1124
+ return Object.entries(properties).map(([name, schema]) => (Object.assign({ name, schema: typeof schema !== 'boolean' ? schema : undefined, examples: typeof schema !== 'boolean' && schema.examples && schema.examples[0]
1125
+ ? [{ key: 'example', value: schema.examples[0] }]
1126
+ : undefined }, ((required === null || required === void 0 ? void 0 : required.includes(name)) && { required: true }))));
1098
1127
  }
1099
1128
 
1100
1129
  const ParameterEditor = ({ parameter, value, onChange, isOptional, onChangeOptional, canChangeOptional, validate, }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "7.7.12",
3
+ "version": "7.7.14",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",
@@ -38,7 +38,7 @@
38
38
  "@stoplight/types": "^13.7.0",
39
39
  "@stoplight/yaml": "^4.2.3",
40
40
  "classnames": "^2.2.6",
41
- "httpsnippet": "^2.0.0",
41
+ "httpsnippet-lite": "^3.0.1",
42
42
  "jotai": "1.3.9",
43
43
  "json-schema": "^0.4.0",
44
44
  "lodash": "^4.17.19",
@@ -6,8 +6,8 @@ declare type Example = {
6
6
  data: string;
7
7
  };
8
8
  export declare type GenerateExampleFromMediaTypeContentOptions = Sampler.Options;
9
- export declare const useGenerateExampleFromMediaTypeContent: (mediaTypeContent: IMediaTypeContent | undefined, chosenExampleIndex?: number | undefined, { skipReadOnly, skipWriteOnly, skipNonRequired, ticks }?: GenerateExampleFromMediaTypeContentOptions) => string;
10
- export declare const generateExampleFromMediaTypeContent: (mediaTypeContent: IMediaTypeContent | undefined, document: any, chosenExampleIndex?: number, options?: Sampler.Options | undefined) => string;
9
+ export declare const useGenerateExampleFromMediaTypeContent: (mediaTypeContent: IMediaTypeContent | undefined, chosenExampleIndex?: number, { skipReadOnly, skipWriteOnly, skipNonRequired, ticks }?: GenerateExampleFromMediaTypeContentOptions) => string;
10
+ export declare const generateExampleFromMediaTypeContent: (mediaTypeContent: IMediaTypeContent | undefined, document: any, chosenExampleIndex?: number, options?: GenerateExampleFromMediaTypeContentOptions) => string;
11
11
  export declare const generateExamplesFromJsonSchema: (schema: JSONSchema7) => Example[];
12
12
  export declare const exceedsSize: (example: string, size?: number) => boolean;
13
13
  export {};
@@ -1,3 +1,3 @@
1
1
  import type { IServer } from '@stoplight/types';
2
- export declare const getServersToDisplay: (originalServers: IServer[], mockUrl?: string | undefined) => IServer[];
2
+ export declare const getServersToDisplay: (originalServers: IServer[], mockUrl?: string) => IServer[];
3
3
  export declare const getServerUrlWithDefaultValues: (server: IServer) => string | null;