@scalar/schemas 0.7.0 → 0.7.1

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/schemas
2
2
 
3
+ ## 0.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#9626](https://github.com/scalar/scalar/pull/9626): Fix AsyncAPI security scheme types being lost on ingestion. When a server referenced a scheme via `$ref`, coercion synthesized a default `$ref-value` (the first `type` literal, `userPassword`) that leaked back over the real definition through the resolved-document proxy, so every scheme rendered as `userPassword`. Reference `$ref-value` is now optional, so unresolved references pass through untouched.
8
+
3
9
  ## 0.7.0
4
10
 
5
11
  ### Minor Changes
@@ -18,6 +18,12 @@ export declare const asyncApiReferenceObject: import("@scalar/validation").Objec
18
18
  *
19
19
  * Use when the specification allows only a Reference Object (not an inline object), for example
20
20
  * `operation.channel` or `channel.servers`.
21
+ *
22
+ * `$ref-value` is a resolved-document extension populated by the bundler/proxy at access time, so it
23
+ * is optional here. If coercion required it, an unresolved `{ $ref }` would be filled with a default
24
+ * instance of `schema` (for a security scheme, the first `type` literal — `userPassword`). Because the
25
+ * magic proxy shares one target object between a `$ref-value` and the component it points at, that
26
+ * synthetic default then leaks back over the real definition, clobbering its `type`.
21
27
  */
22
28
  export declare const asyncApiResolvedReference: (schema: Schema) => Schema;
23
29
  /** Inline object or Reference Object with resolved `$ref-value`. */
@@ -1 +1 @@
1
- {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/asyncapi/3.1/reference.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAiD,MAAM,oBAAoB,CAAA;AAI/F;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;AAElD;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;EAKnC,CAAA;AAUD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,KAAG,MACkD,CAAA;AAE7G,oEAAoE;AACpE,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MAA4D,CAAA"}
1
+ {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../src/asyncapi/3.1/reference.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAA2D,MAAM,oBAAoB,CAAA;AAIzG;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAA;AAElD;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;EAKnC,CAAA;AAUD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,KAAG,MAC4D,CAAA;AAEvH,oEAAoE;AACpE,eAAO,MAAM,YAAY,GAAI,QAAQ,MAAM,KAAG,MAA4D,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { isObject } from '@scalar/helpers/object/is-object';
2
- import { evaluate, intersection, object, string, union } from '@scalar/validation';
2
+ import { evaluate, intersection, object, optional, string, union } from '@scalar/validation';
3
3
  import { referenceExtensions } from '../../general/bundler-extensions.js';
4
4
  /**
5
5
  * AsyncAPI Reference Object (JSON Reference). Only `$ref` is defined; additional
@@ -19,7 +19,13 @@ const e = (value) => {
19
19
  *
20
20
  * Use when the specification allows only a Reference Object (not an inline object), for example
21
21
  * `operation.channel` or `channel.servers`.
22
+ *
23
+ * `$ref-value` is a resolved-document extension populated by the bundler/proxy at access time, so it
24
+ * is optional here. If coercion required it, an unresolved `{ $ref }` would be filled with a default
25
+ * instance of `schema` (for a security scheme, the first `type` literal — `userPassword`). Because the
26
+ * magic proxy shares one target object between a `$ref-value` and the component it points at, that
27
+ * synthetic default then leaks back over the real definition, clobbering its `type`.
22
28
  */
23
- export const asyncApiResolvedReference = (schema) => intersection([asyncApiReferenceObject, object({ '$ref-value': evaluate(e, schema) }), referenceExtensions]);
29
+ export const asyncApiResolvedReference = (schema) => intersection([asyncApiReferenceObject, object({ '$ref-value': optional(evaluate(e, schema)) }), referenceExtensions]);
24
30
  /** Inline object or Reference Object with resolved `$ref-value`. */
25
31
  export const recursiveRef = (schema) => union([schema, asyncApiResolvedReference(schema)]);
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "schemas",
15
15
  "scalar"
16
16
  ],
17
- "version": "0.7.0",
17
+ "version": "0.7.1",
18
18
  "engines": {
19
19
  "node": ">=22"
20
20
  },
@@ -41,12 +41,12 @@
41
41
  "CHANGELOG.md"
42
42
  ],
43
43
  "dependencies": {
44
- "@scalar/helpers": "0.9.0",
45
- "@scalar/validation": "0.6.0"
44
+ "@scalar/validation": "0.6.0",
45
+ "@scalar/helpers": "0.9.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "vitest": "4.1.0",
49
- "@scalar/types": "0.16.0"
49
+ "@scalar/types": "0.16.1"
50
50
  },
51
51
  "scripts": {
52
52
  "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",