oas-truth 0.5.0 → 0.6.0

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/README.md CHANGED
@@ -36,7 +36,7 @@ dependency order. `makeSchemaDeclarations` returns the same declarations one by
36
36
 
37
37
  Recursive `$ref` cycles keep a helper type so the const can be annotated (`z.ZodType<NodeType>`,
38
38
  `v.GenericSchema<NodeType>`, `Schema.Codec<NodeType>`). That helper matches what the library
39
- infers — `| undefined` on Valibot and Effect optionals, `readonly` arrays on Effect — so it
39
+ infers — `| undefined` on Valibot optionals, `readonly` arrays on Effect — so it
40
40
  type-checks under `exactOptionalPropertyTypes`. Arktype cycles become
41
41
  `scope({...}).export().Member`; that declaration's `importLine` is then
42
42
  `import { type, scope } from 'arktype'`. `schemaImportLine` is the same function
package/dist/index.d.ts CHANGED
@@ -499,7 +499,7 @@ export type Callbacks = {
499
499
  };
500
500
  /**
501
501
  * Where a value arrives as text: an OpenAPI parameter location, or `formData` for a field of
502
- * a form body. schema-to-library coerces the value from text for every one of them.
502
+ * a form body. schema-truth coerces the value from text for every one of them.
503
503
  */
504
504
  export type ParamIn = 'query' | 'path' | 'header' | 'cookie' | 'formData';
505
505
  /**
@@ -508,7 +508,7 @@ export type ParamIn = 'query' | 'path' | 'header' | 'cookie' | 'formData';
508
508
  * @see https://spec.openapis.org/oas/v3.2.0.html#style-values
509
509
  */
510
510
  export type ParamStyle = 'matrix' | 'label' | 'simple' | 'form' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
511
- /** Narrow a Parameter Object's free-form `style` to one schema-to-library reads. */
511
+ /** Narrow a Parameter Object's free-form `style` to one schema-truth reads. */
512
512
  export declare function isParamStyle(style: string): style is ParamStyle;
513
513
  export type SchemaLib = 'zod' | 'valibot' | 'arktype' | 'effect' | 'typebox';
514
514
  /**
@@ -597,7 +597,7 @@ export declare function toPascalCase(str: string): string;
597
597
  export declare function schemaRefToName(ref: string): string;
598
598
  /**
599
599
  * Convert a name to a valid PascalCase TypeScript identifier. Mirrors
600
- * schema-to-library's `toIdentifierPascalCase` so reference identifiers match
600
+ * schema-truth's `toIdentifierPascalCase` so reference identifiers match
601
601
  * the component declaration names it emits. Non-ASCII names are encoded
602
602
  * injectively so distinct names never collide.
603
603
  */
