@scalar/workspace-store 0.68.4 → 0.68.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scalar/workspace-store
2
2
 
3
+ ## 0.68.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#10677](https://github.com/scalar/scalar/pull/10677): Generate serialized JSON examples from `contentSchema` instead of falling back to `null`, including JSON media type parameters, structured JSON suffixes, and string type arrays.
8
+
3
9
  ## 0.68.4
4
10
 
5
11
  ### Patch Changes
@@ -1 +1 @@
1
- {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAG5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAwZ9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,GACnC,QAAQ,YAAY,EACpB,YAAY,MAAM,EAAE,EACpB,UAAU,2BAA2B,EACrC,mBAAiB,EACjB,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,YAAY,GAAG,SAoBjB,CAAA;AAiaD,sEAAsE;AACtE,MAAM,MAAM,2BAA2B,GAAG;IACxC,2EAA2E;IAC3E,CAAC,kBAAkB,CAAC,CAAC,EAAE,sBAAsB,CAAA;IAC7C,mFAAmF;IACnF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kFAAkF;IAClF,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,qDAAqD;IACrD,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9C,CAAA;AAyPD;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,yBAAyB,GAC7B,QAAQ,YAAY,EACpB,UAAU,2BAA2B,EACrC,iEAOG,OAAO,CAAC;IACT,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACrB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,qGAAqG;IACrG,YAAY,EAAE,YAAY,CAAA;CAC3B,CAAM,KACN,OAgPF,CAAA;AAoBD,gGAAgG;AAChG,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,YAAY,EACpB,UAAU,2BAA2B,EACrC,UAAS,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAM,KAC5D,OA2BF,CAAA"}
1
+ {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAG5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAwZ9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,GACnC,QAAQ,YAAY,EACpB,YAAY,MAAM,EAAE,EACpB,UAAU,2BAA2B,EACrC,mBAA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AAM,KAC5D,OA2BF,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { isDefined } from '@scalar/helpers/array/is-defined';
2
+ import { isJsonMediaType } from '@scalar/helpers/http/is-json-media-type';
2
3
  import { escapeJsonPointer } from '@scalar/helpers/json/escape-json-pointer';
3
4
  import { isDynamicRef, pushDynamicScope, resolveDynamicRef } from '../../../helpers/dynamic-ref.js';
4
5
  import { unpackProxyObject } from '../../../helpers/unpack-proxy.js';
@@ -881,6 +882,13 @@ const getMaxDepthValue = (schema, options, schemaPath, seen = new Set()) => {
881
882
  truncated = true;
882
883
  return MAX_DEPTH_EXCEEDED;
883
884
  };
885
+ const hasUnencodedJsonContent = (schema) => {
886
+ if (!('contentSchema' in schema) || !isJsonMediaType(schema.contentMediaType))
887
+ return false;
888
+ if ('contentEncoding' in schema)
889
+ return false;
890
+ return !('type' in schema) || getDeclaredTypes(schema).includes('string');
891
+ };
884
892
  /**
885
893
  * Generate an example value from a given OpenAPI SchemaObject.
886
894
  *
@@ -1005,7 +1013,13 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1005
1013
  if (selectedComposition && selectedVariant) {
1006
1014
  const rootType = 'type' in _schema ? _schema.type : undefined;
1007
1015
  const variantType = 'type' in selectedVariant ? selectedVariant.type : undefined;
1008
- const selectedType = variantType ?? rootType ?? ('items' in _schema && !('properties' in _schema) ? 'array' : undefined);
1016
+ const selectedType = variantType ??
1017
+ rootType ??
1018
+ (hasUnencodedJsonContent(_schema)
1019
+ ? 'string'
1020
+ : 'items' in _schema && !('properties' in _schema)
1021
+ ? 'array'
1022
+ : undefined);
1009
1023
  if (selectedType !== undefined && selectedType !== 'object') {
1010
1024
  const { oneOf: _oneOf, anyOf: _anyOf, ...base } = _schema;
1011
1025
  const selectedSchema = { ...base, ...selectedVariant };
@@ -1028,6 +1042,25 @@ const generateExampleFromSchema = (schema, options, { level = 0, parentSchema, n
1028
1042
  return cache(_schema, result, cacheKey, skipCache);
1029
1043
  }
1030
1044
  }
1045
+ if (hasUnencodedJsonContent(_schema)) {
1046
+ const contentSchema = resolve.schema(_schema.contentSchema);
1047
+ if (contentSchema) {
1048
+ // JSON content preserves strings and property names regardless of the enclosing wire format.
1049
+ const content = getExampleFromSchema(contentSchema, { ...options, xml: false, binaryAsFile: false }, {
1050
+ level: level + 1,
1051
+ // The decoded value inherits the field requirement, not the string wrapper as a parent.
1052
+ parentSchema,
1053
+ name,
1054
+ schemaPath: [...schemaPath, 'contentSchema'],
1055
+ seen,
1056
+ dynamicScope: childScope,
1057
+ });
1058
+ if (content !== undefined) {
1059
+ seen.delete(targetValue);
1060
+ return cache(_schema, JSON.stringify(content), cacheKey, skipCache);
1061
+ }
1062
+ }
1063
+ }
1031
1064
  // Handle object types - check for properties to identify objects
1032
1065
  if ('properties' in _schema || ('type' in _schema && _schema.type === 'object')) {
1033
1066
  const result = handleObjectSchema(_schema, options, level, seen, cacheKey, schemaPath, dynamicScope);
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "openapi",
17
17
  "scalar"
18
18
  ],
19
- "version": "0.68.4",
19
+ "version": "0.68.5",
20
20
  "engines": {
21
21
  "node": ">=22"
22
22
  },
@@ -155,10 +155,10 @@
155
155
  "dependencies": {
156
156
  "@scalar/asyncapi-upgrader": "0.1.18",
157
157
  "@scalar/helpers": "0.16.4",
158
- "@scalar/json-magic": "0.16.0",
158
+ "@scalar/json-magic": "0.16.1",
159
159
  "@scalar/openapi-upgrader": "0.4.5",
160
160
  "@scalar/schemas": "0.14.0",
161
- "@scalar/snippetz": "0.10.9",
161
+ "@scalar/snippetz": "0.10.10",
162
162
  "@scalar/typebox": "0.1.3",
163
163
  "@scalar/types": "0.24.0",
164
164
  "@scalar/validation": "0.6.7",