openapi-typesafe 1.0.0-rc.2 → 1.0.0-rc.3
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/dist/adapters/node-deprecations/node-deprecations.cjs +14 -0
- package/dist/adapters/node-deprecations/node-deprecations.cjs.map +1 -0
- package/dist/adapters/node-deprecations/node-deprecations.mjs +12 -0
- package/dist/adapters/node-deprecations/node-deprecations.mjs.map +1 -0
- package/dist/api/default-ports.cjs +5 -0
- package/dist/api/default-ports.cjs.map +1 -1
- package/dist/api/default-ports.mjs +5 -1
- package/dist/api/default-ports.mjs.map +1 -1
- package/dist/api/discriminator-conflict-warnings.cjs +1 -1
- package/dist/api/discriminator-conflict-warnings.cjs.map +1 -1
- package/dist/api/discriminator-conflict-warnings.mjs +2 -2
- package/dist/api/discriminator-conflict-warnings.mjs.map +1 -1
- package/dist/api/discriminator-patch.cjs +3 -3
- package/dist/api/discriminator-patch.cjs.map +1 -1
- package/dist/api/discriminator-patch.mjs +4 -4
- package/dist/api/discriminator-patch.mjs.map +1 -1
- package/dist/api/discriminator-scan.cjs +2 -2
- package/dist/api/discriminator-scan.cjs.map +1 -1
- package/dist/api/discriminator-scan.mjs +3 -3
- package/dist/api/discriminator-scan.mjs.map +1 -1
- package/dist/api/document-run.cjs +2 -1
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +2 -1
- package/dist/api/document-run.mjs.map +1 -1
- package/dist/api/legacy-callback-warning.cjs +7 -4
- package/dist/api/legacy-callback-warning.cjs.map +1 -1
- package/dist/api/legacy-callback-warning.mjs +8 -5
- package/dist/api/legacy-callback-warning.mjs.map +1 -1
- package/dist/api/openapi-ts.cjs +1 -1
- package/dist/api/openapi-ts.cjs.map +1 -1
- package/dist/api/openapi-ts.mjs +2 -2
- package/dist/api/openapi-ts.mjs.map +1 -1
- package/dist/api/string-to-ast.cjs +7 -9
- package/dist/api/string-to-ast.cjs.map +1 -1
- package/dist/api/string-to-ast.mjs +8 -9
- package/dist/api/string-to-ast.mjs.map +1 -1
- package/dist/api/transform-schema.cjs +2 -2
- package/dist/api/transform-schema.cjs.map +1 -1
- package/dist/api/transform-schema.mjs +3 -3
- package/dist/api/transform-schema.mjs.map +1 -1
- package/dist/application/transform/document/components.cjs +1 -1
- package/dist/application/transform/document/components.cjs.map +1 -1
- package/dist/application/transform/document/components.mjs +2 -2
- package/dist/application/transform/document/components.mjs.map +1 -1
- package/dist/application/transform/document/parameters.cjs +1 -1
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +2 -2
- package/dist/application/transform/document/parameters.mjs.map +1 -1
- package/dist/application/transform/document/paths.cjs +1 -1
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +2 -2
- package/dist/application/transform/document/paths.mjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.cjs +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.cjs.map +1 -1
- package/dist/application/transform/ref-pointer/pointer-type.mjs +2 -2
- package/dist/application/transform/ref-pointer/pointer-type.mjs.map +1 -1
- package/dist/application/transform/schema/access-flags.cjs +1 -1
- package/dist/application/transform/schema/access-flags.cjs.map +1 -1
- package/dist/application/transform/schema/access-flags.mjs +2 -2
- package/dist/application/transform/schema/access-flags.mjs.map +1 -1
- package/dist/application/transform/schema/array-type.cjs +2 -2
- package/dist/application/transform/schema/array-type.cjs.map +1 -1
- package/dist/application/transform/schema/array-type.mjs +3 -3
- package/dist/application/transform/schema/array-type.mjs.map +1 -1
- package/dist/application/transform/schema/composition-type.cjs +3 -3
- package/dist/application/transform/schema/composition-type.cjs.map +1 -1
- package/dist/application/transform/schema/composition-type.mjs +4 -4
- package/dist/application/transform/schema/composition-type.mjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.cjs +3 -5
- package/dist/application/transform/schema/enum-rule.cjs.map +1 -1
- package/dist/application/transform/schema/enum-rule.mjs +4 -6
- package/dist/application/transform/schema/enum-rule.mjs.map +1 -1
- package/dist/application/transform/schema/presence-members.cjs +1 -1
- package/dist/application/transform/schema/presence-members.cjs.map +1 -1
- package/dist/application/transform/schema/presence-members.mjs +2 -2
- package/dist/application/transform/schema/presence-members.mjs.map +1 -1
- package/dist/application/transform/schema/required-variants.cjs +2 -2
- package/dist/application/transform/schema/required-variants.cjs.map +1 -1
- package/dist/application/transform/schema/required-variants.mjs +3 -3
- package/dist/application/transform/schema/required-variants.mjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.cjs +1 -1
- package/dist/application/transform/schema/unevaluated-properties.cjs.map +1 -1
- package/dist/application/transform/schema/unevaluated-properties.mjs +2 -2
- package/dist/application/transform/schema/unevaluated-properties.mjs.map +1 -1
- package/dist/application/transform/schema-comment.cjs +1 -1
- package/dist/application/transform/schema-comment.cjs.map +1 -1
- package/dist/application/transform/schema-comment.mjs +2 -2
- package/dist/application/transform/schema-comment.mjs.map +1 -1
- package/dist/domain/deprecations.cjs +11 -0
- package/dist/domain/deprecations.cjs.map +1 -0
- package/dist/domain/deprecations.mjs +9 -0
- package/dist/domain/deprecations.mjs.map +1 -0
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs.map +1 -1
- package/dist/domain/output-fixes.cjs +11 -14
- package/dist/domain/output-fixes.cjs.map +1 -1
- package/dist/domain/output-fixes.mjs +11 -13
- package/dist/domain/output-fixes.mjs.map +1 -1
- package/dist/domain/warnings.cjs +0 -1
- package/dist/domain/warnings.cjs.map +1 -1
- package/dist/domain/warnings.mjs +0 -1
- package/dist/domain/warnings.mjs.map +1 -1
- package/dist/index.cjs +2 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -16
- package/dist/index.d.mts +35 -16
- package/dist/index.d.ts +35 -16
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/adapters/node-deprecations/node-deprecations.ts +14 -0
- package/src/api/default-ports.ts +7 -0
- package/src/api/discriminator-conflict-warnings.ts +2 -2
- package/src/api/discriminator-patch.ts +4 -5
- package/src/api/discriminator-scan.ts +3 -3
- package/src/api/document-run.ts +5 -0
- package/src/api/legacy-callback-warning.ts +13 -6
- package/src/api/openapi-ts.ts +6 -2
- package/src/api/run-context.ts +3 -0
- package/src/api/string-to-ast.ts +11 -15
- package/src/api/transform-schema.ts +3 -3
- package/src/application/ports/deprecation-reporter.ts +9 -0
- package/src/application/transform/document/components.ts +2 -2
- package/src/application/transform/document/parameters.ts +2 -2
- package/src/application/transform/document/paths.ts +2 -2
- package/src/application/transform/ref-pointer/pointer-type.ts +2 -4
- package/src/application/transform/schema/access-flags.ts +2 -2
- package/src/application/transform/schema/array-type.ts +3 -5
- package/src/application/transform/schema/composition-type.ts +4 -4
- package/src/application/transform/schema/enum-rule.ts +4 -6
- package/src/application/transform/schema/presence-members.ts +2 -2
- package/src/application/transform/schema/required-variants.ts +3 -3
- package/src/application/transform/schema/unevaluated-properties.ts +2 -2
- package/src/application/transform/schema-comment.ts +2 -2
- package/src/domain/deprecations.ts +15 -0
- package/src/domain/errors.ts +8 -2
- package/src/domain/output-fixes.ts +16 -16
- package/src/domain/warnings.ts +0 -1
- package/src/index.ts +2 -6
package/dist/index.d.cts
CHANGED
|
@@ -250,9 +250,10 @@ type FooterEntry = IrDeclaration | ts.Node;
|
|
|
250
250
|
/**
|
|
251
251
|
* Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;
|
|
252
252
|
* without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the
|
|
253
|
-
* default.
|
|
253
|
+
* default. The object names the fixes for this package's code; the public API is the `OutputFix`
|
|
254
|
+
* union and the `OUTPUT_FIXES` list (ADR-021, amendment 1).
|
|
254
255
|
*/
|
|
255
|
-
declare const
|
|
256
|
+
declare const FIX: {
|
|
256
257
|
/** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */
|
|
257
258
|
readonly ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union";
|
|
258
259
|
/** An `allOf` member with only `required` makes those properties of the others required. */
|
|
@@ -295,13 +296,14 @@ declare const OutputFix: {
|
|
|
295
296
|
/** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
|
|
296
297
|
readonly UNEVALUATED_PROPERTIES: "unevaluated-properties";
|
|
297
298
|
};
|
|
298
|
-
|
|
299
|
+
/** The name of one opt-in output fix. */
|
|
300
|
+
type OutputFix = (typeof FIX)[keyof typeof FIX];
|
|
299
301
|
/** Every fix of this version, in the order the docs list them. */
|
|
300
302
|
declare const OUTPUT_FIXES: readonly OutputFix[];
|
|
301
303
|
/** The name that turns on every fix of the installed version. */
|
|
302
|
-
declare const
|
|
303
|
-
/** A name the `fix` option accepts: one fix, or `all`. */
|
|
304
|
-
type OutputFixName = OutputFix | typeof
|
|
304
|
+
declare const ALL_FIXES = "all";
|
|
305
|
+
/** A name the `fix` option accepts: one fix, or `"all"`. */
|
|
306
|
+
type OutputFixName = OutputFix | typeof ALL_FIXES;
|
|
305
307
|
|
|
306
308
|
interface Extensable {
|
|
307
309
|
[key: `x-${string}`]: any;
|
|
@@ -1451,6 +1453,20 @@ interface TransformNodeOptions {
|
|
|
1451
1453
|
ctx: GlobalContext;
|
|
1452
1454
|
}
|
|
1453
1455
|
|
|
1456
|
+
/**
|
|
1457
|
+
* Deprecations of what 2.0 removes. Each one is a Node.js `DeprecationWarning` with one of these
|
|
1458
|
+
* codes, so `--no-deprecation`, `--throw-deprecation`, `--trace-deprecation` and
|
|
1459
|
+
* `process.on("warning")` work on it as on Node's own (ADR-004, amendment of 2026-11-08).
|
|
1460
|
+
*/
|
|
1461
|
+
/** Every deprecation code. */
|
|
1462
|
+
declare const DEPRECATION_CODES: {
|
|
1463
|
+
readonly OPENAPI_TYPESAFE_DEP_STRING_TO_AST: "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
|
|
1464
|
+
readonly OPENAPI_TYPESAFE_DEP_TS_TRANSFORM: "OPENAPI_TYPESAFE_DEP_TS_TRANSFORM";
|
|
1465
|
+
readonly OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM: "OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM";
|
|
1466
|
+
readonly OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY: "OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY";
|
|
1467
|
+
};
|
|
1468
|
+
type DeprecationCode = (typeof DEPRECATION_CODES)[keyof typeof DEPRECATION_CODES];
|
|
1469
|
+
|
|
1454
1470
|
/** The debug groups of the original `DEBUG=openapi-ts:<group>` output. */
|
|
1455
1471
|
type DebugGroup = "redoc" | "lint" | "bundle" | "ts";
|
|
1456
1472
|
/**
|
|
@@ -1483,7 +1499,10 @@ declare function openapiTS(source: SchemaSource, options?: GeneratorOptions): Pr
|
|
|
1483
1499
|
* `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken
|
|
1484
1500
|
* invariant) is a plain `Error`, not one of these.
|
|
1485
1501
|
*/
|
|
1486
|
-
/**
|
|
1502
|
+
/**
|
|
1503
|
+
* Every error code. A minor release may add codes (ADR-034); each one needs a row in the CLI's
|
|
1504
|
+
* exit-code table, which the compiler checks.
|
|
1505
|
+
*/
|
|
1487
1506
|
declare const ERROR_CODES: {
|
|
1488
1507
|
readonly SCHEMA_SOURCE_EMPTY: "SCHEMA_SOURCE_EMPTY";
|
|
1489
1508
|
readonly SCHEMA_SOURCE_INVALID: "SCHEMA_SOURCE_INVALID";
|
|
@@ -1513,7 +1532,10 @@ declare const ERROR_CODES: {
|
|
|
1513
1532
|
readonly OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED";
|
|
1514
1533
|
};
|
|
1515
1534
|
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
1516
|
-
/**
|
|
1535
|
+
/**
|
|
1536
|
+
* Structured, JSON-serializable facts about a failure, for programs and logs. Only the keys that
|
|
1537
|
+
* docs/node.md (Errors) lists are stable (ADR-034, amendment of 2026-11-08).
|
|
1538
|
+
*/
|
|
1517
1539
|
type ErrorDetails = Readonly<Record<string, unknown>>;
|
|
1518
1540
|
interface OpenAPITypesafeErrorInit {
|
|
1519
1541
|
readonly code: ErrorCode;
|
|
@@ -1787,15 +1809,13 @@ declare function walk(obj: unknown, cb: (value: Record<string, unknown>, path: (
|
|
|
1787
1809
|
*/
|
|
1788
1810
|
declare function warn(msg: string, silent?: boolean): void;
|
|
1789
1811
|
|
|
1790
|
-
/** Node's deprecation code for `stringToAST`, so users can filter or trace the warning. */
|
|
1791
|
-
declare const STRING_TO_AST_DEPRECATION_CODE = "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
|
|
1792
1812
|
/**
|
|
1793
1813
|
* Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so
|
|
1794
|
-
* it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Node
|
|
1795
|
-
* on the first call only.
|
|
1814
|
+
* it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Emits a Node.js
|
|
1815
|
+
* `DeprecationWarning` (`OPENAPI_TYPESAFE_DEP_STRING_TO_AST`) on the first call only.
|
|
1796
1816
|
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.
|
|
1797
1817
|
*/
|
|
1798
|
-
declare
|
|
1818
|
+
declare function stringToAST(source: string): unknown[];
|
|
1799
1819
|
|
|
1800
1820
|
/**
|
|
1801
1821
|
* The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same
|
|
@@ -1816,7 +1836,6 @@ declare const WARNING_CODES: {
|
|
|
1816
1836
|
readonly DISCRIMINATOR_VALUE_NOT_ALLOWED: "DISCRIMINATOR_VALUE_NOT_ALLOWED";
|
|
1817
1837
|
readonly ENUM_VALUES_EXCLUDED: "ENUM_VALUES_EXCLUDED";
|
|
1818
1838
|
readonly FIX_NEEDS_OPTION: "FIX_NEEDS_OPTION";
|
|
1819
|
-
readonly LEGACY_CALLBACK_DEPRECATED: "LEGACY_CALLBACK_DEPRECATED";
|
|
1820
1839
|
readonly LINT_PROBLEM: "LINT_PROBLEM";
|
|
1821
1840
|
readonly PATH_TEMPLATES_IDENTICAL: "PATH_TEMPLATES_IDENTICAL";
|
|
1822
1841
|
readonly QUERYSTRING_NEXT_TO_QUERY: "QUERYSTRING_NEXT_TO_QUERY";
|
|
@@ -1944,5 +1963,5 @@ declare function transformSchemaObject(schemaObject: SchemaObject | ReferenceObj
|
|
|
1944
1963
|
/** Transform SchemaObjects without the `postTransform` callback at the top level. */
|
|
1945
1964
|
declare function transformSchemaObjectWithComposition(schemaObject: SchemaObject | ReferenceObject, options: TransformNodeOptions, fromAdditionalProperties?: boolean): IrType;
|
|
1946
1965
|
|
|
1947
|
-
export {
|
|
1948
|
-
export type { $defs, AnnotatedSchemaObject, ArraySubtype, AstToStringInput, AstToStringOptions, BooleanSubtype, CallbackObject, ComponentsObject, ContactObject, DiscriminatorObject, EncodingObject, ErrorCode, ErrorDetails, ExampleObject, Extensable, ExternalDocumentationObject, FooterEntry, GeneratorOptions, GlobalContext, HeaderObject, InfoObject, IntegerSubtype, IrArrayType, IrBooleanLiteralType, IrCallbackOptions, IrCallbackType, IrComment, IrConstArrayDeclaration, IrDeclaration, IrEnumDeclaration, IrEnumMember, IrIndexSignature, IrIndexedAccessType, IrInterfaceDeclaration, IrIntersectionType, IrKeyword, IrKeywordType, IrMember, IrNumberLiteralType, IrObjectType, IrPostTransform, IrPropertyName, IrPropertySignature, IrRawDeclaration, IrRawType, IrReadonlyType, IrReferenceType, IrStringEncoding, IrStringLiteralType, IrTransform, IrTransformObject, IrTransformProperty, IrTupleElement, IrTupleType, IrType, IrTypeAliasDeclaration, IrUnionType, LegacyCallbackName, LegacyCallbackOptions, LicenseObject, LinkObject, MediaTypeObject, Method, NullSubtype, NumberSubtype, OAuthFlowObject, OAuthFlowsObject, OapiRefOptions, ObjectSubtype, OpenAPI3, OpenAPITSBaseOptions, OpenAPITSIrOptions, OpenAPITSOptions, OperationObject, OutputFixName, ParameterObject, PathItemObject, PathsObject, ReferenceObject, RequestBodyObject, ResolveRefOptions, ResponseObject, ResponsesObject, SchemaObject, SchemaSource, SecurityRequirementObject, SecuritySchemeObject, ServerObject, ServerVariableObject, StringSubtype, TagObject, TransformNodeOptions, TransformObject, TypeInput, WarningCode, WebhooksObject, XMLObject };
|
|
1966
|
+
export { BOOLEAN, COMMENT_HEADER, DEPRECATION_CODES, ERROR_CODES, FALSE, JS_ENUM_INVALID_CHARS_RE, JS_PROPERTY_INDEX_INVALID_CHARS_RE, JS_PROPERTY_INDEX_RE, NEVER, NULL, NUMBER, OUTPUT_FIXES, OpenAPITypesafeError, QUESTION_TOKEN, SPECIAL_CHARACTER_MAP, STRING, TRUE, UNDEFINED, UNKNOWN, WARNING_CODES, addJSDocComment, astToString, c, createDiscriminatorProperty, createRef, debug, openapiTS as default, enumCache, error, formatTime, getEntries, injectOperationObject, isOpenAPITypesafeError, oapiRef, resolveRef, scanDiscriminators, stringToAST, transformComponentsObject, transformHeaderObject, transformMediaTypeObject, transformOperationObject, transformParameterObject, transformPathItemObject, transformPathsObject, transformRequestBodyObject, transformResponseObject, transformResponsesObject, transformSchema, transformSchemaObject, transformSchemaObjectWithComposition, tsArrayLiteralExpression, tsDedupe, tsEnum, tsEnumMember, tsIntersection, tsIsPrimitive, tsLiteral, tsModifiers, tsNullable, tsOmit, tsPropertyIndex, tsReadonlyArray, tsRecord, tsUnion, tsWithRequired, walk, warn };
|
|
1967
|
+
export type { $defs, AnnotatedSchemaObject, ArraySubtype, AstToStringInput, AstToStringOptions, BooleanSubtype, CallbackObject, ComponentsObject, ContactObject, DeprecationCode, DiscriminatorObject, EncodingObject, ErrorCode, ErrorDetails, ExampleObject, Extensable, ExternalDocumentationObject, FooterEntry, GeneratorOptions, GlobalContext, HeaderObject, InfoObject, IntegerSubtype, IrArrayType, IrBooleanLiteralType, IrCallbackOptions, IrCallbackType, IrComment, IrConstArrayDeclaration, IrDeclaration, IrEnumDeclaration, IrEnumMember, IrIndexSignature, IrIndexedAccessType, IrInterfaceDeclaration, IrIntersectionType, IrKeyword, IrKeywordType, IrMember, IrNumberLiteralType, IrObjectType, IrPostTransform, IrPropertyName, IrPropertySignature, IrRawDeclaration, IrRawType, IrReadonlyType, IrReferenceType, IrStringEncoding, IrStringLiteralType, IrTransform, IrTransformObject, IrTransformProperty, IrTupleElement, IrTupleType, IrType, IrTypeAliasDeclaration, IrUnionType, LegacyCallbackName, LegacyCallbackOptions, LicenseObject, LinkObject, MediaTypeObject, Method, NullSubtype, NumberSubtype, OAuthFlowObject, OAuthFlowsObject, OapiRefOptions, ObjectSubtype, OpenAPI3, OpenAPITSBaseOptions, OpenAPITSIrOptions, OpenAPITSOptions, OperationObject, OutputFix, OutputFixName, ParameterObject, PathItemObject, PathsObject, ReferenceObject, RequestBodyObject, ResolveRefOptions, ResponseObject, ResponsesObject, SchemaObject, SchemaSource, SecurityRequirementObject, SecuritySchemeObject, ServerObject, ServerVariableObject, StringSubtype, TagObject, TransformNodeOptions, TransformObject, TypeInput, WarningCode, WebhooksObject, XMLObject };
|
package/dist/index.d.mts
CHANGED
|
@@ -250,9 +250,10 @@ type FooterEntry = IrDeclaration | ts.Node;
|
|
|
250
250
|
/**
|
|
251
251
|
* Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;
|
|
252
252
|
* without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the
|
|
253
|
-
* default.
|
|
253
|
+
* default. The object names the fixes for this package's code; the public API is the `OutputFix`
|
|
254
|
+
* union and the `OUTPUT_FIXES` list (ADR-021, amendment 1).
|
|
254
255
|
*/
|
|
255
|
-
declare const
|
|
256
|
+
declare const FIX: {
|
|
256
257
|
/** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */
|
|
257
258
|
readonly ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union";
|
|
258
259
|
/** An `allOf` member with only `required` makes those properties of the others required. */
|
|
@@ -295,13 +296,14 @@ declare const OutputFix: {
|
|
|
295
296
|
/** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
|
|
296
297
|
readonly UNEVALUATED_PROPERTIES: "unevaluated-properties";
|
|
297
298
|
};
|
|
298
|
-
|
|
299
|
+
/** The name of one opt-in output fix. */
|
|
300
|
+
type OutputFix = (typeof FIX)[keyof typeof FIX];
|
|
299
301
|
/** Every fix of this version, in the order the docs list them. */
|
|
300
302
|
declare const OUTPUT_FIXES: readonly OutputFix[];
|
|
301
303
|
/** The name that turns on every fix of the installed version. */
|
|
302
|
-
declare const
|
|
303
|
-
/** A name the `fix` option accepts: one fix, or `all`. */
|
|
304
|
-
type OutputFixName = OutputFix | typeof
|
|
304
|
+
declare const ALL_FIXES = "all";
|
|
305
|
+
/** A name the `fix` option accepts: one fix, or `"all"`. */
|
|
306
|
+
type OutputFixName = OutputFix | typeof ALL_FIXES;
|
|
305
307
|
|
|
306
308
|
interface Extensable {
|
|
307
309
|
[key: `x-${string}`]: any;
|
|
@@ -1451,6 +1453,20 @@ interface TransformNodeOptions {
|
|
|
1451
1453
|
ctx: GlobalContext;
|
|
1452
1454
|
}
|
|
1453
1455
|
|
|
1456
|
+
/**
|
|
1457
|
+
* Deprecations of what 2.0 removes. Each one is a Node.js `DeprecationWarning` with one of these
|
|
1458
|
+
* codes, so `--no-deprecation`, `--throw-deprecation`, `--trace-deprecation` and
|
|
1459
|
+
* `process.on("warning")` work on it as on Node's own (ADR-004, amendment of 2026-11-08).
|
|
1460
|
+
*/
|
|
1461
|
+
/** Every deprecation code. */
|
|
1462
|
+
declare const DEPRECATION_CODES: {
|
|
1463
|
+
readonly OPENAPI_TYPESAFE_DEP_STRING_TO_AST: "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
|
|
1464
|
+
readonly OPENAPI_TYPESAFE_DEP_TS_TRANSFORM: "OPENAPI_TYPESAFE_DEP_TS_TRANSFORM";
|
|
1465
|
+
readonly OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM: "OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM";
|
|
1466
|
+
readonly OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY: "OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY";
|
|
1467
|
+
};
|
|
1468
|
+
type DeprecationCode = (typeof DEPRECATION_CODES)[keyof typeof DEPRECATION_CODES];
|
|
1469
|
+
|
|
1454
1470
|
/** The debug groups of the original `DEBUG=openapi-ts:<group>` output. */
|
|
1455
1471
|
type DebugGroup = "redoc" | "lint" | "bundle" | "ts";
|
|
1456
1472
|
/**
|
|
@@ -1483,7 +1499,10 @@ declare function openapiTS(source: SchemaSource, options?: GeneratorOptions): Pr
|
|
|
1483
1499
|
* `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken
|
|
1484
1500
|
* invariant) is a plain `Error`, not one of these.
|
|
1485
1501
|
*/
|
|
1486
|
-
/**
|
|
1502
|
+
/**
|
|
1503
|
+
* Every error code. A minor release may add codes (ADR-034); each one needs a row in the CLI's
|
|
1504
|
+
* exit-code table, which the compiler checks.
|
|
1505
|
+
*/
|
|
1487
1506
|
declare const ERROR_CODES: {
|
|
1488
1507
|
readonly SCHEMA_SOURCE_EMPTY: "SCHEMA_SOURCE_EMPTY";
|
|
1489
1508
|
readonly SCHEMA_SOURCE_INVALID: "SCHEMA_SOURCE_INVALID";
|
|
@@ -1513,7 +1532,10 @@ declare const ERROR_CODES: {
|
|
|
1513
1532
|
readonly OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED";
|
|
1514
1533
|
};
|
|
1515
1534
|
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
1516
|
-
/**
|
|
1535
|
+
/**
|
|
1536
|
+
* Structured, JSON-serializable facts about a failure, for programs and logs. Only the keys that
|
|
1537
|
+
* docs/node.md (Errors) lists are stable (ADR-034, amendment of 2026-11-08).
|
|
1538
|
+
*/
|
|
1517
1539
|
type ErrorDetails = Readonly<Record<string, unknown>>;
|
|
1518
1540
|
interface OpenAPITypesafeErrorInit {
|
|
1519
1541
|
readonly code: ErrorCode;
|
|
@@ -1787,15 +1809,13 @@ declare function walk(obj: unknown, cb: (value: Record<string, unknown>, path: (
|
|
|
1787
1809
|
*/
|
|
1788
1810
|
declare function warn(msg: string, silent?: boolean): void;
|
|
1789
1811
|
|
|
1790
|
-
/** Node's deprecation code for `stringToAST`, so users can filter or trace the warning. */
|
|
1791
|
-
declare const STRING_TO_AST_DEPRECATION_CODE = "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
|
|
1792
1812
|
/**
|
|
1793
1813
|
* Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so
|
|
1794
|
-
* it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Node
|
|
1795
|
-
* on the first call only.
|
|
1814
|
+
* it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Emits a Node.js
|
|
1815
|
+
* `DeprecationWarning` (`OPENAPI_TYPESAFE_DEP_STRING_TO_AST`) on the first call only.
|
|
1796
1816
|
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.
|
|
1797
1817
|
*/
|
|
1798
|
-
declare
|
|
1818
|
+
declare function stringToAST(source: string): unknown[];
|
|
1799
1819
|
|
|
1800
1820
|
/**
|
|
1801
1821
|
* The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same
|
|
@@ -1816,7 +1836,6 @@ declare const WARNING_CODES: {
|
|
|
1816
1836
|
readonly DISCRIMINATOR_VALUE_NOT_ALLOWED: "DISCRIMINATOR_VALUE_NOT_ALLOWED";
|
|
1817
1837
|
readonly ENUM_VALUES_EXCLUDED: "ENUM_VALUES_EXCLUDED";
|
|
1818
1838
|
readonly FIX_NEEDS_OPTION: "FIX_NEEDS_OPTION";
|
|
1819
|
-
readonly LEGACY_CALLBACK_DEPRECATED: "LEGACY_CALLBACK_DEPRECATED";
|
|
1820
1839
|
readonly LINT_PROBLEM: "LINT_PROBLEM";
|
|
1821
1840
|
readonly PATH_TEMPLATES_IDENTICAL: "PATH_TEMPLATES_IDENTICAL";
|
|
1822
1841
|
readonly QUERYSTRING_NEXT_TO_QUERY: "QUERYSTRING_NEXT_TO_QUERY";
|
|
@@ -1944,5 +1963,5 @@ declare function transformSchemaObject(schemaObject: SchemaObject | ReferenceObj
|
|
|
1944
1963
|
/** Transform SchemaObjects without the `postTransform` callback at the top level. */
|
|
1945
1964
|
declare function transformSchemaObjectWithComposition(schemaObject: SchemaObject | ReferenceObject, options: TransformNodeOptions, fromAdditionalProperties?: boolean): IrType;
|
|
1946
1965
|
|
|
1947
|
-
export {
|
|
1948
|
-
export type { $defs, AnnotatedSchemaObject, ArraySubtype, AstToStringInput, AstToStringOptions, BooleanSubtype, CallbackObject, ComponentsObject, ContactObject, DiscriminatorObject, EncodingObject, ErrorCode, ErrorDetails, ExampleObject, Extensable, ExternalDocumentationObject, FooterEntry, GeneratorOptions, GlobalContext, HeaderObject, InfoObject, IntegerSubtype, IrArrayType, IrBooleanLiteralType, IrCallbackOptions, IrCallbackType, IrComment, IrConstArrayDeclaration, IrDeclaration, IrEnumDeclaration, IrEnumMember, IrIndexSignature, IrIndexedAccessType, IrInterfaceDeclaration, IrIntersectionType, IrKeyword, IrKeywordType, IrMember, IrNumberLiteralType, IrObjectType, IrPostTransform, IrPropertyName, IrPropertySignature, IrRawDeclaration, IrRawType, IrReadonlyType, IrReferenceType, IrStringEncoding, IrStringLiteralType, IrTransform, IrTransformObject, IrTransformProperty, IrTupleElement, IrTupleType, IrType, IrTypeAliasDeclaration, IrUnionType, LegacyCallbackName, LegacyCallbackOptions, LicenseObject, LinkObject, MediaTypeObject, Method, NullSubtype, NumberSubtype, OAuthFlowObject, OAuthFlowsObject, OapiRefOptions, ObjectSubtype, OpenAPI3, OpenAPITSBaseOptions, OpenAPITSIrOptions, OpenAPITSOptions, OperationObject, OutputFixName, ParameterObject, PathItemObject, PathsObject, ReferenceObject, RequestBodyObject, ResolveRefOptions, ResponseObject, ResponsesObject, SchemaObject, SchemaSource, SecurityRequirementObject, SecuritySchemeObject, ServerObject, ServerVariableObject, StringSubtype, TagObject, TransformNodeOptions, TransformObject, TypeInput, WarningCode, WebhooksObject, XMLObject };
|
|
1966
|
+
export { BOOLEAN, COMMENT_HEADER, DEPRECATION_CODES, ERROR_CODES, FALSE, JS_ENUM_INVALID_CHARS_RE, JS_PROPERTY_INDEX_INVALID_CHARS_RE, JS_PROPERTY_INDEX_RE, NEVER, NULL, NUMBER, OUTPUT_FIXES, OpenAPITypesafeError, QUESTION_TOKEN, SPECIAL_CHARACTER_MAP, STRING, TRUE, UNDEFINED, UNKNOWN, WARNING_CODES, addJSDocComment, astToString, c, createDiscriminatorProperty, createRef, debug, openapiTS as default, enumCache, error, formatTime, getEntries, injectOperationObject, isOpenAPITypesafeError, oapiRef, resolveRef, scanDiscriminators, stringToAST, transformComponentsObject, transformHeaderObject, transformMediaTypeObject, transformOperationObject, transformParameterObject, transformPathItemObject, transformPathsObject, transformRequestBodyObject, transformResponseObject, transformResponsesObject, transformSchema, transformSchemaObject, transformSchemaObjectWithComposition, tsArrayLiteralExpression, tsDedupe, tsEnum, tsEnumMember, tsIntersection, tsIsPrimitive, tsLiteral, tsModifiers, tsNullable, tsOmit, tsPropertyIndex, tsReadonlyArray, tsRecord, tsUnion, tsWithRequired, walk, warn };
|
|
1967
|
+
export type { $defs, AnnotatedSchemaObject, ArraySubtype, AstToStringInput, AstToStringOptions, BooleanSubtype, CallbackObject, ComponentsObject, ContactObject, DeprecationCode, DiscriminatorObject, EncodingObject, ErrorCode, ErrorDetails, ExampleObject, Extensable, ExternalDocumentationObject, FooterEntry, GeneratorOptions, GlobalContext, HeaderObject, InfoObject, IntegerSubtype, IrArrayType, IrBooleanLiteralType, IrCallbackOptions, IrCallbackType, IrComment, IrConstArrayDeclaration, IrDeclaration, IrEnumDeclaration, IrEnumMember, IrIndexSignature, IrIndexedAccessType, IrInterfaceDeclaration, IrIntersectionType, IrKeyword, IrKeywordType, IrMember, IrNumberLiteralType, IrObjectType, IrPostTransform, IrPropertyName, IrPropertySignature, IrRawDeclaration, IrRawType, IrReadonlyType, IrReferenceType, IrStringEncoding, IrStringLiteralType, IrTransform, IrTransformObject, IrTransformProperty, IrTupleElement, IrTupleType, IrType, IrTypeAliasDeclaration, IrUnionType, LegacyCallbackName, LegacyCallbackOptions, LicenseObject, LinkObject, MediaTypeObject, Method, NullSubtype, NumberSubtype, OAuthFlowObject, OAuthFlowsObject, OapiRefOptions, ObjectSubtype, OpenAPI3, OpenAPITSBaseOptions, OpenAPITSIrOptions, OpenAPITSOptions, OperationObject, OutputFix, OutputFixName, ParameterObject, PathItemObject, PathsObject, ReferenceObject, RequestBodyObject, ResolveRefOptions, ResponseObject, ResponsesObject, SchemaObject, SchemaSource, SecurityRequirementObject, SecuritySchemeObject, ServerObject, ServerVariableObject, StringSubtype, TagObject, TransformNodeOptions, TransformObject, TypeInput, WarningCode, WebhooksObject, XMLObject };
|
package/dist/index.d.ts
CHANGED
|
@@ -250,9 +250,10 @@ type FooterEntry = IrDeclaration | ts.Node;
|
|
|
250
250
|
/**
|
|
251
251
|
* Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;
|
|
252
252
|
* without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the
|
|
253
|
-
* default.
|
|
253
|
+
* default. The object names the fixes for this package's code; the public API is the `OutputFix`
|
|
254
|
+
* union and the `OUTPUT_FIXES` list (ADR-021, amendment 1).
|
|
254
255
|
*/
|
|
255
|
-
declare const
|
|
256
|
+
declare const FIX: {
|
|
256
257
|
/** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */
|
|
257
258
|
readonly ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union";
|
|
258
259
|
/** An `allOf` member with only `required` makes those properties of the others required. */
|
|
@@ -295,13 +296,14 @@ declare const OutputFix: {
|
|
|
295
296
|
/** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
|
|
296
297
|
readonly UNEVALUATED_PROPERTIES: "unevaluated-properties";
|
|
297
298
|
};
|
|
298
|
-
|
|
299
|
+
/** The name of one opt-in output fix. */
|
|
300
|
+
type OutputFix = (typeof FIX)[keyof typeof FIX];
|
|
299
301
|
/** Every fix of this version, in the order the docs list them. */
|
|
300
302
|
declare const OUTPUT_FIXES: readonly OutputFix[];
|
|
301
303
|
/** The name that turns on every fix of the installed version. */
|
|
302
|
-
declare const
|
|
303
|
-
/** A name the `fix` option accepts: one fix, or `all`. */
|
|
304
|
-
type OutputFixName = OutputFix | typeof
|
|
304
|
+
declare const ALL_FIXES = "all";
|
|
305
|
+
/** A name the `fix` option accepts: one fix, or `"all"`. */
|
|
306
|
+
type OutputFixName = OutputFix | typeof ALL_FIXES;
|
|
305
307
|
|
|
306
308
|
interface Extensable {
|
|
307
309
|
[key: `x-${string}`]: any;
|
|
@@ -1451,6 +1453,20 @@ interface TransformNodeOptions {
|
|
|
1451
1453
|
ctx: GlobalContext;
|
|
1452
1454
|
}
|
|
1453
1455
|
|
|
1456
|
+
/**
|
|
1457
|
+
* Deprecations of what 2.0 removes. Each one is a Node.js `DeprecationWarning` with one of these
|
|
1458
|
+
* codes, so `--no-deprecation`, `--throw-deprecation`, `--trace-deprecation` and
|
|
1459
|
+
* `process.on("warning")` work on it as on Node's own (ADR-004, amendment of 2026-11-08).
|
|
1460
|
+
*/
|
|
1461
|
+
/** Every deprecation code. */
|
|
1462
|
+
declare const DEPRECATION_CODES: {
|
|
1463
|
+
readonly OPENAPI_TYPESAFE_DEP_STRING_TO_AST: "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
|
|
1464
|
+
readonly OPENAPI_TYPESAFE_DEP_TS_TRANSFORM: "OPENAPI_TYPESAFE_DEP_TS_TRANSFORM";
|
|
1465
|
+
readonly OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM: "OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM";
|
|
1466
|
+
readonly OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY: "OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY";
|
|
1467
|
+
};
|
|
1468
|
+
type DeprecationCode = (typeof DEPRECATION_CODES)[keyof typeof DEPRECATION_CODES];
|
|
1469
|
+
|
|
1454
1470
|
/** The debug groups of the original `DEBUG=openapi-ts:<group>` output. */
|
|
1455
1471
|
type DebugGroup = "redoc" | "lint" | "bundle" | "ts";
|
|
1456
1472
|
/**
|
|
@@ -1483,7 +1499,10 @@ declare function openapiTS(source: SchemaSource, options?: GeneratorOptions): Pr
|
|
|
1483
1499
|
* `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken
|
|
1484
1500
|
* invariant) is a plain `Error`, not one of these.
|
|
1485
1501
|
*/
|
|
1486
|
-
/**
|
|
1502
|
+
/**
|
|
1503
|
+
* Every error code. A minor release may add codes (ADR-034); each one needs a row in the CLI's
|
|
1504
|
+
* exit-code table, which the compiler checks.
|
|
1505
|
+
*/
|
|
1487
1506
|
declare const ERROR_CODES: {
|
|
1488
1507
|
readonly SCHEMA_SOURCE_EMPTY: "SCHEMA_SOURCE_EMPTY";
|
|
1489
1508
|
readonly SCHEMA_SOURCE_INVALID: "SCHEMA_SOURCE_INVALID";
|
|
@@ -1513,7 +1532,10 @@ declare const ERROR_CODES: {
|
|
|
1513
1532
|
readonly OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED";
|
|
1514
1533
|
};
|
|
1515
1534
|
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
1516
|
-
/**
|
|
1535
|
+
/**
|
|
1536
|
+
* Structured, JSON-serializable facts about a failure, for programs and logs. Only the keys that
|
|
1537
|
+
* docs/node.md (Errors) lists are stable (ADR-034, amendment of 2026-11-08).
|
|
1538
|
+
*/
|
|
1517
1539
|
type ErrorDetails = Readonly<Record<string, unknown>>;
|
|
1518
1540
|
interface OpenAPITypesafeErrorInit {
|
|
1519
1541
|
readonly code: ErrorCode;
|
|
@@ -1787,15 +1809,13 @@ declare function walk(obj: unknown, cb: (value: Record<string, unknown>, path: (
|
|
|
1787
1809
|
*/
|
|
1788
1810
|
declare function warn(msg: string, silent?: boolean): void;
|
|
1789
1811
|
|
|
1790
|
-
/** Node's deprecation code for `stringToAST`, so users can filter or trace the warning. */
|
|
1791
|
-
declare const STRING_TO_AST_DEPRECATION_CODE = "OPENAPI_TYPESAFE_DEP_STRING_TO_AST";
|
|
1792
1812
|
/**
|
|
1793
1813
|
* Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so
|
|
1794
|
-
* it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Node
|
|
1795
|
-
* on the first call only.
|
|
1814
|
+
* it needs TypeScript 6 or earlier (or `@typescript/typescript6`). Emits a Node.js
|
|
1815
|
+
* `DeprecationWarning` (`OPENAPI_TYPESAFE_DEP_STRING_TO_AST`) on the first call only.
|
|
1796
1816
|
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.
|
|
1797
1817
|
*/
|
|
1798
|
-
declare
|
|
1818
|
+
declare function stringToAST(source: string): unknown[];
|
|
1799
1819
|
|
|
1800
1820
|
/**
|
|
1801
1821
|
* The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same
|
|
@@ -1816,7 +1836,6 @@ declare const WARNING_CODES: {
|
|
|
1816
1836
|
readonly DISCRIMINATOR_VALUE_NOT_ALLOWED: "DISCRIMINATOR_VALUE_NOT_ALLOWED";
|
|
1817
1837
|
readonly ENUM_VALUES_EXCLUDED: "ENUM_VALUES_EXCLUDED";
|
|
1818
1838
|
readonly FIX_NEEDS_OPTION: "FIX_NEEDS_OPTION";
|
|
1819
|
-
readonly LEGACY_CALLBACK_DEPRECATED: "LEGACY_CALLBACK_DEPRECATED";
|
|
1820
1839
|
readonly LINT_PROBLEM: "LINT_PROBLEM";
|
|
1821
1840
|
readonly PATH_TEMPLATES_IDENTICAL: "PATH_TEMPLATES_IDENTICAL";
|
|
1822
1841
|
readonly QUERYSTRING_NEXT_TO_QUERY: "QUERYSTRING_NEXT_TO_QUERY";
|
|
@@ -1944,5 +1963,5 @@ declare function transformSchemaObject(schemaObject: SchemaObject | ReferenceObj
|
|
|
1944
1963
|
/** Transform SchemaObjects without the `postTransform` callback at the top level. */
|
|
1945
1964
|
declare function transformSchemaObjectWithComposition(schemaObject: SchemaObject | ReferenceObject, options: TransformNodeOptions, fromAdditionalProperties?: boolean): IrType;
|
|
1946
1965
|
|
|
1947
|
-
export {
|
|
1948
|
-
export type { $defs, AnnotatedSchemaObject, ArraySubtype, AstToStringInput, AstToStringOptions, BooleanSubtype, CallbackObject, ComponentsObject, ContactObject, DiscriminatorObject, EncodingObject, ErrorCode, ErrorDetails, ExampleObject, Extensable, ExternalDocumentationObject, FooterEntry, GeneratorOptions, GlobalContext, HeaderObject, InfoObject, IntegerSubtype, IrArrayType, IrBooleanLiteralType, IrCallbackOptions, IrCallbackType, IrComment, IrConstArrayDeclaration, IrDeclaration, IrEnumDeclaration, IrEnumMember, IrIndexSignature, IrIndexedAccessType, IrInterfaceDeclaration, IrIntersectionType, IrKeyword, IrKeywordType, IrMember, IrNumberLiteralType, IrObjectType, IrPostTransform, IrPropertyName, IrPropertySignature, IrRawDeclaration, IrRawType, IrReadonlyType, IrReferenceType, IrStringEncoding, IrStringLiteralType, IrTransform, IrTransformObject, IrTransformProperty, IrTupleElement, IrTupleType, IrType, IrTypeAliasDeclaration, IrUnionType, LegacyCallbackName, LegacyCallbackOptions, LicenseObject, LinkObject, MediaTypeObject, Method, NullSubtype, NumberSubtype, OAuthFlowObject, OAuthFlowsObject, OapiRefOptions, ObjectSubtype, OpenAPI3, OpenAPITSBaseOptions, OpenAPITSIrOptions, OpenAPITSOptions, OperationObject, OutputFixName, ParameterObject, PathItemObject, PathsObject, ReferenceObject, RequestBodyObject, ResolveRefOptions, ResponseObject, ResponsesObject, SchemaObject, SchemaSource, SecurityRequirementObject, SecuritySchemeObject, ServerObject, ServerVariableObject, StringSubtype, TagObject, TransformNodeOptions, TransformObject, TypeInput, WarningCode, WebhooksObject, XMLObject };
|
|
1966
|
+
export { BOOLEAN, COMMENT_HEADER, DEPRECATION_CODES, ERROR_CODES, FALSE, JS_ENUM_INVALID_CHARS_RE, JS_PROPERTY_INDEX_INVALID_CHARS_RE, JS_PROPERTY_INDEX_RE, NEVER, NULL, NUMBER, OUTPUT_FIXES, OpenAPITypesafeError, QUESTION_TOKEN, SPECIAL_CHARACTER_MAP, STRING, TRUE, UNDEFINED, UNKNOWN, WARNING_CODES, addJSDocComment, astToString, c, createDiscriminatorProperty, createRef, debug, openapiTS as default, enumCache, error, formatTime, getEntries, injectOperationObject, isOpenAPITypesafeError, oapiRef, resolveRef, scanDiscriminators, stringToAST, transformComponentsObject, transformHeaderObject, transformMediaTypeObject, transformOperationObject, transformParameterObject, transformPathItemObject, transformPathsObject, transformRequestBodyObject, transformResponseObject, transformResponsesObject, transformSchema, transformSchemaObject, transformSchemaObjectWithComposition, tsArrayLiteralExpression, tsDedupe, tsEnum, tsEnumMember, tsIntersection, tsIsPrimitive, tsLiteral, tsModifiers, tsNullable, tsOmit, tsPropertyIndex, tsReadonlyArray, tsRecord, tsUnion, tsWithRequired, walk, warn };
|
|
1967
|
+
export type { $defs, AnnotatedSchemaObject, ArraySubtype, AstToStringInput, AstToStringOptions, BooleanSubtype, CallbackObject, ComponentsObject, ContactObject, DeprecationCode, DiscriminatorObject, EncodingObject, ErrorCode, ErrorDetails, ExampleObject, Extensable, ExternalDocumentationObject, FooterEntry, GeneratorOptions, GlobalContext, HeaderObject, InfoObject, IntegerSubtype, IrArrayType, IrBooleanLiteralType, IrCallbackOptions, IrCallbackType, IrComment, IrConstArrayDeclaration, IrDeclaration, IrEnumDeclaration, IrEnumMember, IrIndexSignature, IrIndexedAccessType, IrInterfaceDeclaration, IrIntersectionType, IrKeyword, IrKeywordType, IrMember, IrNumberLiteralType, IrObjectType, IrPostTransform, IrPropertyName, IrPropertySignature, IrRawDeclaration, IrRawType, IrReadonlyType, IrReferenceType, IrStringEncoding, IrStringLiteralType, IrTransform, IrTransformObject, IrTransformProperty, IrTupleElement, IrTupleType, IrType, IrTypeAliasDeclaration, IrUnionType, LegacyCallbackName, LegacyCallbackOptions, LicenseObject, LinkObject, MediaTypeObject, Method, NullSubtype, NumberSubtype, OAuthFlowObject, OAuthFlowsObject, OapiRefOptions, ObjectSubtype, OpenAPI3, OpenAPITSBaseOptions, OpenAPITSIrOptions, OpenAPITSOptions, OperationObject, OutputFix, OutputFixName, ParameterObject, PathItemObject, PathsObject, ReferenceObject, RequestBodyObject, ResolveRefOptions, ResponseObject, ResponsesObject, SchemaObject, SchemaSource, SecurityRequirementObject, SecuritySchemeObject, ServerObject, ServerVariableObject, StringSubtype, TagObject, TransformNodeOptions, TransformObject, TypeInput, WarningCode, WebhooksObject, XMLObject };
|
package/dist/index.mjs
CHANGED
|
@@ -4,11 +4,12 @@ export { COMMENT_HEADER } from './api/comment-header.mjs';
|
|
|
4
4
|
export { scanDiscriminators } from './api/discriminator-scan.mjs';
|
|
5
5
|
export { JS_ENUM_INVALID_CHARS_RE, JS_PROPERTY_INDEX_INVALID_CHARS_RE, JS_PROPERTY_INDEX_RE, QUESTION_TOKEN, SPECIAL_CHARACTER_MAP, addJSDocComment, enumCache, tsArrayLiteralExpression, tsDedupe, tsEnum, tsEnumMember, tsIsPrimitive, tsModifiers, tsPropertyIndex, tsReadonlyArray } from './api/legacy-ts-helpers.mjs';
|
|
6
6
|
export { c, createDiscriminatorProperty, createRef, debug, error, formatTime, getEntries, resolveRef, walk, warn } from './api/legacy-utils.mjs';
|
|
7
|
-
export {
|
|
7
|
+
export { stringToAST } from './api/string-to-ast.mjs';
|
|
8
8
|
export { default as transformSchema } from './api/transform-schema.mjs';
|
|
9
9
|
export { BOOLEAN, FALSE, NEVER, NULL, NUMBER, STRING, TRUE, UNDEFINED, UNKNOWN, oapiRef, tsIntersection, tsLiteral, tsNullable, tsOmit, tsRecord, tsUnion, tsWithRequired } from './api/type-helpers.mjs';
|
|
10
|
+
export { DEPRECATION_CODES } from './domain/deprecations.mjs';
|
|
10
11
|
export { ERROR_CODES, OpenAPITypesafeError, isOpenAPITypesafeError } from './domain/errors.mjs';
|
|
11
|
-
export {
|
|
12
|
+
export { OUTPUT_FIXES } from './domain/output-fixes.mjs';
|
|
12
13
|
export { WARNING_CODES } from './domain/warnings.mjs';
|
|
13
14
|
export { default as transformComponentsObject } from './transform/components-object.mjs';
|
|
14
15
|
export { default as transformHeaderObject } from './transform/header-object.mjs';
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-typesafe",
|
|
3
3
|
"description": "Convert OpenAPI 3.0, 3.1 & 3.2 schemas to TypeScript",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Fedor Chishchin",
|
|
7
7
|
"url": "https://github.com/fedorello"
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@redocly/openapi-core": "^1.34.
|
|
75
|
+
"@redocly/openapi-core": "^1.34.22",
|
|
76
76
|
"ansi-colors": "^4.1.3",
|
|
77
77
|
"change-case": "^5.4.4",
|
|
78
78
|
"parse-json": "^8.3.0",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { deprecate } from "node:util";
|
|
2
|
+
import type { DeprecationReporter } from "../../application/ports/deprecation-reporter.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Deprecations as Node.js `DeprecationWarning`s. `util.deprecate` warns once per process for each
|
|
6
|
+
* code, also across wrappers, and honours `--no-deprecation` and `--throw-deprecation`.
|
|
7
|
+
*/
|
|
8
|
+
export function createNodeDeprecationReporter(): DeprecationReporter {
|
|
9
|
+
return {
|
|
10
|
+
report(code, message) {
|
|
11
|
+
deprecate(() => undefined, message, code)();
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
package/src/api/default-ports.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { performance } from "node:perf_hooks";
|
|
2
2
|
import { createConfig, type Config as RedoclyConfig } from "@redocly/openapi-core";
|
|
3
3
|
import supportsColor from "supports-color";
|
|
4
|
+
import { createNodeDeprecationReporter } from "../adapters/node-deprecations/node-deprecations.js";
|
|
4
5
|
import type { RemoteDocumentLimits } from "../adapters/redocly-loader/remote-fetch.js";
|
|
5
6
|
import { createTerminalLogger } from "../adapters/terminal-logger/terminal-logger.js";
|
|
7
|
+
import type { DeprecationReporter } from "../application/ports/deprecation-reporter.js";
|
|
6
8
|
import type { Logger } from "../application/ports/logger.js";
|
|
7
9
|
|
|
8
10
|
/**
|
|
@@ -26,6 +28,11 @@ export function defaultLogger(silent: boolean): Logger {
|
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
30
|
|
|
31
|
+
/** Deprecations as Node.js `DeprecationWarning`s, each code once per process. */
|
|
32
|
+
export function defaultDeprecationReporter(): DeprecationReporter {
|
|
33
|
+
return createNodeDeprecationReporter();
|
|
34
|
+
}
|
|
35
|
+
|
|
29
36
|
/**
|
|
30
37
|
* How long one remote `$ref` (or a remote source) may take to load. Large documents (the 27 MB
|
|
31
38
|
* Cloudflare spec) download in seconds; a minute covers slow hosts, while Node's own fetch would
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
type DiscriminatorValueConflict,
|
|
4
4
|
findDiscriminatorValueConflicts,
|
|
5
5
|
} from "../domain/openapi/discriminator-conflicts.js";
|
|
6
|
-
import { OutputFix } from "../domain/output-fixes.js";
|
|
6
|
+
import { FIX, type OutputFix } from "../domain/output-fixes.js";
|
|
7
7
|
import { WARNING_CODES, warningText } from "../domain/warnings.js";
|
|
8
8
|
|
|
9
9
|
const DOCS_BASE_URL = "https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs";
|
|
@@ -36,7 +36,7 @@ export function warnDiscriminatorValueConflicts(
|
|
|
36
36
|
fixes: readonly OutputFix[],
|
|
37
37
|
logger: Logger,
|
|
38
38
|
): void {
|
|
39
|
-
const isUnionReused = fixes.includes(
|
|
39
|
+
const isUnionReused = fixes.includes(FIX.ALLOF_DISCRIMINATED_UNION);
|
|
40
40
|
for (const conflict of findDiscriminatorValueConflicts(document, { isUnionReused })) {
|
|
41
41
|
logger.warn(warningText(warningOf(conflict), WARNING_CODES.DISCRIMINATOR_VALUE_NOT_ALLOWED));
|
|
42
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Logger } from "../application/ports/logger.js";
|
|
2
|
-
import { OutputFix } from "../domain/output-fixes.js";
|
|
2
|
+
import { FIX, type OutputFix } from "../domain/output-fixes.js";
|
|
3
3
|
import { WARNING_CODES, warningText } from "../domain/warnings.js";
|
|
4
4
|
import type { DiscriminatorObject, OpenAPI3, SchemaObject } from "../types.js";
|
|
5
5
|
import { addEnumProperty, declaresValues, type EnumPatch } from "./discriminator-enum.js";
|
|
@@ -46,7 +46,7 @@ export interface ScanState extends DiscriminatorScanOptions {
|
|
|
46
46
|
|
|
47
47
|
/** Whether `discriminator-values` is on: values of two discriminators merge into one enum. */
|
|
48
48
|
export function mergesValues(state: ScanState): boolean {
|
|
49
|
-
return state.fixes.has(
|
|
49
|
+
return state.fixes.has(FIX.DISCRIMINATOR_VALUES);
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function patchedSchema(state: ScanState, patch: EnumPatch): SchemaObject | undefined {
|
|
@@ -60,8 +60,7 @@ function patchedSchema(state: ScanState, patch: EnumPatch): SchemaObject | undef
|
|
|
60
60
|
*/
|
|
61
61
|
function isDeclared(state: ScanState, patch: EnumPatch): boolean {
|
|
62
62
|
return (
|
|
63
|
-
state.fixes.has(
|
|
64
|
-
declaresValues(patchedSchema(state, patch), patch)
|
|
63
|
+
state.fixes.has(FIX.DISCRIMINATOR_VALUES) && declaresValues(patchedSchema(state, patch), patch)
|
|
65
64
|
);
|
|
66
65
|
}
|
|
67
66
|
|
|
@@ -70,7 +69,7 @@ function isDeclared(state: ScanState, patch: EnumPatch): boolean {
|
|
|
70
69
|
* added, or a discriminator object that a schema inherited.
|
|
71
70
|
*/
|
|
72
71
|
export function recordEnumParent(state: ScanState, owner: DiscriminatorOwner, key: object): void {
|
|
73
|
-
if (!state.fixes.has(
|
|
72
|
+
if (!state.fixes.has(FIX.DISCRIMINATOR_VALUES)) {
|
|
74
73
|
return;
|
|
75
74
|
}
|
|
76
75
|
const { silent, logger } = state;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Logger } from "../application/ports/logger.js";
|
|
2
2
|
import { isUnionMember, unionAt } from "../domain/openapi/discriminated-union.js";
|
|
3
|
-
import {
|
|
3
|
+
import { FIX } from "../domain/output-fixes.js";
|
|
4
4
|
import type {
|
|
5
5
|
DiscriminatorObject,
|
|
6
6
|
GeneratorOptions,
|
|
@@ -121,7 +121,7 @@ function valuesMappedTo(discriminator: DiscriminatorObject, ref: string): string
|
|
|
121
121
|
* schema that the union's mapping names is a member.
|
|
122
122
|
*/
|
|
123
123
|
function inheritsDiscriminator(state: ScanState, parentRef: string, ref: string): boolean {
|
|
124
|
-
if (!state.fixes.has(
|
|
124
|
+
if (!state.fixes.has(FIX.ALLOF_DISCRIMINATED_UNION)) {
|
|
125
125
|
return true;
|
|
126
126
|
}
|
|
127
127
|
const resolve = (target: string) => resolveDocumentRef(state.schema, target, state);
|
|
@@ -141,7 +141,7 @@ function recordInherited(
|
|
|
141
141
|
discriminator: DiscriminatorObject,
|
|
142
142
|
ownerRef: string,
|
|
143
143
|
): void {
|
|
144
|
-
if (state.fixes.has(
|
|
144
|
+
if (state.fixes.has(FIX.DISCRIMINATOR_VALUES) && state.owners.has(ref)) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
const inherited = { ...discriminator };
|
package/src/api/document-run.ts
CHANGED
|
@@ -2,6 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
3
|
import type { Config as RedoclyConfig } from "@redocly/openapi-core";
|
|
4
4
|
import { sourceEmptyError } from "../adapters/redocly-loader/schema-load-errors.js";
|
|
5
|
+
import type { DeprecationReporter } from "../application/ports/deprecation-reporter.js";
|
|
5
6
|
import type { Logger } from "../application/ports/logger.js";
|
|
6
7
|
import type { RefAccess, SchemaLoader } from "../application/ports/schema-loader.js";
|
|
7
8
|
import { withStackOverflowReported } from "../application/stack-overflow.js";
|
|
@@ -25,6 +26,8 @@ import { warnUnsupportedFeatures } from "./unsupported-feature-warnings.js";
|
|
|
25
26
|
export interface GeneratorPorts {
|
|
26
27
|
readonly loader: SchemaLoader;
|
|
27
28
|
readonly logger: Logger;
|
|
29
|
+
/** Where the run reports the deprecated callback forms (ADR-004). */
|
|
30
|
+
readonly deprecations: DeprecationReporter;
|
|
28
31
|
/** The Redocly config the loader uses; the run's context exposes it as `ctx.redoc`. */
|
|
29
32
|
readonly redoc: RedoclyConfig;
|
|
30
33
|
/** A monotonic time in milliseconds, for debug durations. */
|
|
@@ -47,6 +50,7 @@ type ContextFlags = Omit<
|
|
|
47
50
|
| "runFooter"
|
|
48
51
|
| "legacyCallbackWarnings"
|
|
49
52
|
| "logger"
|
|
53
|
+
| "deprecations"
|
|
50
54
|
| "fix"
|
|
51
55
|
>;
|
|
52
56
|
|
|
@@ -175,6 +179,7 @@ export async function createDocumentRun(
|
|
|
175
179
|
redoc: ports.redoc,
|
|
176
180
|
resolve: ($ref) => resolveDocumentRef(schema, $ref, { silent, logger }),
|
|
177
181
|
logger,
|
|
182
|
+
deprecations: ports.deprecations,
|
|
178
183
|
};
|
|
179
184
|
return { schema, ctx };
|
|
180
185
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DEPRECATION_CODES, type DeprecationCode } from "../domain/deprecations.js";
|
|
2
2
|
import type { LegacyCallbackName } from "../types.js";
|
|
3
|
-
import {
|
|
3
|
+
import { defaultDeprecationReporter } from "./default-ports.js";
|
|
4
4
|
import type { RunContext } from "./run-context.js";
|
|
5
5
|
|
|
6
6
|
/** Where the IR callbacks are documented; the warning points users there. */
|
|
@@ -13,6 +13,12 @@ const USES: Readonly<Record<LegacyCallbackName, string>> = {
|
|
|
13
13
|
transformProperty: "`transformProperty` receives TypeScript nodes",
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
const CODES: Readonly<Record<LegacyCallbackName, DeprecationCode>> = {
|
|
17
|
+
transform: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_TRANSFORM,
|
|
18
|
+
postTransform: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_POST_TRANSFORM,
|
|
19
|
+
transformProperty: DEPRECATION_CODES.OPENAPI_TYPESAFE_DEP_TS_TRANSFORM_PROPERTY,
|
|
20
|
+
};
|
|
21
|
+
|
|
16
22
|
function message(name: LegacyCallbackName): string {
|
|
17
23
|
return (
|
|
18
24
|
`${USES[name]}. This form works in 1.x through the TypeScript bridge and is removed in 2.0. ` +
|
|
@@ -20,14 +26,15 @@ function message(name: LegacyCallbackName): string {
|
|
|
20
26
|
);
|
|
21
27
|
}
|
|
22
28
|
|
|
23
|
-
/**
|
|
29
|
+
/**
|
|
30
|
+
* Report a deprecated callback form once per run and callback, as a deprecation (not through the
|
|
31
|
+
* logger, so `silent` does not hide it). The Node.js reporter shows each code once per process.
|
|
32
|
+
*/
|
|
24
33
|
export function warnLegacyCallback(ctx: RunContext, name: LegacyCallbackName): void {
|
|
25
34
|
ctx.legacyCallbackWarnings ??= new Set();
|
|
26
35
|
if (ctx.legacyCallbackWarnings.has(name)) {
|
|
27
36
|
return;
|
|
28
37
|
}
|
|
29
38
|
ctx.legacyCallbackWarnings.add(name);
|
|
30
|
-
(ctx.
|
|
31
|
-
warningText(message(name), WARNING_CODES.LEGACY_CALLBACK_DEPRECATED),
|
|
32
|
-
);
|
|
39
|
+
(ctx.deprecations ?? defaultDeprecationReporter()).report(CODES[name], message(name));
|
|
33
40
|
}
|
package/src/api/openapi-ts.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { IrDeclaration } from "../domain/ir/nodes.js";
|
|
|
4
4
|
import type { GeneratorOptions, SchemaSource } from "../types.js";
|
|
5
5
|
import {
|
|
6
6
|
DEFAULT_REMOTE_DOCUMENT_LIMITS,
|
|
7
|
+
defaultDeprecationReporter,
|
|
7
8
|
defaultLogger,
|
|
8
9
|
defaultRedoclyConfig,
|
|
9
10
|
monotonicNow,
|
|
@@ -34,7 +35,10 @@ export async function generateDeclarations(
|
|
|
34
35
|
return result;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* The default ports: the terminal logger, Node.js deprecation warnings, the given or default
|
|
40
|
+
* Redocly config, Redocly loading.
|
|
41
|
+
*/
|
|
38
42
|
export async function defaultGeneratorPorts(options: GeneratorOptions): Promise<GeneratorPorts> {
|
|
39
43
|
const logger = defaultLogger(options.silent ?? false);
|
|
40
44
|
const redoc = options.redocly ?? (await defaultRedoclyConfig());
|
|
@@ -45,7 +49,7 @@ export async function defaultGeneratorPorts(options: GeneratorOptions): Promise<
|
|
|
45
49
|
remoteRefTimeoutMs: REMOTE_REF_TIMEOUT_MS,
|
|
46
50
|
remoteDocumentLimits: DEFAULT_REMOTE_DOCUMENT_LIMITS,
|
|
47
51
|
});
|
|
48
|
-
return { loader, logger, redoc, now: monotonicNow };
|
|
52
|
+
return { loader, logger, deprecations: defaultDeprecationReporter(), redoc, now: monotonicNow };
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
/**
|
package/src/api/run-context.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DeprecationReporter } from "../application/ports/deprecation-reporter.js";
|
|
1
2
|
import type { Logger } from "../application/ports/logger.js";
|
|
2
3
|
import type { DocumentFooter } from "../application/transform/transform-context.js";
|
|
3
4
|
import type { GlobalContext, LegacyCallbackName, SchemaObject } from "../types.js";
|
|
@@ -31,4 +32,6 @@ export interface RunContext extends GlobalContext {
|
|
|
31
32
|
legacyCallbackWarnings?: Set<LegacyCallbackName>;
|
|
32
33
|
/** Where this run reports warnings and debug output; without it, the terminal. */
|
|
33
34
|
logger?: Logger;
|
|
35
|
+
/** Where this run reports deprecated forms; without it, Node.js `DeprecationWarning`s. */
|
|
36
|
+
deprecations?: DeprecationReporter;
|
|
34
37
|
}
|