@@ -681,7 +681,7 @@ type SchemasOptions = {
681
681
  readonly wrapDeclaration?: (expr: string, name: string) => string;
682
682
  /**
683
683
  * Register the OpenAPI key on each declaration. TypeBox puts it in the
684
- * outermost builder options via schema-to-library; the other libraries use
684
+ * outermost builder options via schema-truth; the other libraries use
685
685
  * `adapter.withRef` (an outer wrap). A bare identifier is left unchanged.
686
686
  */
687
687
  readonly ref?: boolean;
package/dist/index.js CHANGED
@@ -2,11 +2,11 @@ import path from "node:path";
2
2
  import SwaggerParser from "@apidevtools/swagger-parser";
3
3
  import { NodeHost, compile } from "@typespec/compiler";
4
4
  import { getOpenAPI3 } from "@typespec/openapi3";
5
- import { schemaToArktype } from "schema-to-library/arktype";
6
- import { schemaToEffect } from "schema-to-library/effect";
7
- import { schemaToTypebox } from "schema-to-library/typebox";
8
- import { schemaToValibot } from "schema-to-library/valibot";
9
- import { schemaToZod } from "schema-to-library/zod";
5
+ import { schemaToArktype } from "schema-truth/arktype";
6
+ import { schemaToEffect } from "schema-truth/effect";
7
+ import { schemaToTypebox } from "schema-truth/typebox";
8
+ import { schemaToValibot } from "schema-truth/valibot";
9
+ import { schemaToZod } from "schema-truth/zod";
10
10
  // src/openapi/index.ts
11
11
  async function parseOpenAPI(input) {
12
12
  try {
@@ -44,7 +44,7 @@ const PARAM_STYLES = [
44
44
  "pipeDelimited",
45
45
  "deepObject"
46
46
  ];
47
- /** Narrow a Parameter Object's free-form `style` to one schema-to-library reads. */
47
+ /** Narrow a Parameter Object's free-form `style` to one schema-truth reads. */
48
48
  function isParamStyle(style) {
49
49
  return PARAM_STYLES.includes(style);
50
50
  }
@@ -53,14 +53,14 @@ function isBareIdent(expr) {
53
53
  return /^[A-Za-z_$][\w$]*$/u.test(expr);
54
54
  }
55
55
  /**
56
- * Widen the rich `Schema` type to a bare JSON-Schema object for schema-to-library.
56
+ * Widen the rich `Schema` type to a bare JSON-Schema object for schema-truth.
57
57
  * `Schema` is not structurally assignable to its `JSONSchema` (e.g. `x-emailPattern`
58
58
  * literal unions differ), so this `as`-free bridge erases the incompatible members.
59
59
  */
60
60
  function toJsonSchema(schema) {
61
61
  return schema;
62
62
  }
63
- /** The wire options schema-to-library reads, without an `undefined` member. */
63
+ /** The wire options schema-truth reads, without an `undefined` member. */
64
64
  function wireOptions(paramIn, options) {
65
65
  return {
66
66
  ...paramIn && { paramIn },
@@ -234,10 +234,7 @@ function makeEffectAdapter() {
234
234
  cyclicAnnotation(typeName) {
235
235
  return `Schema.Codec<${typeName}>`;
236
236
  },
237
- cyclicTypeStyle: {
238
- optionalUndefined: true,
239
- readonlyArrays: true
240
- },
237
+ cyclicTypeStyle: { readonlyArrays: true },
241
238
  reservedTypeNames: ["Schema", "Effect"],
242
239
  withRef(expr, ref) {
243
240
  return isBareIdent(expr) ? expr : `${expr}.annotate({identifier:${JSON.stringify(ref)}})`;
@@ -280,7 +277,7 @@ function encodeNonAscii(name) {
280
277
  }
281
278
  /**
282
279
  * Convert a name to a valid PascalCase TypeScript identifier. Mirrors
283
- * schema-to-library's `toIdentifierPascalCase` so reference identifiers match
280
+ * schema-truth's `toIdentifierPascalCase` so reference identifiers match
284
281
  * the component declaration names it emits. Non-ASCII names are encoded
285
282
  * injectively so distinct names never collide.
286
283
  */
@@ -819,7 +816,7 @@ function mapSchema(schema, fn) {
819
816
  }
820
817
  /**
821
818
  * `readonly` as the declarative `x-readonly` extension on every object and array,
822
- * which schema-to-library turns into each library's readonly form.
819
+ * which schema-truth turns into each library's readonly form.
823
820
  */
824
821
  function markReadonly(schema) {
825
822
  return mapSchema(schema, (node) => {
@@ -833,7 +830,7 @@ function markReadonly(schema) {
833
830
  /**
834
831
  * TypeBox and Arktype cannot express a cycle with standalone `const`s: the group
835
832
  * becomes one `Type.Cyclic(...)` / `scope(...)` container and each member selects
836
- * its entry. schema-to-library builds the container from a `$defs` document.
833
+ * its entry. schema-truth builds the container from a `$defs` document.
837
834
  */
838
835
  function rewriteCollisionRef(node, identifiers) {
839
836
  if (typeof node.$ref !== "string" || !node.$ref.startsWith("#/components/schemas/")) return node;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oas-truth",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "oas-truth is a parser from OpenAPI and TypeSpec to a typed OpenAPI document",
5
5
  "keywords": [
6
6
  "openapi",
@@ -28,7 +28,7 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "schema-to-library": "^0.7.0"
31
+ "schema-truth": "^0.8.3"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@apidevtools/swagger-parser": "^13.1.0",
@@ -40,7 +40,7 @@
40
40
  "@typespec/rest": "0.87.0",
41
41
  "@typespec/versioning": "0.87.0",
42
42
  "arktype": "^2.2.9",
43
- "effect": "4.0.6",
43
+ "effect": "4.1.1",
44
44
  "typebox": "^1.4.3",
45
45
  "typescript": "^7.0.2",
46
46
  "valibot": "^1.5.0",