@stoplight/elements-core 9.0.25-beta-0.3 → 9.0.25-beta-0.4

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/index.esm.js CHANGED
@@ -2641,6 +2641,12 @@ const ServerVariables = ({ variables, values, onChangeValue }) => {
2641
2641
  };
2642
2642
 
2643
2643
  const defaultServers = [];
2644
+ const findResponseForStatus = (httpOperation, status) => {
2645
+ var _a, _b;
2646
+ const statusCode = String(status);
2647
+ const statusRange = `${Math.floor(status / 100)}XX`;
2648
+ return ((_b = (_a = httpOperation.responses.find(({ code }) => code === statusCode)) !== null && _a !== void 0 ? _a : httpOperation.responses.find(({ code }) => code.toUpperCase() === statusRange)) !== null && _b !== void 0 ? _b : httpOperation.responses.find(({ code }) => code === 'default'));
2649
+ };
2644
2650
  const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embeddedInMd = false, hideTryItPanel = false, tryItCredentialsPolicy, corsProxy, }) => {
2645
2651
  var _a, _b, _c, _d, _e, _f;
2646
2652
  TryIt.displayName = 'TryIt';
@@ -2758,8 +2764,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2758
2764
  let skipBodyParsing = false;
2759
2765
  if (mockData && type === 'json' && bodyText) {
2760
2766
  const responseMediaType = contentType === null || contentType === void 0 ? void 0 : contentType.split(';')[0];
2761
- const responseSchema = (_j = (_h = (_g = httpOperation.responses
2762
- .find(({ code }) => code === String(response === null || response === void 0 ? void 0 : response.status))) === null || _g === void 0 ? void 0 : _g.contents) === null || _h === void 0 ? void 0 : _h.find(({ mediaType }) => mediaType === responseMediaType)) === null || _j === void 0 ? void 0 : _j.schema;
2767
+ const responseSchema = (_j = (_h = (_g = findResponseForStatus(httpOperation, response.status)) === null || _g === void 0 ? void 0 : _g.contents) === null || _h === void 0 ? void 0 : _h.find(({ mediaType }) => mediaType === responseMediaType)) === null || _j === void 0 ? void 0 : _j.schema;
2763
2768
  if (responseSchema) {
2764
2769
  try {
2765
2770
  bodyText = stringifyExampleWithResolvedSchema(JSON.parse(bodyText), responseSchema);
package/index.js CHANGED
@@ -2662,6 +2662,12 @@ const ServerVariables = ({ variables, values, onChangeValue }) => {
2662
2662
  };
2663
2663
 
2664
2664
  const defaultServers = [];
2665
+ const findResponseForStatus = (httpOperation, status) => {
2666
+ var _a, _b;
2667
+ const statusCode = String(status);
2668
+ const statusRange = `${Math.floor(status / 100)}XX`;
2669
+ return ((_b = (_a = httpOperation.responses.find(({ code }) => code === statusCode)) !== null && _a !== void 0 ? _a : httpOperation.responses.find(({ code }) => code.toUpperCase() === statusRange)) !== null && _b !== void 0 ? _b : httpOperation.responses.find(({ code }) => code === 'default'));
2670
+ };
2665
2671
  const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embeddedInMd = false, hideTryItPanel = false, tryItCredentialsPolicy, corsProxy, }) => {
2666
2672
  var _a, _b, _c, _d, _e, _f;
2667
2673
  TryIt.displayName = 'TryIt';
@@ -2779,8 +2785,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2779
2785
  let skipBodyParsing = false;
2780
2786
  if (mockData && type === 'json' && bodyText) {
2781
2787
  const responseMediaType = contentType === null || contentType === void 0 ? void 0 : contentType.split(';')[0];
2782
- const responseSchema = (_j = (_h = (_g = httpOperation.responses
2783
- .find(({ code }) => code === String(response === null || response === void 0 ? void 0 : response.status))) === null || _g === void 0 ? void 0 : _g.contents) === null || _h === void 0 ? void 0 : _h.find(({ mediaType }) => mediaType === responseMediaType)) === null || _j === void 0 ? void 0 : _j.schema;
2788
+ const responseSchema = (_j = (_h = (_g = findResponseForStatus(httpOperation, response.status)) === null || _g === void 0 ? void 0 : _g.contents) === null || _h === void 0 ? void 0 : _h.find(({ mediaType }) => mediaType === responseMediaType)) === null || _j === void 0 ? void 0 : _j.schema;
2784
2789
  if (responseSchema) {
2785
2790
  try {
2786
2791
  bodyText = stringifyExampleWithResolvedSchema(JSON.parse(bodyText), responseSchema);
package/index.mjs CHANGED
@@ -2641,6 +2641,12 @@ const ServerVariables = ({ variables, values, onChangeValue }) => {
2641
2641
  };
2642
2642
 
2643
2643
  const defaultServers = [];
2644
+ const findResponseForStatus = (httpOperation, status) => {
2645
+ var _a, _b;
2646
+ const statusCode = String(status);
2647
+ const statusRange = `${Math.floor(status / 100)}XX`;
2648
+ return ((_b = (_a = httpOperation.responses.find(({ code }) => code === statusCode)) !== null && _a !== void 0 ? _a : httpOperation.responses.find(({ code }) => code.toUpperCase() === statusRange)) !== null && _b !== void 0 ? _b : httpOperation.responses.find(({ code }) => code === 'default'));
2649
+ };
2644
2650
  const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embeddedInMd = false, hideTryItPanel = false, tryItCredentialsPolicy, corsProxy, }) => {
2645
2651
  var _a, _b, _c, _d, _e, _f;
2646
2652
  TryIt.displayName = 'TryIt';
@@ -2758,8 +2764,7 @@ const TryIt = ({ httpOperation, mockUrl, onRequestChange, requestBodyIndex, embe
2758
2764
  let skipBodyParsing = false;
2759
2765
  if (mockData && type === 'json' && bodyText) {
2760
2766
  const responseMediaType = contentType === null || contentType === void 0 ? void 0 : contentType.split(';')[0];
2761
- const responseSchema = (_j = (_h = (_g = httpOperation.responses
2762
- .find(({ code }) => code === String(response === null || response === void 0 ? void 0 : response.status))) === null || _g === void 0 ? void 0 : _g.contents) === null || _h === void 0 ? void 0 : _h.find(({ mediaType }) => mediaType === responseMediaType)) === null || _j === void 0 ? void 0 : _j.schema;
2767
+ const responseSchema = (_j = (_h = (_g = findResponseForStatus(httpOperation, response.status)) === null || _g === void 0 ? void 0 : _g.contents) === null || _h === void 0 ? void 0 : _h.find(({ mediaType }) => mediaType === responseMediaType)) === null || _j === void 0 ? void 0 : _j.schema;
2763
2768
  if (responseSchema) {
2764
2769
  try {
2765
2770
  bodyText = stringifyExampleWithResolvedSchema(JSON.parse(bodyText), responseSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoplight/elements-core",
3
- "version": "9.0.25-beta-0.3",
3
+ "version": "9.0.25-beta-0.4",
4
4
  "main": "./index.js",
5
5
  "sideEffects": [
6
6
  "web-components.min.js",