openapi-typesafe 1.0.0-rc.1 → 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/README.md +12 -5
- 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/adapters/redocly-loader/configured-headers.cjs +32 -0
- package/dist/adapters/redocly-loader/configured-headers.cjs.map +1 -0
- package/dist/adapters/redocly-loader/configured-headers.mjs +30 -0
- package/dist/adapters/redocly-loader/configured-headers.mjs.map +1 -0
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs +19 -6
- package/dist/adapters/redocly-loader/redocly-schema-loader.cjs.map +1 -1
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs +18 -5
- package/dist/adapters/redocly-loader/redocly-schema-loader.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.cjs +37 -4
- package/dist/adapters/redocly-loader/ref-access.cjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-access.mjs +37 -4
- package/dist/adapters/redocly-loader/ref-access.mjs.map +1 -1
- package/dist/adapters/redocly-loader/ref-resolution-check.cjs +191 -0
- package/dist/adapters/redocly-loader/ref-resolution-check.cjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-resolution-check.mjs +189 -0
- package/dist/adapters/redocly-loader/ref-resolution-check.mjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.cjs +73 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.cjs.map +1 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.mjs +60 -0
- package/dist/adapters/redocly-loader/ref-resolution-steps.mjs.map +1 -0
- package/dist/adapters/redocly-loader/remote-fetch.cjs +41 -14
- package/dist/adapters/redocly-loader/remote-fetch.cjs.map +1 -1
- package/dist/adapters/redocly-loader/remote-fetch.mjs +40 -14
- package/dist/adapters/redocly-loader/remote-fetch.mjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-load-errors.cjs +23 -5
- package/dist/adapters/redocly-loader/schema-load-errors.cjs.map +1 -1
- package/dist/adapters/redocly-loader/schema-load-errors.mjs +23 -5
- package/dist/adapters/redocly-loader/schema-load-errors.mjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.cjs +9 -1
- package/dist/adapters/redocly-loader/unsupported-keys.cjs.map +1 -1
- package/dist/adapters/redocly-loader/unsupported-keys.mjs +9 -1
- package/dist/adapters/redocly-loader/unsupported-keys.mjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.cjs +6 -4
- package/dist/adapters/terminal-logger/terminal-logger.cjs.map +1 -1
- package/dist/adapters/terminal-logger/terminal-logger.mjs +6 -4
- package/dist/adapters/terminal-logger/terminal-logger.mjs.map +1 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs +2 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.cjs.map +1 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs +2 -1
- package/dist/adapters/type-ast-bridge/ir-to-typescript.mjs.map +1 -1
- package/dist/adapters/type-ast-bridge/print-typescript.cjs.map +1 -1
- package/dist/adapters/type-ast-bridge/print-typescript.mjs.map +1 -1
- package/dist/api/default-ports.cjs +14 -0
- package/dist/api/default-ports.cjs.map +1 -1
- package/dist/api/default-ports.mjs +12 -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 +8 -4
- package/dist/api/discriminator-patch.cjs.map +1 -1
- package/dist/api/discriminator-patch.mjs +9 -5
- 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-refs.cjs +15 -12
- package/dist/api/document-refs.cjs.map +1 -1
- package/dist/api/document-refs.mjs +15 -12
- package/dist/api/document-refs.mjs.map +1 -1
- package/dist/api/document-run.cjs +6 -3
- package/dist/api/document-run.cjs.map +1 -1
- package/dist/api/document-run.mjs +6 -3
- package/dist/api/document-run.mjs.map +1 -1
- package/dist/api/footer-sink.cjs +25 -2
- package/dist/api/footer-sink.cjs.map +1 -1
- package/dist/api/footer-sink.mjs +25 -2
- package/dist/api/footer-sink.mjs.map +1 -1
- package/dist/api/legacy-callback-warning.cjs +7 -1
- package/dist/api/legacy-callback-warning.cjs.map +1 -1
- package/dist/api/legacy-callback-warning.mjs +8 -2
- package/dist/api/legacy-callback-warning.mjs.map +1 -1
- package/dist/api/legacy-ts-helpers.cjs.map +1 -1
- package/dist/api/legacy-ts-helpers.mjs.map +1 -1
- package/dist/api/legacy-utils.cjs.map +1 -1
- package/dist/api/legacy-utils.mjs.map +1 -1
- package/dist/api/openapi-ts.cjs +3 -2
- package/dist/api/openapi-ts.cjs.map +1 -1
- package/dist/api/openapi-ts.mjs +4 -3
- 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-context.cjs +1 -1
- package/dist/api/transform-context.cjs.map +1 -1
- package/dist/api/transform-context.mjs +1 -1
- package/dist/api/transform-context.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/print/type-printer.cjs +2 -1
- package/dist/application/print/type-printer.cjs.map +1 -1
- package/dist/application/print/type-printer.mjs +2 -1
- package/dist/application/print/type-printer.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 +2 -2
- package/dist/application/transform/document/parameters.cjs.map +1 -1
- package/dist/application/transform/document/parameters.mjs +3 -3
- package/dist/application/transform/document/parameters.mjs.map +1 -1
- package/dist/application/transform/document/paths.cjs +2 -2
- package/dist/application/transform/document/paths.cjs.map +1 -1
- package/dist/application/transform/document/paths.mjs +3 -3
- package/dist/application/transform/document/paths.mjs.map +1 -1
- package/dist/application/transform/footer/evaluation.cjs +9 -0
- package/dist/application/transform/footer/evaluation.cjs.map +1 -1
- package/dist/application/transform/footer/evaluation.mjs +8 -1
- package/dist/application/transform/footer/evaluation.mjs.map +1 -1
- package/dist/application/transform/footer/type-evaluation.cjs +4 -112
- package/dist/application/transform/footer/type-evaluation.cjs.map +1 -1
- package/dist/application/transform/footer/type-evaluation.mjs +4 -112
- package/dist/application/transform/footer/type-evaluation.mjs.map +1 -1
- package/dist/application/transform/footer/type-indexing.cjs +107 -0
- package/dist/application/transform/footer/type-indexing.cjs.map +1 -0
- package/dist/application/transform/footer/type-indexing.mjs +105 -0
- package/dist/application/transform/footer/type-indexing.mjs.map +1 -0
- 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/cli/api-settings.cjs +78 -0
- package/dist/cli/api-settings.cjs.map +1 -0
- package/dist/cli/api-settings.mjs +73 -0
- package/dist/cli/api-settings.mjs.map +1 -0
- package/dist/cli/cli-arguments.cjs +1 -0
- package/dist/cli/cli-arguments.cjs.map +1 -1
- package/dist/cli/cli-arguments.mjs +1 -1
- package/dist/cli/cli-arguments.mjs.map +1 -1
- package/dist/cli/help-text.cjs +3 -3
- package/dist/cli/help-text.cjs.map +1 -1
- package/dist/cli/help-text.mjs +3 -3
- package/dist/cli/help-text.mjs.map +1 -1
- package/dist/cli/redocly-apis.cjs +8 -4
- package/dist/cli/redocly-apis.cjs.map +1 -1
- package/dist/cli/redocly-apis.mjs +7 -3
- package/dist/cli/redocly-apis.mjs.map +1 -1
- package/dist/cli/run-cli.cjs +5 -1
- package/dist/cli/run-cli.cjs.map +1 -1
- package/dist/cli/run-cli.mjs +5 -1
- package/dist/cli/run-cli.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 +4 -1
- package/dist/domain/errors.cjs.map +1 -1
- package/dist/domain/errors.mjs +4 -1
- package/dist/domain/errors.mjs.map +1 -1
- package/dist/domain/ir/constructors.cjs +2 -0
- package/dist/domain/ir/constructors.cjs.map +1 -1
- package/dist/domain/ir/constructors.mjs +2 -1
- package/dist/domain/ir/constructors.mjs.map +1 -1
- package/dist/domain/openapi/path-templates.cjs +1 -1
- package/dist/domain/openapi/path-templates.cjs.map +1 -1
- package/dist/domain/openapi/path-templates.mjs +1 -1
- package/dist/domain/openapi/path-templates.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/url-credentials.cjs +10 -0
- package/dist/domain/url-credentials.cjs.map +1 -0
- package/dist/domain/url-credentials.mjs +8 -0
- package/dist/domain/url-credentials.mjs.map +1 -0
- package/dist/domain/warnings.cjs +8 -1
- package/dist/domain/warnings.cjs.map +1 -1
- package/dist/domain/warnings.mjs +8 -1
- package/dist/domain/warnings.mjs.map +1 -1
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1185 -59
- package/dist/index.d.mts +1185 -59
- package/dist/index.d.ts +1185 -59
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/dist/transform/path-item-object.cjs.map +1 -1
- package/dist/transform/path-item-object.mjs.map +1 -1
- package/package.json +5 -4
- package/src/adapters/node-deprecations/node-deprecations.ts +14 -0
- package/src/adapters/redocly-loader/configured-headers.ts +65 -0
- package/src/adapters/redocly-loader/redocly-schema-loader.ts +22 -7
- package/src/adapters/redocly-loader/ref-access.ts +60 -5
- package/src/adapters/redocly-loader/ref-resolution-check.ts +257 -0
- package/src/adapters/redocly-loader/ref-resolution-steps.ts +113 -0
- package/src/adapters/redocly-loader/remote-fetch.ts +77 -21
- package/src/adapters/redocly-loader/schema-load-errors.ts +33 -11
- package/src/adapters/redocly-loader/unsupported-keys.ts +17 -2
- package/src/adapters/terminal-logger/terminal-logger.ts +9 -5
- package/src/adapters/type-ast-bridge/ir-to-typescript.ts +2 -1
- package/src/adapters/type-ast-bridge/print-typescript.ts +3 -1
- package/src/adapters/type-ast-bridge/typescript-types.ts +57 -5
- package/src/api/default-ports.ts +23 -0
- package/src/api/discriminator-conflict-warnings.ts +2 -2
- package/src/api/discriminator-patch.ts +11 -7
- package/src/api/discriminator-scan.ts +3 -3
- package/src/api/document-refs.ts +19 -15
- package/src/api/document-run.ts +14 -6
- package/src/api/footer-sink.ts +34 -2
- package/src/api/legacy-callback-warning.ts +16 -5
- package/src/api/legacy-ts-helpers.ts +7 -5
- package/src/api/legacy-utils.ts +1 -1
- package/src/api/openapi-ts.ts +8 -2
- package/src/api/run-context.ts +37 -0
- package/src/api/string-to-ast.ts +11 -15
- package/src/api/transform-context.ts +10 -8
- package/src/api/transform-schema.ts +9 -8
- package/src/application/ports/deprecation-reporter.ts +9 -0
- package/src/application/print/type-printer.ts +2 -1
- package/src/application/transform/document/components.ts +2 -2
- package/src/application/transform/document/parameters.ts +4 -3
- package/src/application/transform/document/paths.ts +4 -3
- package/src/application/transform/footer/evaluation.ts +10 -0
- package/src/application/transform/footer/type-evaluation.ts +6 -133
- package/src/application/transform/footer/type-indexing.ts +152 -0
- 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/cli/api-settings.ts +109 -0
- package/src/cli/cli-arguments.ts +5 -2
- package/src/cli/help-text.ts +4 -4
- package/src/cli/redocly-apis.ts +13 -7
- package/src/cli/run-cli.ts +5 -1
- package/src/domain/deprecations.ts +15 -0
- package/src/domain/errors.ts +16 -4
- package/src/domain/ir/constructors.ts +3 -0
- package/src/domain/ir/nodes.ts +9 -6
- package/src/domain/openapi/path-templates.ts +2 -1
- package/src/domain/output-fixes.ts +16 -16
- package/src/domain/url-credentials.ts +18 -0
- package/src/domain/warnings.ts +7 -0
- package/src/index.ts +3 -6
- package/src/transform/path-item-object.ts +6 -2
- package/src/types/generator-options.ts +12 -32
- package/src/types/openapi-common.ts +1 -0
- package/src/types/openapi-request.ts +3 -0
- package/src/types/openapi-schema.ts +2 -0
- package/src/types/openapi-security.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import { PathLike } from 'node:fs';
|
|
2
2
|
import { Readable } from 'node:stream';
|
|
3
3
|
import { Config } from '@redocly/openapi-core';
|
|
4
|
-
import
|
|
4
|
+
import * as TypeScript from 'typescript';
|
|
5
5
|
import colors from 'ansi-colors';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Type IR: the closed set of immutable nodes that describes the TypeScript types and declarations
|
|
9
|
+
* the generator emits (ENGINEERING_PLAN §4.2, ADR-002). Nodes are plain readonly data with a `kind`
|
|
10
|
+
* discriminator; every consumer in this package dispatches with an exhaustive `switch`, so a new
|
|
11
|
+
* kind breaks the build wherever it must be handled. For users the set is open: a minor release
|
|
12
|
+
* may add a kind (ADR-034), so code outside the package must keep a node of an unknown kind as it
|
|
13
|
+
* is, and a `switch` over `kind` needs a `default` branch.
|
|
14
|
+
*
|
|
15
|
+
* Utility types (`Omit`, `Record`, `WithRequired`, `Extract`) are `reference` nodes with type
|
|
16
|
+
* arguments, built by named constructors: the printer has nothing special to do for them.
|
|
17
|
+
*/
|
|
18
|
+
/** Keyword types. `null` is a keyword here; TypeScript models it as a literal type. */
|
|
7
19
|
type IrKeyword = "string" | "number" | "boolean" | "null" | "undefined" | "unknown" | "never";
|
|
20
|
+
/**
|
|
21
|
+
* How a string literal is written.
|
|
22
|
+
* - `json`: `JSON.stringify` text, non-ASCII kept as is. The original writes literal types this way
|
|
23
|
+
* to keep UTF-8 readable (TypeScript issue 36174).
|
|
24
|
+
* - `escaped`: TypeScript printer escaping, non-ASCII as `\uXXXX`. The original writes
|
|
25
|
+
* indexed-access keys and quoted property names this way.
|
|
26
|
+
*/
|
|
8
27
|
type IrStringEncoding = "json" | "escaped";
|
|
9
28
|
interface IrKeywordType {
|
|
10
29
|
readonly kind: "keyword";
|
|
@@ -13,8 +32,10 @@ interface IrKeywordType {
|
|
|
13
32
|
interface IrStringLiteralType {
|
|
14
33
|
readonly kind: "stringLiteral";
|
|
15
34
|
readonly value: string;
|
|
16
|
-
|
|
35
|
+
/** How the printer writes the value; unset is `json`. A detail of the printer. */
|
|
36
|
+
readonly encoding?: IrStringEncoding;
|
|
17
37
|
}
|
|
38
|
+
/** Finite number; a negative value prints with a leading minus sign. */
|
|
18
39
|
interface IrNumberLiteralType {
|
|
19
40
|
readonly kind: "numberLiteral";
|
|
20
41
|
readonly value: number;
|
|
@@ -23,6 +44,7 @@ interface IrBooleanLiteralType {
|
|
|
23
44
|
readonly kind: "booleanLiteral";
|
|
24
45
|
readonly value: boolean;
|
|
25
46
|
}
|
|
47
|
+
/** A named type, optionally with type arguments: `components`, `Record<string, never>`. */
|
|
26
48
|
interface IrReferenceType {
|
|
27
49
|
readonly kind: "reference";
|
|
28
50
|
readonly name: string;
|
|
@@ -32,6 +54,7 @@ interface IrArrayType {
|
|
|
32
54
|
readonly kind: "array";
|
|
33
55
|
readonly element: IrType;
|
|
34
56
|
}
|
|
57
|
+
/** A tuple element; `isRest` prints `...T`, `isOptional` prints `T?` (never both). */
|
|
35
58
|
interface IrTupleElement {
|
|
36
59
|
readonly type: IrType;
|
|
37
60
|
readonly isRest: boolean;
|
|
@@ -53,28 +76,48 @@ interface IrObjectType {
|
|
|
53
76
|
readonly kind: "object";
|
|
54
77
|
readonly members: readonly IrMember[];
|
|
55
78
|
}
|
|
79
|
+
/** `object[index]`, for example `components["schemas"]`. */
|
|
56
80
|
interface IrIndexedAccessType {
|
|
57
81
|
readonly kind: "indexedAccess";
|
|
58
82
|
readonly object: IrType;
|
|
59
83
|
readonly index: IrType;
|
|
60
84
|
}
|
|
85
|
+
/** `readonly T` (the only type operator the generator emits). */
|
|
61
86
|
interface IrReadonlyType {
|
|
62
87
|
readonly kind: "readonly";
|
|
63
88
|
readonly type: IrType;
|
|
64
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Text printed as is. Escape hatch for types that come from outside the IR, for example output of
|
|
92
|
+
* legacy `ts.Node` callbacks converted by the type-AST bridge (ENGINEERING_PLAN 6.3). The text is
|
|
93
|
+
* written as if it started at column 0: each line after the first gets the indentation of the
|
|
94
|
+
* position where the type is printed. Known limit: this also indents the continuation lines of a
|
|
95
|
+
* template literal that spans lines, which TypeScript keeps verbatim (ADR-004).
|
|
96
|
+
*/
|
|
65
97
|
interface IrRawType {
|
|
66
98
|
readonly kind: "raw";
|
|
67
99
|
readonly text: string;
|
|
100
|
+
/**
|
|
101
|
+
* @internal The TypeScript node the bridge printed the text from. The reverse bridge (the
|
|
102
|
+
* deprecated `ts.Node` callbacks, ADR-004) hands it back unchanged. Set by the generator only:
|
|
103
|
+
* read it as opaque, never set it, and expect it to go away in 2.0.
|
|
104
|
+
*/
|
|
68
105
|
readonly origin?: unknown;
|
|
69
106
|
}
|
|
70
107
|
type IrType = IrKeywordType | IrStringLiteralType | IrNumberLiteralType | IrBooleanLiteralType | IrReferenceType | IrArrayType | IrTupleType | IrUnionType | IrIntersectionType | IrObjectType | IrIndexedAccessType | IrReadonlyType | IrRawType;
|
|
71
|
-
|
|
108
|
+
/** A comment printed on its own line before a node; a node may have several, printed in order. */
|
|
109
|
+
type IrComment =
|
|
110
|
+
/** `/*text*\/`: `text` is the comment body, for example `* @description Hello `. */
|
|
111
|
+
{
|
|
72
112
|
readonly kind: "block";
|
|
73
113
|
readonly text: string;
|
|
74
|
-
}
|
|
114
|
+
}
|
|
115
|
+
/** `//text`. */
|
|
116
|
+
| {
|
|
75
117
|
readonly kind: "line";
|
|
76
118
|
readonly text: string;
|
|
77
119
|
};
|
|
120
|
+
/** Property key: identifier, quoted string, or number, as decided by `toPropertyName`. */
|
|
78
121
|
type IrPropertyName = {
|
|
79
122
|
readonly kind: "identifier";
|
|
80
123
|
readonly text: string;
|
|
@@ -93,6 +136,7 @@ interface IrPropertySignature {
|
|
|
93
136
|
readonly isReadonly: boolean;
|
|
94
137
|
readonly comments: readonly IrComment[];
|
|
95
138
|
}
|
|
139
|
+
/** `[parameterName: parameterType]: type`. */
|
|
96
140
|
interface IrIndexSignature {
|
|
97
141
|
readonly kind: "indexSignature";
|
|
98
142
|
readonly parameterName: string;
|
|
@@ -116,6 +160,7 @@ interface IrTypeAliasDeclaration {
|
|
|
116
160
|
readonly type: IrType;
|
|
117
161
|
readonly comments: readonly IrComment[];
|
|
118
162
|
}
|
|
163
|
+
/** `name` is printed as given (already sanitized or quoted by the enum naming rules). */
|
|
119
164
|
interface IrEnumMember {
|
|
120
165
|
readonly name: string;
|
|
121
166
|
readonly value: string | number;
|
|
@@ -128,6 +173,7 @@ interface IrEnumDeclaration {
|
|
|
128
173
|
readonly members: readonly IrEnumMember[];
|
|
129
174
|
readonly comments: readonly IrComment[];
|
|
130
175
|
}
|
|
176
|
+
/** `const name: type = [values];` (the `--enum-values` and `--make-paths-enum` arrays). */
|
|
131
177
|
interface IrConstArrayDeclaration {
|
|
132
178
|
readonly kind: "constArray";
|
|
133
179
|
readonly name: string;
|
|
@@ -136,103 +182,235 @@ interface IrConstArrayDeclaration {
|
|
|
136
182
|
readonly values: readonly (string | number)[];
|
|
137
183
|
readonly comments: readonly IrComment[];
|
|
138
184
|
}
|
|
185
|
+
/** A declaration printed as is: footer helpers and injected code. */
|
|
139
186
|
interface IrRawDeclaration {
|
|
140
187
|
readonly kind: "rawDeclaration";
|
|
141
188
|
readonly text: string;
|
|
189
|
+
/** The type name the text declares, when known (helper types), so the footer can find it. */
|
|
142
190
|
readonly name?: string;
|
|
143
191
|
}
|
|
144
192
|
type IrDeclaration = IrInterfaceDeclaration | IrTypeAliasDeclaration | IrEnumDeclaration | IrConstArrayDeclaration | IrRawDeclaration;
|
|
145
193
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
194
|
+
/**
|
|
195
|
+
* The TypeScript compiler's node types for code outside the bridge and for the public
|
|
196
|
+
* declarations (ADR-004, decision 4; ADR-032). Type-only: importing it never loads TypeScript.
|
|
197
|
+
*
|
|
198
|
+
* Each type is read from the compiler API of the `typescript` package the consumer has installed
|
|
199
|
+
* (`factory`, `createPrinter`), not named as `ts.Node`. TypeScript 5.x and 6.x have that API, so
|
|
200
|
+
* the types are the compiler's own. TypeScript 7's `typescript` package exports only `version`;
|
|
201
|
+
* `ts.Node` there is error TS2694 in a consumer that checks declarations (`skipLibCheck: false`).
|
|
202
|
+
*/
|
|
203
|
+
type Api = typeof TypeScript;
|
|
204
|
+
type Factory = Api extends {
|
|
205
|
+
readonly factory: infer F;
|
|
206
|
+
} ? F : undefined;
|
|
207
|
+
/**
|
|
208
|
+
* A compiler type when the installed `typescript` has no compiler API (TypeScript 7). It is `any`
|
|
209
|
+
* because that is what these types already were for such a consumer with `skipLibCheck: true`
|
|
210
|
+
* (an unresolved type in a declaration file is `any`), so callbacks that build or read nodes of
|
|
211
|
+
* `@typescript/typescript6` keep compiling (ADR-032). The cost, as before: a union with a node
|
|
212
|
+
* type, such as the result of `transform`, accepts any value there.
|
|
213
|
+
*/
|
|
214
|
+
type WithoutCompilerApi = any;
|
|
215
|
+
/** The node type that `factory[Name]` returns, or `WithoutCompilerApi`. */
|
|
216
|
+
type Created<Name extends string> = Factory extends {
|
|
217
|
+
readonly [Key in Name]: (...args: never[]) => infer Result;
|
|
218
|
+
} ? Result : WithoutCompilerApi;
|
|
219
|
+
type ModifierList = Created<"createModifiersFromModifierFlags">;
|
|
220
|
+
/** The compiler node types the package names; see the module comment. */
|
|
221
|
+
declare namespace ts {
|
|
222
|
+
type Node = Api extends {
|
|
223
|
+
isTypeNode(node: infer N): boolean;
|
|
224
|
+
} ? N : WithoutCompilerApi;
|
|
225
|
+
type TypeNode = Factory extends {
|
|
226
|
+
createArrayTypeNode(elementType: infer T): unknown;
|
|
227
|
+
} ? T : WithoutCompilerApi;
|
|
228
|
+
type QuestionToken = Factory extends {
|
|
229
|
+
createPropertySignature(modifiers: never, name: never, token: infer Q, type: never): unknown;
|
|
230
|
+
} ? NonNullable<Q> : WithoutCompilerApi;
|
|
231
|
+
type Modifier = ModifierList extends readonly (infer M)[] | undefined ? M : WithoutCompilerApi;
|
|
232
|
+
type PrinterOptions = Api extends {
|
|
233
|
+
createPrinter(options?: infer O, ...rest: never[]): unknown;
|
|
234
|
+
} ? NonNullable<O> : WithoutCompilerApi;
|
|
235
|
+
type PropertySignature = Created<"createPropertySignature">;
|
|
236
|
+
type LiteralTypeNode = Created<"createLiteralTypeNode">;
|
|
237
|
+
type TypeLiteralNode = Created<"createTypeLiteralNode">;
|
|
238
|
+
type InterfaceDeclaration = Created<"createInterfaceDeclaration">;
|
|
239
|
+
type EnumDeclaration = Created<"createEnumDeclaration">;
|
|
240
|
+
type EnumMember = Created<"createEnumMember">;
|
|
241
|
+
type VariableStatement = Created<"createVariableStatement">;
|
|
242
|
+
type Identifier = Created<"createIdentifier">;
|
|
243
|
+
type NumericLiteral = Created<"createNumericLiteral">;
|
|
244
|
+
type StringLiteral = Created<"createStringLiteral">;
|
|
153
245
|
}
|
|
154
246
|
|
|
155
|
-
|
|
247
|
+
/** A footer entry: a declaration in IR, or a TypeScript node added by user code. */
|
|
248
|
+
type FooterEntry = IrDeclaration | ts.Node;
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Opt-in fixes of the output of valid schemas (ADR-021). Each one changes only the cases it names;
|
|
252
|
+
* without any, the output is the same as openapi-typescript 7.13 gives. In 2.0 they become the
|
|
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).
|
|
255
|
+
*/
|
|
256
|
+
declare const FIX: {
|
|
257
|
+
/** An `allOf` `$ref` to a discriminated union is the union, without `Omit` or a schema name. */
|
|
156
258
|
readonly ALLOF_DISCRIMINATED_UNION: "allof-discriminated-union";
|
|
259
|
+
/** An `allOf` member with only `required` makes those properties of the others required. */
|
|
157
260
|
readonly ALLOF_REQUIRED: "allof-required";
|
|
261
|
+
/** The JSDoc of a schema lists the descriptions of its `anyOf` and `oneOf` members. */
|
|
158
262
|
readonly ANYOF_ONEOF_DESCRIPTIONS: "anyof-oneof-descriptions";
|
|
263
|
+
/** `anyOf` / `oneOf` variants with only `required` make those keys of the parent required. */
|
|
159
264
|
readonly ANYOF_ONEOF_REQUIRED: "anyof-oneof-required";
|
|
265
|
+
/** `anyOf` next to object keywords or `allOf` is intersected with them, not added to a union. */
|
|
160
266
|
readonly ANYOF_PROPERTIES: "anyof-properties";
|
|
267
|
+
/** `--array-length` tuples have `min` to `max` items, nest right and follow `--immutable`. */
|
|
161
268
|
readonly ARRAY_LENGTH_TUPLES: "array-length-tuples";
|
|
269
|
+
/** `--dedupe-enums` names a shared enum by all of its schemas, not by the first one. */
|
|
162
270
|
readonly DEDUPE_ENUM_NAMES: "dedupe-enum-names";
|
|
271
|
+
/** `required` next to an `allOf` `$ref` to a discriminator member still gives `WithRequired`. */
|
|
163
272
|
readonly DISCRIMINATOR_MEMBER_REQUIRED: "discriminator-member-required";
|
|
273
|
+
/**
|
|
274
|
+
* The value a discriminator member gets: one enum of every discriminator's values, a mapping
|
|
275
|
+
* before the schema name, a schema's own mapping before an inherited one, none where the member
|
|
276
|
+
* declares it, and with `--enum` a member of the owner's enum.
|
|
277
|
+
*/
|
|
164
278
|
readonly DISCRIMINATOR_VALUES: "discriminator-values";
|
|
279
|
+
/** An exploded object query parameter's properties are keys of `query`, as they are sent. */
|
|
165
280
|
readonly EXPLODED_QUERY_OBJECTS: "exploded-query-objects";
|
|
281
|
+
/** `--enum` declares an enum that lists `null` without it, and the type adds `| null`. */
|
|
166
282
|
readonly NULLABLE_ENUMS: "nullable-enums";
|
|
283
|
+
/** `--path-params-as-types` gives each `{name}` its placeholder, `{number}` included. */
|
|
167
284
|
readonly PATH_PARAM_TYPE_NAMES: "path-param-type-names";
|
|
285
|
+
/** A `prefixItems` tuple is open unless `items` or `unevaluatedItems` closes it (2020-12). */
|
|
168
286
|
readonly PREFIX_ITEMS: "prefix-items";
|
|
287
|
+
/** `readOnly` and `writeOnly` of the schema a `$ref` names, or of `allOf` members, count. */
|
|
169
288
|
readonly READ_WRITE_REFS: "read-write-refs";
|
|
289
|
+
/**
|
|
290
|
+
* A `$ref` into schema keywords (`content/<type>/schema`, `items`, `allOf/0`) gets the type it
|
|
291
|
+
* points at, also where the original type compiles through an index signature.
|
|
292
|
+
*/
|
|
170
293
|
readonly REF_POINTERS: "ref-pointers";
|
|
294
|
+
/** Schemas of one root type name without the prefix each get an alias, the earlier numbered. */
|
|
171
295
|
readonly ROOT_TYPE_NUMBERING: "root-type-numbering";
|
|
296
|
+
/** `unevaluatedProperties` types the keys no other keyword declares (an index signature). */
|
|
172
297
|
readonly UNEVALUATED_PROPERTIES: "unevaluated-properties";
|
|
173
298
|
};
|
|
174
|
-
|
|
299
|
+
/** The name of one opt-in output fix. */
|
|
300
|
+
type OutputFix = (typeof FIX)[keyof typeof FIX];
|
|
301
|
+
/** Every fix of this version, in the order the docs list them. */
|
|
175
302
|
declare const OUTPUT_FIXES: readonly OutputFix[];
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
readonly name: string | undefined;
|
|
181
|
-
readonly description: string | undefined;
|
|
182
|
-
}
|
|
183
|
-
interface EnumDeclarationRequest {
|
|
184
|
-
readonly name: string;
|
|
185
|
-
readonly isComponentSchema: boolean;
|
|
186
|
-
readonly values: readonly (string | number)[];
|
|
187
|
-
readonly metadata: readonly EnumMemberMetadata[];
|
|
188
|
-
readonly isOwnerReference?: boolean;
|
|
189
|
-
}
|
|
190
|
-
interface EnumValuesRequest {
|
|
191
|
-
readonly name: string;
|
|
192
|
-
readonly type: IrType;
|
|
193
|
-
readonly values: readonly (string | number)[];
|
|
194
|
-
}
|
|
195
|
-
interface FooterDeclarations {
|
|
196
|
-
addEnum(request: EnumDeclarationRequest): string;
|
|
197
|
-
enumMembers(name: string): ReadonlyMap<string | number, string>;
|
|
198
|
-
addEnumValues(request: EnumValuesRequest): void;
|
|
199
|
-
requireWithRequired(): void;
|
|
200
|
-
requirePropertyValues(): void;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
interface DocumentFooter extends FooterDeclarations {
|
|
204
|
-
addOperation(build: () => IrPropertySignature): void;
|
|
205
|
-
}
|
|
303
|
+
/** The name that turns on every fix of the installed version. */
|
|
304
|
+
declare const ALL_FIXES = "all";
|
|
305
|
+
/** A name the `fix` option accepts: one fix, or `"all"`. */
|
|
306
|
+
type OutputFixName = OutputFix | typeof ALL_FIXES;
|
|
206
307
|
|
|
207
308
|
interface Extensable {
|
|
208
309
|
[key: `x-${string}`]: any;
|
|
209
310
|
}
|
|
311
|
+
/**
|
|
312
|
+
* [4.8.5] Server Object
|
|
313
|
+
* An object representing a Server.
|
|
314
|
+
*/
|
|
210
315
|
interface ServerObject extends Extensable {
|
|
316
|
+
/**
|
|
317
|
+
* REQUIRED. A URL to the target host. This URL supports Server Variables and MAY be relative, to
|
|
318
|
+
* indicate that the host location is relative to the location where the OpenAPI document is being
|
|
319
|
+
* served. Variable substitutions will be made when a variable is named in {brackets}.
|
|
320
|
+
*/
|
|
211
321
|
url: string;
|
|
322
|
+
/**
|
|
323
|
+
* An optional string describing the host designated by the URL. CommonMark syntax MAY be used for
|
|
324
|
+
* rich text representation.
|
|
325
|
+
*/
|
|
212
326
|
description: string;
|
|
327
|
+
/**
|
|
328
|
+
* A map between a variable name and its value. The value is used for substitution in the server’s
|
|
329
|
+
* URL template.
|
|
330
|
+
*/
|
|
213
331
|
variables: {
|
|
214
332
|
[name: string]: ServerVariableObject;
|
|
215
333
|
};
|
|
216
334
|
}
|
|
335
|
+
/**
|
|
336
|
+
* [4.8.6] Server Variable Object
|
|
337
|
+
* An object representing a Server Variable for server URL template substitution.
|
|
338
|
+
*/
|
|
217
339
|
interface ServerVariableObject extends Extensable {
|
|
340
|
+
/**
|
|
341
|
+
* An enumeration of string values to be used if the substitution options are from a limited set.
|
|
342
|
+
* The array MUST NOT be empty.
|
|
343
|
+
*/
|
|
218
344
|
enum?: string[];
|
|
345
|
+
/**
|
|
346
|
+
* REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value
|
|
347
|
+
* is not supplied. Note this behavior is different than the Schema Object’s treatment of default
|
|
348
|
+
* values, because in those cases parameter values are optional. If the enum is defined, the value
|
|
349
|
+
* MUST exist in the enum’s values.
|
|
350
|
+
*/
|
|
219
351
|
default: string;
|
|
352
|
+
/**
|
|
353
|
+
* An optional description for the server variable. CommonMark syntax MAY be used for rich text
|
|
354
|
+
* representation.
|
|
355
|
+
*/
|
|
220
356
|
description?: string;
|
|
221
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* [4.8.11] External Documentation Object
|
|
360
|
+
* Allows referencing an external resource for extended documentation.
|
|
361
|
+
*/
|
|
222
362
|
interface ExternalDocumentationObject extends Extensable {
|
|
363
|
+
/**
|
|
364
|
+
* A description of the target documentation. CommonMark syntax MAY be used for rich text
|
|
365
|
+
* representation.
|
|
366
|
+
*/
|
|
223
367
|
description?: string;
|
|
368
|
+
/** REQUIRED. The URL for the target documentation. This MUST be in the form of a URL. */
|
|
224
369
|
url: string;
|
|
225
370
|
}
|
|
371
|
+
/**
|
|
372
|
+
* [4.8.23] Reference Object
|
|
373
|
+
* A simple object to allow referencing other components in the OpenAPI document, internally and
|
|
374
|
+
* externally. The $ref string value contains a URI [RFC3986], which identifies the location of the
|
|
375
|
+
* value being referenced. See the rules for resolving Relative References.
|
|
376
|
+
*/
|
|
226
377
|
interface ReferenceObject extends Extensable {
|
|
378
|
+
/** REQUIRED. The reference identifier. This MUST be in the form of a URI. */
|
|
227
379
|
$ref: string;
|
|
380
|
+
/**
|
|
381
|
+
* A short summary which by default SHOULD override that of the referenced component. If the
|
|
382
|
+
* referenced object-type does not allow a summary field, then this field has no effect.
|
|
383
|
+
*/
|
|
228
384
|
summary?: string;
|
|
385
|
+
/**
|
|
386
|
+
* A description which by default SHOULD override that of the referenced component. CommonMark
|
|
387
|
+
* syntax MAY be used for rich text representation. If the referenced object-type does not allow a
|
|
388
|
+
* description field, then this field has no effect.
|
|
389
|
+
*/
|
|
229
390
|
description?: string;
|
|
230
391
|
}
|
|
231
392
|
|
|
393
|
+
/**
|
|
394
|
+
* [4.8.24] Schema Object
|
|
395
|
+
* The Schema Object allows the definition of input and output data types. These types can be
|
|
396
|
+
* objects, but also primitives and arrays. This object is a superset of the JSON Schema
|
|
397
|
+
* Specification Draft 2020-12.
|
|
398
|
+
*/
|
|
232
399
|
type SchemaObject = {
|
|
400
|
+
/**
|
|
401
|
+
* The Schema Object allows the definition of input and output data types. These types can be
|
|
402
|
+
* objects, but also primitives and arrays. This object is a superset of the JSON Schema
|
|
403
|
+
* Specification Draft 2020-12.
|
|
404
|
+
*/
|
|
233
405
|
discriminator?: DiscriminatorObject;
|
|
406
|
+
/**
|
|
407
|
+
* MAY be used only on properties schemas. It has no effect on root schemas. Adds additional
|
|
408
|
+
* metadata to describe the XML representation of this property.
|
|
409
|
+
*/
|
|
234
410
|
xml?: XMLObject;
|
|
411
|
+
/** Additional external documentation for this schema. */
|
|
235
412
|
externalDocs?: ExternalDocumentationObject;
|
|
413
|
+
/** @deprecated */
|
|
236
414
|
example?: any;
|
|
237
415
|
title?: string;
|
|
238
416
|
description?: string;
|
|
@@ -241,12 +419,19 @@ type SchemaObject = {
|
|
|
241
419
|
readOnly?: boolean;
|
|
242
420
|
writeOnly?: boolean;
|
|
243
421
|
enum?: unknown[];
|
|
422
|
+
/**
|
|
423
|
+
* Use of this keyword is functionally equivalent to an "enum" (Section 6.1.2) with a single
|
|
424
|
+
* value.
|
|
425
|
+
*/
|
|
244
426
|
const?: unknown;
|
|
245
427
|
default?: unknown;
|
|
246
428
|
format?: string;
|
|
429
|
+
/** Media type of the string contents (OpenAPI 3.1, JSON Schema 2020-12), e.g. `image/png`. */
|
|
247
430
|
contentMediaType?: string;
|
|
431
|
+
/** How the string's contents are encoded (OpenAPI 3.1, JSON Schema 2020-12), e.g. `base64`. */
|
|
248
432
|
contentEncoding?: string;
|
|
249
433
|
additionalProperties?: boolean | Record<string, never> | SchemaObject | ReferenceObject;
|
|
434
|
+
/** @deprecated in 3.1 (still valid for 3.0) */
|
|
250
435
|
nullable?: boolean;
|
|
251
436
|
oneOf?: (SchemaObject | ReferenceObject)[];
|
|
252
437
|
allOf?: (SchemaObject | ReferenceObject)[];
|
|
@@ -303,307 +488,926 @@ interface ObjectSubtype {
|
|
|
303
488
|
enum?: (SchemaObject | ReferenceObject)[];
|
|
304
489
|
$defs?: $defs;
|
|
305
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* [4.8.25] Discriminator Object
|
|
493
|
+
* When request bodies or response payloads may be one of a number of different schemas, a
|
|
494
|
+
* discriminator object can be used to aid in serialization, deserialization, and validation. The
|
|
495
|
+
* discriminator is a specific object in a schema which is used to inform the consumer of the
|
|
496
|
+
* document of an alternative schema based on the value associated with it.
|
|
497
|
+
*/
|
|
306
498
|
interface DiscriminatorObject {
|
|
499
|
+
/**
|
|
500
|
+
* The name of the property in the payload that will hold the discriminator value. Required
|
|
501
|
+
* before OpenAPI 3.2; typed as required so existing readers keep a `string`.
|
|
502
|
+
*/
|
|
307
503
|
propertyName: string;
|
|
504
|
+
/** An object to hold mappings between payload values and schema names or references. */
|
|
308
505
|
mapping?: Record<string, string>;
|
|
506
|
+
/** The schema for payloads without the property or with an unmapped value (OpenAPI 3.2). */
|
|
309
507
|
defaultMapping?: string;
|
|
508
|
+
/** If this exists, then a discriminator type should be added to objects matching this path */
|
|
310
509
|
oneOf?: string[];
|
|
311
510
|
}
|
|
511
|
+
/**
|
|
512
|
+
* [4.8.26] XML Object
|
|
513
|
+
* A metadata object that allows for more fine-tuned XML model definitions. When using arrays, XML
|
|
514
|
+
* element names are not inferred (for singular/plural forms) and the `name` property SHOULD be used
|
|
515
|
+
* to add that information. See examples for expected behavior.
|
|
516
|
+
*/
|
|
312
517
|
interface XMLObject extends Extensable {
|
|
518
|
+
/**
|
|
519
|
+
* Replaces the name of the element/attribute used for the described schema property. When defined
|
|
520
|
+
* within `items`, it will affect the name of the individual XML elements within the list. When
|
|
521
|
+
* defined alongside `type` being `array` (outside the `items`), it will affect the wrapping
|
|
522
|
+
* element and only if `wrapped` is `true`. If `wrapped` is `false`, it will be ignored.
|
|
523
|
+
*/
|
|
313
524
|
name?: string;
|
|
525
|
+
/** The URI of the namespace definition. This MUST be in the form of an absolute URI. */
|
|
314
526
|
namespace?: string;
|
|
527
|
+
/** The prefix to be used for the name. */
|
|
315
528
|
prefix?: string;
|
|
529
|
+
/**
|
|
530
|
+
* Declares whether the property definition translates to an attribute instead of an element.
|
|
531
|
+
* Default value is `false`.
|
|
532
|
+
*/
|
|
316
533
|
attribute?: boolean;
|
|
534
|
+
/**
|
|
535
|
+
* MAY be used only for an array definition. Signifies whether the array is wrapped (for example,
|
|
536
|
+
* `<books><book/><book/></books>`) or unwrapped (`<book/><book/>`). Default value is `false`. The
|
|
537
|
+
* definition takes effect only when defined alongside `type` being `array` (outside the `items`).
|
|
538
|
+
*/
|
|
317
539
|
wrapped?: boolean;
|
|
318
540
|
}
|
|
541
|
+
/** The `$defs` of a Schema Object: named subschemas. */
|
|
319
542
|
type $defs = Record<string, SchemaObject>;
|
|
320
543
|
|
|
544
|
+
/**
|
|
545
|
+
* [4.8.12] Parameter Object
|
|
546
|
+
* Describes a single operation parameter.
|
|
547
|
+
* A unique parameter is defined by a combination of a name and location.
|
|
548
|
+
*/
|
|
321
549
|
interface ParameterObject extends Extensable {
|
|
550
|
+
/**
|
|
551
|
+
* REQUIRED. The name of the parameter. Parameter names are case sensitive.
|
|
552
|
+
*
|
|
553
|
+
* - If `in` is `"path"`, the `name` field MUST correspond to a template expression occurring
|
|
554
|
+
* within the path field in the Paths Object. See Path Templating for further information.
|
|
555
|
+
* - If `in` is `"header"` and the `name` field is `"Accept"`, `"Content-Type"` or
|
|
556
|
+
* `"Authorization"`, the parameter definition SHALL be ignored.
|
|
557
|
+
* - For all other cases, the `name` corresponds to the parameter name used by the `in` property.
|
|
558
|
+
*/
|
|
322
559
|
name: string;
|
|
560
|
+
/**
|
|
561
|
+
* REQUIRED. The location of the parameter. Possible values are "query", "header", "path",
|
|
562
|
+
* "cookie", or "querystring" (OpenAPI 3.2: the whole query string, described by `content`).
|
|
563
|
+
*/
|
|
323
564
|
in: "query" | "header" | "path" | "cookie" | "querystring";
|
|
565
|
+
/**
|
|
566
|
+
* A brief description of the parameter. This could contain examples of use. CommonMark syntax MAY
|
|
567
|
+
* be used for rich text representation.
|
|
568
|
+
*/
|
|
324
569
|
description?: string;
|
|
570
|
+
/**
|
|
571
|
+
* Determines whether this parameter is mandatory. If the parameter location is "path", this
|
|
572
|
+
* property is REQUIRED and its value MUST be true. Otherwise, the property MAY be included and
|
|
573
|
+
* its default value is false.
|
|
574
|
+
*/
|
|
325
575
|
required?: boolean;
|
|
576
|
+
/**
|
|
577
|
+
* Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value
|
|
578
|
+
* is false.
|
|
579
|
+
*/
|
|
326
580
|
deprecated?: boolean;
|
|
581
|
+
/**
|
|
582
|
+
* Sets the ability to pass empty-valued parameters. This is valid only for query parameters and
|
|
583
|
+
* allows sending a parameter with an empty value. Default value is false. If style is used, and
|
|
584
|
+
* if behavior is n/a (cannot be serialized), the value of allowEmptyValue SHALL be ignored. Use
|
|
585
|
+
* of this property is NOT RECOMMENDED, as it is likely to be removed in a later revision.
|
|
586
|
+
*/
|
|
327
587
|
allowEmptyValue?: boolean;
|
|
588
|
+
/**
|
|
589
|
+
* Describes how the parameter value will be serialized depending on the type of the parameter
|
|
590
|
+
* value. Default values (based on value of in): for query - form; for path - simple; for header -
|
|
591
|
+
* simple; for cookie - form.
|
|
592
|
+
*/
|
|
328
593
|
style?: string;
|
|
594
|
+
/**
|
|
595
|
+
* When this is true, parameter values of type `array` or `object` generate separate parameters
|
|
596
|
+
* for each value of the array or key-value pair of the map. For other types of parameters this
|
|
597
|
+
* property has no effect. When `style` is `form`, the default value is `true`. For all other
|
|
598
|
+
* styles, the default value is `false`.
|
|
599
|
+
*/
|
|
329
600
|
explode?: boolean;
|
|
601
|
+
/**
|
|
602
|
+
* Determines whether the parameter value SHOULD allow reserved characters, as defined by
|
|
603
|
+
* [RFC3986] `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. This property only
|
|
604
|
+
* applies to parameters with an `in` value of `query`. The default value is `false`.
|
|
605
|
+
*/
|
|
330
606
|
allowReserved?: boolean;
|
|
607
|
+
/** The schema defining the type used for the parameter. */
|
|
331
608
|
schema?: SchemaObject;
|
|
609
|
+
/** Example of the parameter’s potential value. */
|
|
332
610
|
example?: any;
|
|
611
|
+
/** Examples of the parameter’s potential value. */
|
|
333
612
|
examples?: {
|
|
334
613
|
[name: string]: ExampleObject | ReferenceObject;
|
|
335
614
|
};
|
|
615
|
+
/** A map containing the representations for the parameter. */
|
|
336
616
|
content?: {
|
|
337
617
|
[contentType: string]: MediaTypeObject | ReferenceObject;
|
|
338
618
|
};
|
|
339
619
|
}
|
|
620
|
+
/**
|
|
621
|
+
* [4.8.13] Request Body Object
|
|
622
|
+
* Describes a single request body.
|
|
623
|
+
*/
|
|
340
624
|
interface RequestBodyObject extends Extensable {
|
|
625
|
+
/**
|
|
626
|
+
* A brief description of the request body. This could contain examples of use. CommonMark syntax
|
|
627
|
+
* MAY be used for rich text representation.
|
|
628
|
+
*/
|
|
341
629
|
description?: string;
|
|
630
|
+
/**
|
|
631
|
+
* REQUIRED. The content of the request body. The key is a media type or media type range and the
|
|
632
|
+
* value describes it. For requests that match multiple keys, only the most specific key is
|
|
633
|
+
* applicable. e.g. text/plain overrides text
|
|
634
|
+
*/
|
|
342
635
|
content: {
|
|
343
636
|
[contentType: string]: MediaTypeObject | ReferenceObject;
|
|
344
637
|
};
|
|
638
|
+
/** Determines if the request body is required in the request. Defaults to false. */
|
|
345
639
|
required?: boolean;
|
|
346
640
|
}
|
|
641
|
+
/**
|
|
642
|
+
* [4.8.14] Media Type Object
|
|
643
|
+
*/
|
|
347
644
|
interface MediaTypeObject extends Extensable {
|
|
645
|
+
/** The schema defining the content of the request, response, or parameter. */
|
|
348
646
|
schema?: SchemaObject | ReferenceObject;
|
|
647
|
+
/**
|
|
648
|
+
* The schema of each item of a sequential media type such as `application/jsonl` or
|
|
649
|
+
* `text/event-stream` (OpenAPI 3.2).
|
|
650
|
+
*/
|
|
349
651
|
itemSchema?: SchemaObject | ReferenceObject;
|
|
652
|
+
/**
|
|
653
|
+
* Example of the media type. The example object SHOULD be in the correct format as specified by
|
|
654
|
+
* the media type. The example field is mutually exclusive of the examples field. Furthermore, if
|
|
655
|
+
* referencing a schema which contains an example, the example value SHALL override the example
|
|
656
|
+
* provided by the schema.
|
|
657
|
+
*/
|
|
350
658
|
example?: any;
|
|
659
|
+
/**
|
|
660
|
+
* Examples of the media type. Each example object SHOULD match the media type and specified
|
|
661
|
+
* schema if present. The examples field is mutually exclusive of the example field. Furthermore,
|
|
662
|
+
* if referencing a schema which contains an example, the examples value SHALL override the
|
|
663
|
+
* example provided by the schema.
|
|
664
|
+
*/
|
|
351
665
|
examples?: {
|
|
352
666
|
[name: string]: ExampleObject | ReferenceObject;
|
|
353
667
|
};
|
|
668
|
+
/**
|
|
669
|
+
* A map between a property name and its encoding information. The key, being the property name,
|
|
670
|
+
* MUST exist in the schema as a property. The encoding object SHALL only apply to requestBody
|
|
671
|
+
* objects when the media type is multipart or application/x-www-form-urlencoded.
|
|
672
|
+
*/
|
|
354
673
|
encoding?: {
|
|
355
674
|
[propertyName: string]: EncodingObject;
|
|
356
675
|
};
|
|
357
676
|
}
|
|
677
|
+
/**
|
|
678
|
+
* [4.8.15] Encoding Object
|
|
679
|
+
* A single encoding definition applied to a single schema property.
|
|
680
|
+
*/
|
|
358
681
|
interface EncodingObject extends Extensable {
|
|
682
|
+
/**
|
|
683
|
+
* The Content-Type for encoding a specific property. Default value depends on the property type:
|
|
684
|
+
* for object - application/json; for array – the default is defined based on the inner type; for
|
|
685
|
+
* all other cases the default is application/octet-stream. The value can be a specific media type
|
|
686
|
+
* (e.g. application/json), a wildcard media type (e.g. image/*), or a comma-separated list of the
|
|
687
|
+
* two types.
|
|
688
|
+
*/
|
|
359
689
|
contentType?: string;
|
|
690
|
+
/**
|
|
691
|
+
* A map allowing additional information to be provided as headers, for example
|
|
692
|
+
* Content-Disposition. Content-Type is described separately and SHALL be ignored in this section.
|
|
693
|
+
* This property SHALL be ignored if the request body media type is not a multipart.
|
|
694
|
+
*/
|
|
360
695
|
headers?: {
|
|
361
696
|
[name: string]: HeaderObject | ReferenceObject;
|
|
362
697
|
};
|
|
698
|
+
/**
|
|
699
|
+
* Describes how a specific property value will be serialized depending on its type. See Parameter
|
|
700
|
+
* Object for details on the style property. The behavior follows the same values as query
|
|
701
|
+
* parameters, including default values. This property SHALL be ignored if the request body media
|
|
702
|
+
* type is not application/x-www-form-urlencoded or multipart/form-data. If a value is explicitly
|
|
703
|
+
* defined, then the value of contentType (implicit or explicit) SHALL be ignored.
|
|
704
|
+
*/
|
|
363
705
|
style?: string;
|
|
706
|
+
/**
|
|
707
|
+
* When this is true, property values of type array or object generate separate parameters for
|
|
708
|
+
* each value of the array, or key-value-pair of the map. For other types of properties this
|
|
709
|
+
* property has no effect. When style is form, the default value is true. For all other styles,
|
|
710
|
+
* the default value is false. This property SHALL be ignored if the request body media type is
|
|
711
|
+
* not application/x-www-form-urlencoded or multipart/form-data. If a value is explicitly defined,
|
|
712
|
+
* then the value of contentType (implicit or explicit) SHALL be ignored.
|
|
713
|
+
*/
|
|
364
714
|
explode?: string;
|
|
715
|
+
/**
|
|
716
|
+
* Determines whether the parameter value SHOULD allow reserved characters, as defined by
|
|
717
|
+
* [RFC3986] :/?#[]@!$&'()*+,;= to be included without percent-encoding. The default value is
|
|
718
|
+
* false. This property SHALL be ignored if the request body media type is not
|
|
719
|
+
* application/x-www-form-urlencoded or multipart/form-data. If a value is explicitly defined,
|
|
720
|
+
* then the value of contentType (implicit or explicit) SHALL be ignored.
|
|
721
|
+
*/
|
|
365
722
|
allowReserved?: string;
|
|
366
723
|
}
|
|
724
|
+
/**
|
|
725
|
+
* [4.8.19[ Example Object
|
|
726
|
+
*/
|
|
367
727
|
interface ExampleObject extends Extensable {
|
|
728
|
+
/** Short description for the example. */
|
|
368
729
|
summary?: string;
|
|
730
|
+
/**
|
|
731
|
+
* Long description for the example. CommonMark syntax MAY be used for rich text representation.
|
|
732
|
+
*/
|
|
369
733
|
description?: string;
|
|
734
|
+
/**
|
|
735
|
+
* Embedded literal example. The value field and externalValue field are mutually exclusive. To
|
|
736
|
+
* represent examples of media types that cannot naturally represented in JSON or YAML, use a
|
|
737
|
+
* string value to contain the example, escaping where necessary.
|
|
738
|
+
*/
|
|
370
739
|
value?: any;
|
|
740
|
+
/**
|
|
741
|
+
* A URI that points to the literal example. This provides the capability to reference examples
|
|
742
|
+
* that cannot easily be included in JSON or YAML documents. The value field and externalValue
|
|
743
|
+
* field are mutually exclusive. See the rules for resolving Relative References.
|
|
744
|
+
*/
|
|
371
745
|
externalValue?: string;
|
|
372
746
|
}
|
|
747
|
+
/**
|
|
748
|
+
* [4.8.21] Header Object
|
|
749
|
+
* The Header Object follows the structure of the Parameter Object with the following changes:
|
|
750
|
+
*
|
|
751
|
+
* 1. `name` MUST NOT be specified, it is given in the corresponding `headers` map.
|
|
752
|
+
* 2. `in` MUST NOT be specified, it is implicitly in `header`.
|
|
753
|
+
* 3. All traits that are affected by the location MUST be applicable to a location of `heade`r (for
|
|
754
|
+
* example, `style`).
|
|
755
|
+
*/
|
|
373
756
|
type HeaderObject = Omit<ParameterObject, "name" | "in">;
|
|
374
757
|
|
|
758
|
+
/**
|
|
759
|
+
* [4.8.16] Responses Object
|
|
760
|
+
* A container for the expected responses of an operation. The container maps a HTTP response code
|
|
761
|
+
* to the expected response.
|
|
762
|
+
*/
|
|
375
763
|
type ResponsesObject = {
|
|
376
764
|
[responseCode: string]: ResponseObject | ReferenceObject;
|
|
377
765
|
} & {
|
|
766
|
+
/**
|
|
767
|
+
* The documentation of responses other than the ones declared for specific HTTP response codes.
|
|
768
|
+
* Use this field to cover undeclared responses.
|
|
769
|
+
*/
|
|
378
770
|
default?: ResponseObject | ReferenceObject;
|
|
379
771
|
};
|
|
772
|
+
/**
|
|
773
|
+
* [4.8.17] Response Object
|
|
774
|
+
* Describes a single response from an API Operation, including design-time, static links to
|
|
775
|
+
* operations based on the response.
|
|
776
|
+
*/
|
|
380
777
|
interface ResponseObject extends Extensable {
|
|
778
|
+
/**
|
|
779
|
+
* REQUIRED. A description of the response. CommonMark syntax MAY be used for rich text
|
|
780
|
+
* representation.
|
|
781
|
+
*/
|
|
381
782
|
description: string;
|
|
783
|
+
/**
|
|
784
|
+
* Maps a header name to its definition. [RFC7230] states header names are case insensitive. If a
|
|
785
|
+
* response header is defined with the name "Content-Type", it SHALL be ignored.
|
|
786
|
+
*/
|
|
382
787
|
headers?: {
|
|
383
788
|
[name: string]: HeaderObject | ReferenceObject;
|
|
384
789
|
};
|
|
790
|
+
/**
|
|
791
|
+
* A map containing descriptions of potential response payloads. The key is a media type or media
|
|
792
|
+
* type range and the value describes it. For responses that match multiple keys, only the most
|
|
793
|
+
* specific key is applicable. e.g. text/plain overrides text
|
|
794
|
+
*/
|
|
385
795
|
content?: {
|
|
386
796
|
[contentType: string]: MediaTypeObject;
|
|
387
797
|
};
|
|
798
|
+
/**
|
|
799
|
+
* A map of operations links that can be followed from the response. The key of the map is a short
|
|
800
|
+
* name for the link, following the naming constraints of the names for Component Objects.
|
|
801
|
+
*/
|
|
388
802
|
links?: {
|
|
389
803
|
[name: string]: LinkObject | ReferenceObject;
|
|
390
804
|
};
|
|
391
805
|
}
|
|
806
|
+
/**
|
|
807
|
+
* [4.8.20] Link Object
|
|
808
|
+
* The Link object represents a possible design-time link for a response. The presence of a link
|
|
809
|
+
* does not guarantee the caller’s ability to successfully invoke it, rather it provides a known
|
|
810
|
+
* relationship and traversal mechanism between responses and other operations.
|
|
811
|
+
*/
|
|
392
812
|
interface LinkObject extends Extensable {
|
|
813
|
+
/**
|
|
814
|
+
* A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of
|
|
815
|
+
* the operationId field, and MUST point to an Operation Object. Relative operationRef values MAY
|
|
816
|
+
* be used to locate an existing Operation Object in the OpenAPI definition. See the rules for
|
|
817
|
+
* resolving Relative References.
|
|
818
|
+
*/
|
|
393
819
|
operationRef?: string;
|
|
820
|
+
/**
|
|
821
|
+
* The name of an existing, resolvable OAS operation, as defined with a unique operationId. This
|
|
822
|
+
* field is mutually exclusive of the operationRef field.
|
|
823
|
+
*/
|
|
394
824
|
operationId?: string;
|
|
825
|
+
/**
|
|
826
|
+
* A map representing parameters to pass to an operation as specified with operationId or
|
|
827
|
+
* identified via operationRef. The key is the parameter name to be used, whereas the value can be
|
|
828
|
+
* a constant or an expression to be evaluated and passed to the linked operation. The parameter
|
|
829
|
+
* name can be qualified using the parameter location [{in}.]{name} for operations that use the
|
|
830
|
+
* same parameter name in different locations (e.g. path.id).
|
|
831
|
+
*/
|
|
395
832
|
parameters?: {
|
|
396
833
|
[name: string]: `$${string}`;
|
|
397
834
|
};
|
|
835
|
+
/** A literal value or {expression} to use as a request body when calling the target operation. */
|
|
398
836
|
requestBody?: `$${string}`;
|
|
837
|
+
/** A description of the link. CommonMark syntax MAY be used for rich text representation. */
|
|
399
838
|
description?: string;
|
|
839
|
+
/** A server object to be used by the target operation. */
|
|
400
840
|
server?: ServerObject;
|
|
401
841
|
}
|
|
402
842
|
|
|
843
|
+
/**
|
|
844
|
+
* [4.8.27] Security Scheme Object
|
|
845
|
+
* Defines a security scheme that can be used by the operations.
|
|
846
|
+
*/
|
|
403
847
|
type SecuritySchemeObject = {
|
|
848
|
+
/**
|
|
849
|
+
* A description for security scheme. CommonMark syntax MAY be used for rich text representation.
|
|
850
|
+
*/
|
|
404
851
|
description?: string;
|
|
405
852
|
[key: `x-${string}`]: any;
|
|
406
853
|
} & ({
|
|
854
|
+
/** REQUIRED. The type of the security scheme. */
|
|
407
855
|
type: "apiKey";
|
|
856
|
+
/** REQUIRED. The name of the header, query or cookie parameter to be used. */
|
|
408
857
|
name: string;
|
|
858
|
+
/** REQUIRED. The location of the API key. */
|
|
409
859
|
in: "query" | "header" | "cookie";
|
|
410
860
|
} | {
|
|
861
|
+
/** REQUIRED. The type of the security scheme. */
|
|
411
862
|
type: "http";
|
|
863
|
+
/**
|
|
864
|
+
* REQUIRED. The name of the HTTP Authorization scheme to be used in the Authorization header
|
|
865
|
+
* as defined in [RFC7235]. The values used SHOULD be registered in the IANA Authentication
|
|
866
|
+
* Scheme registry.
|
|
867
|
+
*/
|
|
412
868
|
scheme: string;
|
|
869
|
+
/**
|
|
870
|
+
* A hint to the client to identify how the bearer token is formatted. Bearer tokens are
|
|
871
|
+
* usually generated by an authorization server, so this information is primarily for
|
|
872
|
+
* documentation purposes.
|
|
873
|
+
*/
|
|
413
874
|
bearer?: string;
|
|
414
875
|
} | {
|
|
876
|
+
/** REQUIRED. The type of the security scheme. */
|
|
415
877
|
type: "mutualTLS";
|
|
416
878
|
} | {
|
|
879
|
+
/** REQUIRED. Tye type of the security scheme. */
|
|
417
880
|
type: "oauth2";
|
|
881
|
+
/** REQUIRED. An object containing configuration information for the flow types supported. */
|
|
418
882
|
flows: OAuthFlowsObject;
|
|
419
883
|
} | {
|
|
884
|
+
/** REQUIRED. Tye type of the security scheme. */
|
|
420
885
|
type: "openIdConnect";
|
|
886
|
+
/**
|
|
887
|
+
* REQUIRED. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the
|
|
888
|
+
* form of a URL. The OpenID Connect standard requires the use of TLS.
|
|
889
|
+
*/
|
|
421
890
|
openIdConnectUrl: string;
|
|
422
891
|
});
|
|
892
|
+
/**
|
|
893
|
+
* [4.8.26] OAuth Flows Object
|
|
894
|
+
* Allows configuration of the supported OAuth Flows.
|
|
895
|
+
*/
|
|
423
896
|
interface OAuthFlowsObject extends Extensable {
|
|
897
|
+
/** Configuration for the OAuth Implicit flow */
|
|
424
898
|
implicit?: OAuthFlowObject;
|
|
899
|
+
/** Configuration for the OAuth Resource Owner Password flow */
|
|
425
900
|
password?: OAuthFlowObject;
|
|
901
|
+
/**
|
|
902
|
+
* Configuration for the OAuth Client Credentials flow. Previously called `application` in OpenAPI
|
|
903
|
+
* 2.0.
|
|
904
|
+
*/
|
|
426
905
|
clientCredentials?: OAuthFlowObject;
|
|
906
|
+
/**
|
|
907
|
+
* Configuration for the OAuth Authorization Code flow. Previously called `accessCode` in OpenAPI
|
|
908
|
+
* 2.0.
|
|
909
|
+
*/
|
|
427
910
|
authorizationCode?: OAuthFlowObject;
|
|
428
911
|
}
|
|
912
|
+
/**
|
|
913
|
+
* [4.8.29] OAuth Flow Object
|
|
914
|
+
* Configuration details for a supported OAuth Flow
|
|
915
|
+
*/
|
|
429
916
|
interface OAuthFlowObject extends Extensable {
|
|
917
|
+
/**
|
|
918
|
+
* REQUIRED. The authorization URL to be used for this flow. This MUST be in the form of a URL.
|
|
919
|
+
* The OAuth2 standard requires the use of TLS.
|
|
920
|
+
*/
|
|
430
921
|
authorizationUrl: string;
|
|
922
|
+
/**
|
|
923
|
+
* REQUIRED. The token URL to be used for this flow. This MUST be in the form of a URL. The OAuth2
|
|
924
|
+
* standard requires the use of TLS.
|
|
925
|
+
*/
|
|
431
926
|
tokenUrl: string;
|
|
927
|
+
/**
|
|
928
|
+
* The URL to be used for obtaining refresh tokens. This MUST be in the form of a URL. The OAuth2
|
|
929
|
+
* standard requires the use of TLS.
|
|
930
|
+
*/
|
|
432
931
|
refreshUrl: string;
|
|
932
|
+
/**
|
|
933
|
+
* REQUIRED. The available scopes for the OAuth2 security scheme. A map between the scope name and
|
|
934
|
+
* a short description for it. The map MAY be empty.
|
|
935
|
+
*/
|
|
433
936
|
scopes: {
|
|
434
937
|
[name: string]: string;
|
|
435
938
|
};
|
|
436
939
|
}
|
|
940
|
+
/**
|
|
941
|
+
* [4.8.30] Security Requirements Object
|
|
942
|
+
* Lists the required security schemes to execute this operation. The name used for each property
|
|
943
|
+
* MUST correspond to a security scheme declared in the Security Schemes under the Components
|
|
944
|
+
* Object.
|
|
945
|
+
*/
|
|
437
946
|
type SecurityRequirementObject = {
|
|
438
947
|
[P in keyof ComponentsObject["securitySchemes"]]?: string[];
|
|
439
948
|
};
|
|
440
949
|
|
|
950
|
+
/**
|
|
951
|
+
* [4.8.9] Path Item Object
|
|
952
|
+
* Describes the operations available on a single path. A Path Item MAY be empty, due to ACL
|
|
953
|
+
* constraints. The path itself is still exposed to the documentation viewer but they will not know
|
|
954
|
+
* which operations and parameters are available.
|
|
955
|
+
*/
|
|
441
956
|
interface PathItemObject extends Extensable {
|
|
957
|
+
/** A definition of a GET operation on this path. */
|
|
442
958
|
get?: OperationObject | ReferenceObject;
|
|
959
|
+
/** A definition of a PUT operation on this path. */
|
|
443
960
|
put?: OperationObject | ReferenceObject;
|
|
961
|
+
/** A definition of a POST operation on this path. */
|
|
444
962
|
post?: OperationObject | ReferenceObject;
|
|
963
|
+
/** A definition of a DELETE operation on this path. */
|
|
445
964
|
delete?: OperationObject | ReferenceObject;
|
|
965
|
+
/** A definition of a OPTIONS operation on this path. */
|
|
446
966
|
options?: OperationObject | ReferenceObject;
|
|
967
|
+
/** A definition of a HEAD operation on this path. */
|
|
447
968
|
head?: OperationObject | ReferenceObject;
|
|
969
|
+
/** A definition of a PATCH operation on this path. */
|
|
448
970
|
patch?: OperationObject | ReferenceObject;
|
|
971
|
+
/** A definition of a TRACE operation on this path. */
|
|
449
972
|
trace?: OperationObject | ReferenceObject;
|
|
973
|
+
/** A definition of a QUERY operation on this path (OpenAPI 3.2). */
|
|
450
974
|
query?: OperationObject | ReferenceObject;
|
|
975
|
+
/**
|
|
976
|
+
* Operations for other HTTP methods, keyed by the method name exactly as it is sent
|
|
977
|
+
* (OpenAPI 3.2). The fixed methods above must not appear here.
|
|
978
|
+
*/
|
|
451
979
|
additionalOperations?: Record<string, OperationObject | ReferenceObject>;
|
|
980
|
+
/** An alternative server array to service all operations in this path. */
|
|
452
981
|
servers?: ServerObject[];
|
|
982
|
+
/**
|
|
983
|
+
* A list of parameters that are applicable for all the operations described under this path.
|
|
984
|
+
* These parameters can be overridden at the operation level, but cannot be removed there. The
|
|
985
|
+
* list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of
|
|
986
|
+
* a name and location. The list can use the Reference Object to link to parameters that are
|
|
987
|
+
* defined at the OpenAPI Object’s components/parameters.
|
|
988
|
+
*/
|
|
453
989
|
parameters?: (ParameterObject | ReferenceObject)[];
|
|
454
990
|
}
|
|
991
|
+
/**
|
|
992
|
+
* [4.8.10] Operation Object
|
|
993
|
+
* Describes a single API operation on a path.
|
|
994
|
+
*/
|
|
455
995
|
interface OperationObject extends Extensable {
|
|
996
|
+
/**
|
|
997
|
+
* A list of tags for API documentation control. Tags can be used for logical grouping of
|
|
998
|
+
* operations by resources or any other qualifier.
|
|
999
|
+
*/
|
|
456
1000
|
tags?: string[];
|
|
1001
|
+
/** A short summary of what the operation does. */
|
|
457
1002
|
summary?: string;
|
|
1003
|
+
/**
|
|
1004
|
+
* A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text
|
|
1005
|
+
* representation.
|
|
1006
|
+
*/
|
|
458
1007
|
description?: string;
|
|
1008
|
+
/** Additional external documentation for this operation. */
|
|
459
1009
|
externalDocs?: ExternalDocumentationObject;
|
|
1010
|
+
/**
|
|
1011
|
+
* Unique string used to identify the operation. The id MUST be unique among all operations
|
|
1012
|
+
* described in the API. The operationId value is case-sensitive. Tools and libraries MAY use the
|
|
1013
|
+
* operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common
|
|
1014
|
+
* programming naming conventions.
|
|
1015
|
+
*/
|
|
460
1016
|
operationId?: string;
|
|
1017
|
+
/**
|
|
1018
|
+
* A list of parameters that are applicable for this operation. If a parameter is already defined
|
|
1019
|
+
* at the Path Item, the new definition will override it but can never remove it. The list MUST
|
|
1020
|
+
* NOT include duplicated parameters. A unique parameter is defined by a combination of a name and
|
|
1021
|
+
* location. The list can use the Reference Object to link to parameters that are defined at the
|
|
1022
|
+
* OpenAPI Object’s components/parameters.
|
|
1023
|
+
*/
|
|
461
1024
|
parameters?: (ParameterObject | ReferenceObject)[];
|
|
1025
|
+
/**
|
|
1026
|
+
* The request body applicable for this operation. The requestBody is fully supported in HTTP
|
|
1027
|
+
* methods where the HTTP 1.1 specification [RFC7231] has explicitly defined semantics for request
|
|
1028
|
+
* bodies. In other cases where the HTTP spec is vague (such as GET, HEAD and DELETE), requestBody
|
|
1029
|
+
* is permitted but does not have well-defined semantics and SHOULD be avoided if possible.
|
|
1030
|
+
*/
|
|
462
1031
|
requestBody?: RequestBodyObject | ReferenceObject;
|
|
1032
|
+
/** The list of possible responses as they are returned from executing this operation. */
|
|
463
1033
|
responses?: ResponsesObject;
|
|
1034
|
+
/**
|
|
1035
|
+
* A map of possible out-of band callbacks related to the parent operation. The key is a unique
|
|
1036
|
+
* identifier for the Callback Object. Each value in the map is a Callback Object that describes a
|
|
1037
|
+
* request that may be initiated by the API provider and the expected responses.
|
|
1038
|
+
*/
|
|
464
1039
|
callbacks?: Record<string, CallbackObject | ReferenceObject>;
|
|
1040
|
+
/**
|
|
1041
|
+
* Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared
|
|
1042
|
+
* operation. Default value is false.
|
|
1043
|
+
*/
|
|
465
1044
|
deprecated?: boolean;
|
|
1045
|
+
/**
|
|
1046
|
+
* A declaration of which security mechanisms can be used for this operation. The list of values
|
|
1047
|
+
* includes alternative security requirement objects that can be used. Only one of the security
|
|
1048
|
+
* requirement objects need to be satisfied to authorize a request. To make security optional, an
|
|
1049
|
+
* empty security requirement ({}) can be included in the array. This definition overrides any
|
|
1050
|
+
* declared top-level security. To remove a top-level security declaration, an empty array can be
|
|
1051
|
+
* used.
|
|
1052
|
+
*/
|
|
466
1053
|
security?: SecurityRequirementObject[];
|
|
1054
|
+
/**
|
|
1055
|
+
* An alternative server array to service this operation. If an alternative server object is
|
|
1056
|
+
* specified at the Path Item Object or Root level, it will be overridden by this value.
|
|
1057
|
+
*/
|
|
467
1058
|
servers?: ServerObject[];
|
|
468
1059
|
}
|
|
1060
|
+
/**
|
|
1061
|
+
* [4.8.18] Callback Object
|
|
1062
|
+
* A map of possible out-of band callbacks related to the parent operation. Each value in the map is
|
|
1063
|
+
* a Path Item Object that describes a set of requests that may be initiated by the API provider and
|
|
1064
|
+
* the expected responses. The key value used to identify the path item object is an expression,
|
|
1065
|
+
* evaluated at runtime, that identifies a URL to use for the callback operation.
|
|
1066
|
+
*/
|
|
469
1067
|
type CallbackObject = Record<string, PathItemObject>;
|
|
470
1068
|
|
|
1069
|
+
/**
|
|
1070
|
+
* [4.8] Schema
|
|
1071
|
+
* @see https://spec.openapis.org/oas/v3.1.0#schema
|
|
1072
|
+
*/
|
|
471
1073
|
interface OpenAPI3 extends Extensable {
|
|
1074
|
+
/**
|
|
1075
|
+
* REQUIRED. This string MUST be the version number of the OpenAPI Specification that the OpenAPI
|
|
1076
|
+
* document uses. The openapi field SHOULD be used by tooling to interpret the OpenAPI document.
|
|
1077
|
+
* This is not related to the API info.version string.
|
|
1078
|
+
*/
|
|
472
1079
|
openapi: string;
|
|
1080
|
+
/** REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required. */
|
|
473
1081
|
info: InfoObject;
|
|
1082
|
+
/**
|
|
1083
|
+
* The default value for the $schema keyword within Schema Objects contained within this OAS
|
|
1084
|
+
* document. This MUST be in the form of a URI.
|
|
1085
|
+
*/
|
|
474
1086
|
jsonSchemaDialect?: string;
|
|
1087
|
+
/**
|
|
1088
|
+
* An array of Server Objects, which provide connectivity information to a target server. If the
|
|
1089
|
+
* servers property is not provided, or is an empty array, the default value would be a Server
|
|
1090
|
+
* Object with a url value of /.
|
|
1091
|
+
*/
|
|
475
1092
|
servers?: ServerObject[];
|
|
1093
|
+
/** The available paths and operations for the API. */
|
|
476
1094
|
paths?: PathsObject;
|
|
1095
|
+
/**
|
|
1096
|
+
* The incoming webhooks that MAY be received as part of this API and that the API consumer MAY
|
|
1097
|
+
* choose to implement. Closely related to the callbacks feature, this section describes requests
|
|
1098
|
+
* initiated other than by an API call, for example by an out of band registration. The key name
|
|
1099
|
+
* is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object
|
|
1100
|
+
* describes a request that may be initiated by the API provider and the expected responses. An
|
|
1101
|
+
* example is available.
|
|
1102
|
+
*/
|
|
477
1103
|
webhooks?: {
|
|
478
1104
|
[id: string]: PathItemObject | ReferenceObject;
|
|
479
1105
|
};
|
|
1106
|
+
/** An element to hold various schemas for the document. */
|
|
480
1107
|
components?: ComponentsObject;
|
|
1108
|
+
/**
|
|
1109
|
+
* A declaration of which security mechanisms can be used across the API. The list of values
|
|
1110
|
+
* includes alternative security requirement objects that can be used. Only one of the security
|
|
1111
|
+
* requirement objects need to be satisfied to authorize a request. Individual operations can
|
|
1112
|
+
* override this definition. To make security optional, an empty security requirement ({}) can be
|
|
1113
|
+
* included in the array.
|
|
1114
|
+
*/
|
|
481
1115
|
security?: SecurityRequirementObject[];
|
|
1116
|
+
/**
|
|
1117
|
+
* A list of tags used by the document with additional metadata. The order of the tags can be used
|
|
1118
|
+
* to reflect on their order by the parsing tools. Not all tags that are used by the Operation
|
|
1119
|
+
* Object must be declared. The tags that are not declared MAY be organized randomly or based on
|
|
1120
|
+
* the tools’ logic. Each tag name in the list MUST be unique.
|
|
1121
|
+
*/
|
|
482
1122
|
tags?: TagObject[];
|
|
1123
|
+
/** Additional external documentation. */
|
|
483
1124
|
externalDocs?: ExternalDocumentationObject;
|
|
484
1125
|
$defs?: $defs;
|
|
485
1126
|
}
|
|
1127
|
+
/**
|
|
1128
|
+
* [4.8.2] Info Object
|
|
1129
|
+
* The object provides metadata about the API.
|
|
1130
|
+
*/
|
|
486
1131
|
interface InfoObject extends Extensable {
|
|
1132
|
+
/** REQUIRED. The title of the API. */
|
|
487
1133
|
title: string;
|
|
1134
|
+
/** A short summary of the API. */
|
|
488
1135
|
summary?: string;
|
|
1136
|
+
/** A description of the API. CommonMark syntax MAY be used for rich text representation. */
|
|
489
1137
|
description?: string;
|
|
1138
|
+
/** A URL to the Terms of Service for the API. This MUST be in the form of a URL. */
|
|
490
1139
|
termsOfService?: string;
|
|
1140
|
+
/** The contact information for the exposed API. */
|
|
491
1141
|
contact?: ContactObject;
|
|
1142
|
+
/** The license information for the exposed API. */
|
|
492
1143
|
license?: LicenseObject;
|
|
1144
|
+
/**
|
|
1145
|
+
* REQUIRED. The version of the OpenAPI document (which is distinct from the OpenAPI Specification
|
|
1146
|
+
* version or the API implementation version).
|
|
1147
|
+
*/
|
|
493
1148
|
version: string;
|
|
494
1149
|
}
|
|
1150
|
+
/**
|
|
1151
|
+
* [4.8.3] Contact Object
|
|
1152
|
+
* Contact information for the exposed API.
|
|
1153
|
+
*/
|
|
495
1154
|
interface ContactObject extends Extensable {
|
|
1155
|
+
/** The identifying name of the contact person/organization. */
|
|
496
1156
|
name?: string;
|
|
1157
|
+
/** The URL pointing to the contact information. This MUST be in the form of a URL. */
|
|
497
1158
|
url?: string;
|
|
1159
|
+
/**
|
|
1160
|
+
* The email address of the contact person/organization. This MUST be in the form of an email
|
|
1161
|
+
* address.
|
|
1162
|
+
*/
|
|
498
1163
|
email?: string;
|
|
499
1164
|
}
|
|
1165
|
+
/**
|
|
1166
|
+
* [4.8.4] License object
|
|
1167
|
+
* License information for the exposed API.
|
|
1168
|
+
*/
|
|
500
1169
|
interface LicenseObject extends Extensable {
|
|
1170
|
+
/** REQUIRED. The license name used for the API. */
|
|
501
1171
|
name: string;
|
|
1172
|
+
/**
|
|
1173
|
+
* An SPDX license expression for the API. The identifier field is mutually exclusive of the url
|
|
1174
|
+
* field.
|
|
1175
|
+
*/
|
|
502
1176
|
identifier: string;
|
|
1177
|
+
/**
|
|
1178
|
+
* A URL to the license used for the API. This MUST be in the form of a URL. The url field is
|
|
1179
|
+
* mutually exclusive of the identifier field.
|
|
1180
|
+
*/
|
|
503
1181
|
url: string;
|
|
504
1182
|
}
|
|
1183
|
+
/**
|
|
1184
|
+
* [4.8.7] Components Object
|
|
1185
|
+
* Holds a set of reusable objects for different aspects of the OAS.
|
|
1186
|
+
*/
|
|
505
1187
|
interface ComponentsObject extends Extensable {
|
|
1188
|
+
/** An object to hold reusable Schema Objects.*/
|
|
506
1189
|
schemas?: Record<string, SchemaObject>;
|
|
1190
|
+
/** An object to hold reusable Response Objects. */
|
|
507
1191
|
responses?: Record<string, ResponseObject | ReferenceObject>;
|
|
1192
|
+
/** An object to hold reusable Parameter Objects. */
|
|
508
1193
|
parameters?: Record<string, ParameterObject | ReferenceObject>;
|
|
1194
|
+
/** An object to hold reusable Example Objects. */
|
|
509
1195
|
examples?: Record<string, ExampleObject | ReferenceObject>;
|
|
1196
|
+
/** An object to hold reusable Request Body Objects. */
|
|
510
1197
|
requestBodies?: Record<string, RequestBodyObject | ReferenceObject>;
|
|
1198
|
+
/** An object to hold reusable Header Objects. */
|
|
511
1199
|
headers?: Record<string, HeaderObject | ReferenceObject>;
|
|
1200
|
+
/** An object to hold reusable Security Scheme Objects. */
|
|
512
1201
|
securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
|
|
1202
|
+
/** An object to hold reusable Link Objects. */
|
|
513
1203
|
links?: Record<string, LinkObject | ReferenceObject>;
|
|
1204
|
+
/** An object to hold reusable Callback Objects. */
|
|
514
1205
|
callbacks?: Record<string, CallbackObject | ReferenceObject>;
|
|
1206
|
+
/** An object to hold reusable Path Item Objects. */
|
|
515
1207
|
pathItems?: Record<string, PathItemObject | ReferenceObject>;
|
|
1208
|
+
/** An object to hold reusable Media Type Objects (OpenAPI 3.2). */
|
|
516
1209
|
mediaTypes?: Record<string, MediaTypeObject | ReferenceObject>;
|
|
517
1210
|
}
|
|
1211
|
+
/**
|
|
1212
|
+
* [4.8.8] Paths Object
|
|
1213
|
+
* Holds the relative paths to the individual endpoints and their operations. The path is appended
|
|
1214
|
+
* to the URL from the Server Object in order to construct the full URL. The Paths MAY be empty, due
|
|
1215
|
+
* to Access Control List (ACL) constraints.
|
|
1216
|
+
*/
|
|
518
1217
|
interface PathsObject {
|
|
519
1218
|
[pathname: string]: PathItemObject | ReferenceObject;
|
|
520
1219
|
}
|
|
1220
|
+
/**
|
|
1221
|
+
* [x.x.x] Webhooks Object
|
|
1222
|
+
* Holds the webhooks definitions, indexed by their names. A webhook is defined by a Path Item
|
|
1223
|
+
* Object; the only difference is that the request is initiated by the API provider.
|
|
1224
|
+
*/
|
|
521
1225
|
interface WebhooksObject {
|
|
522
1226
|
[name: string]: PathItemObject;
|
|
523
1227
|
}
|
|
1228
|
+
/**
|
|
1229
|
+
* [4.8.22] Tag Object
|
|
1230
|
+
* Adds metadata to a single tag that is used by the Operation Object. It is not mandatory to have a
|
|
1231
|
+
* Tag Object per tag defined in the Operation Object instances.
|
|
1232
|
+
*/
|
|
524
1233
|
interface TagObject extends Extensable {
|
|
1234
|
+
/** REQUIRED. The name of the tag. */
|
|
525
1235
|
name: string;
|
|
1236
|
+
/** A description for the tag. CommonMark syntax MAY be used for rich text representation. */
|
|
526
1237
|
description?: string;
|
|
1238
|
+
/** Additional external documentation for this tag. */
|
|
527
1239
|
externalDocs?: ExternalDocumentationObject;
|
|
528
1240
|
}
|
|
529
1241
|
|
|
530
1242
|
interface TransformObject {
|
|
1243
|
+
/** The type: an IR type (from the helpers), or a TypeScript node (read by the bridge). */
|
|
531
1244
|
schema: IrType | ts.TypeNode;
|
|
532
1245
|
questionToken: boolean;
|
|
533
1246
|
}
|
|
1247
|
+
/**
|
|
1248
|
+
* Every source type `openapiTS` accepts: YAML or JSON text, a URL, a parsed document, bytes or a
|
|
1249
|
+
* stream.
|
|
1250
|
+
*/
|
|
534
1251
|
type SchemaSource = string | URL | OpenAPI3 | Buffer | Readable;
|
|
1252
|
+
/** The generator options other than the schema callbacks. */
|
|
535
1253
|
interface OpenAPITSBaseOptions {
|
|
1254
|
+
/** Treat all objects as if they have `additionalProperties: true` by default (default: false) */
|
|
536
1255
|
additionalProperties?: boolean;
|
|
1256
|
+
/** Alphabetize all keys? (default: false) */
|
|
537
1257
|
alphabetize?: boolean;
|
|
1258
|
+
/** (optional) Generate tuples using array minItems / maxItems */
|
|
538
1259
|
arrayLength?: boolean;
|
|
1260
|
+
/**
|
|
1261
|
+
* Type raw binary strings as `Blob` instead of `string` (default: false): `format: binary`
|
|
1262
|
+
* (OpenAPI 3.0), or a `contentMediaType` that is not text and has no `contentEncoding` (3.1).
|
|
1263
|
+
* `Blob` is a global type of the DOM lib and `@types/node`.
|
|
1264
|
+
*/
|
|
539
1265
|
binaryAsBlob?: boolean;
|
|
1266
|
+
/**
|
|
1267
|
+
* Allow schema objects with no specified properties to have additional properties if not
|
|
1268
|
+
* expressly forbidden? (default: false)
|
|
1269
|
+
*/
|
|
540
1270
|
emptyObjectsUnknown?: boolean;
|
|
1271
|
+
/** Provide current working directory (cwd) which helps resolve relative remote schemas */
|
|
541
1272
|
cwd?: PathLike;
|
|
1273
|
+
/**
|
|
1274
|
+
* Load local `$ref` files only from this directory and below it; a relative path resolves
|
|
1275
|
+
* against `cwd`. Default: no limit. Threat model R1, ADR-017.
|
|
1276
|
+
*/
|
|
542
1277
|
localRefRoot?: string | URL;
|
|
1278
|
+
/**
|
|
1279
|
+
* Load remote `$ref` documents only from these hosts (`name` or `name:port`); `[]` loads none.
|
|
1280
|
+
* Redirects are checked too. Default: any host. Threat model R2, ADR-017.
|
|
1281
|
+
*/
|
|
543
1282
|
remoteRefHosts?: readonly string[];
|
|
1283
|
+
/** Should schema objects with a default value not be considered optional? */
|
|
544
1284
|
defaultNonNullable?: boolean;
|
|
1285
|
+
/** Exclude deprecated fields from types? (default: false) */
|
|
545
1286
|
excludeDeprecated?: boolean;
|
|
1287
|
+
/**
|
|
1288
|
+
* Opt-in fixes of the output of valid schemas (default: none), ADR-021. `"all"` turns on every
|
|
1289
|
+
* fix of the installed version, so a minor update can change the output; list the names to keep
|
|
1290
|
+
* it stable. An unknown name fails with `OPTION_FIX_UNKNOWN`.
|
|
1291
|
+
* @see https://github.com/openapi-typesafe/openapi-typesafe/blob/main/docs/cli.md#fix
|
|
1292
|
+
*/
|
|
546
1293
|
fix?: readonly OutputFixName[];
|
|
1294
|
+
/** Add readonly properties and readonly arrays? (default: false) */
|
|
547
1295
|
immutable?: boolean;
|
|
1296
|
+
/**
|
|
1297
|
+
* Lint the document with the Redocly config before generating (default: true). Bundling errors
|
|
1298
|
+
* still fail the run.
|
|
1299
|
+
*/
|
|
548
1300
|
lint?: boolean;
|
|
1301
|
+
/** (optional) Should logging be suppressed? (necessary for STDOUT) */
|
|
549
1302
|
silent?: boolean;
|
|
1303
|
+
/** Accepted for compatibility with openapi-typescript; not read. */
|
|
550
1304
|
version?: number;
|
|
1305
|
+
/** (optional) Export type instead of interface */
|
|
551
1306
|
exportType?: boolean;
|
|
1307
|
+
/** Export true TypeScript enums instead of unions */
|
|
552
1308
|
enum?: boolean;
|
|
1309
|
+
/** Export union values as arrays */
|
|
553
1310
|
enumValues?: boolean;
|
|
1311
|
+
/** Only generate TS Enums when `x-enum-*` metadata is available */
|
|
554
1312
|
conditionalEnums?: boolean;
|
|
1313
|
+
/** Dedupe enum values */
|
|
555
1314
|
dedupeEnums?: boolean;
|
|
1315
|
+
/** (optional) Substitute path parameter names with their respective types */
|
|
556
1316
|
pathParamsAsTypes?: boolean;
|
|
1317
|
+
/**
|
|
1318
|
+
* Treat all objects as if they have \`required\` set to all properties by default (default:
|
|
1319
|
+
* false)
|
|
1320
|
+
*/
|
|
557
1321
|
propertiesRequiredByDefault?: boolean;
|
|
1322
|
+
/** (optional) Generate schema types at root level */
|
|
558
1323
|
rootTypes?: boolean;
|
|
1324
|
+
/** (optional) Do not add Schema prefix to types at root level */
|
|
559
1325
|
rootTypesNoSchemaPrefix?: boolean;
|
|
1326
|
+
/** (optional) Keep casing of root types */
|
|
560
1327
|
rootTypesKeepCasing?: boolean;
|
|
1328
|
+
/**
|
|
1329
|
+
* Configure Redocly for validation, schema fetching, and bundling
|
|
1330
|
+
* @see https://redocly.com/docs/cli/configuration/
|
|
1331
|
+
*/
|
|
561
1332
|
redocly?: Config;
|
|
1333
|
+
/** Inject arbitrary TypeScript types into the start of the file */
|
|
562
1334
|
inject?: string;
|
|
1335
|
+
/** Generate ApiPaths enum */
|
|
563
1336
|
makePathsEnum?: boolean;
|
|
1337
|
+
/** Generate path params based on path even if they are not defined in the open api schema */
|
|
564
1338
|
generatePathParams?: boolean;
|
|
1339
|
+
/** Generate $Read/$Write markers for readOnly/writeOnly properties (default: false) */
|
|
565
1340
|
readWriteMarkers?: boolean;
|
|
566
1341
|
}
|
|
1342
|
+
/**
|
|
1343
|
+
* The schema callbacks of the original API: they receive TypeScript nodes (ADR-004, decisions 5
|
|
1344
|
+
* and 6). Results may be IR (from the helpers) or TypeScript nodes, read by the bridge.
|
|
1345
|
+
*/
|
|
567
1346
|
interface LegacyCallbackOptions {
|
|
1347
|
+
/** Unset or false: the callbacks below receive TypeScript nodes. */
|
|
568
1348
|
irCallbacks?: false;
|
|
1349
|
+
/** Manually transform certain Schema Objects with a custom TypeScript type */
|
|
569
1350
|
transform?: (schemaObject: SchemaObject, options: TransformNodeOptions) => IrType | ts.TypeNode | TransformObject | undefined;
|
|
1351
|
+
/**
|
|
1352
|
+
* Modify TypeScript types built from Schema Objects (receives a TypeScript node)
|
|
1353
|
+
* @deprecated Use `irCallbacks: true` (ADR-004, decision 6); the TypeScript form is removed in
|
|
1354
|
+
* 2.0.
|
|
1355
|
+
*/
|
|
570
1356
|
postTransform?: (type: ts.TypeNode, options: TransformNodeOptions) => IrType | ts.TypeNode | undefined;
|
|
1357
|
+
/**
|
|
1358
|
+
* Modify property signatures for Schema Object properties (receives a TypeScript node)
|
|
1359
|
+
* @deprecated Use `irCallbacks: true` (ADR-004, decision 6); the TypeScript form is removed in
|
|
1360
|
+
* 2.0.
|
|
1361
|
+
*/
|
|
571
1362
|
transformProperty?: (property: ts.PropertySignature, schemaObject: SchemaObject, options: TransformNodeOptions) => IrPropertySignature | ts.PropertySignature | undefined;
|
|
572
1363
|
}
|
|
1364
|
+
/**
|
|
1365
|
+
* The schema callbacks that have a deprecated TypeScript-node form (ADR-004, decisions 5 and 6).
|
|
1366
|
+
*/
|
|
573
1367
|
type LegacyCallbackName = "transform" | "postTransform" | "transformProperty";
|
|
1368
|
+
/** A type an IR callback returns: an IR type, or TypeScript type text printed as written. */
|
|
574
1369
|
type IrCallbackType = IrType | string;
|
|
1370
|
+
/** What an IR `transform` callback returns to make the property optional. */
|
|
575
1371
|
interface IrTransformObject {
|
|
576
1372
|
schema: IrCallbackType;
|
|
577
1373
|
questionToken: boolean;
|
|
578
1374
|
}
|
|
1375
|
+
/** Replace the generated type of a Schema Object; `undefined` keeps the generated type. */
|
|
579
1376
|
type IrTransform = (schemaObject: SchemaObject, options: TransformNodeOptions) => IrCallbackType | IrTransformObject | undefined;
|
|
1377
|
+
/** Modify the generated type of a Schema Object; `undefined` keeps it. */
|
|
580
1378
|
type IrPostTransform = (type: IrType, options: TransformNodeOptions) => IrCallbackType | undefined;
|
|
1379
|
+
/** Modify the generated property of a Schema Object property; `undefined` keeps it. */
|
|
581
1380
|
type IrTransformProperty = (property: IrPropertySignature, schemaObject: SchemaObject, options: TransformNodeOptions) => IrPropertySignature | undefined;
|
|
1381
|
+
/** The schema callbacks on IR (ENGINEERING_PLAN 6.3): they receive and return IR nodes. */
|
|
582
1382
|
interface IrCallbackOptions {
|
|
583
1383
|
irCallbacks: true;
|
|
584
1384
|
transform?: IrTransform;
|
|
585
1385
|
postTransform?: IrPostTransform;
|
|
586
1386
|
transformProperty?: IrTransformProperty;
|
|
587
1387
|
}
|
|
1388
|
+
/** The options of the original API: callbacks on TypeScript nodes. */
|
|
588
1389
|
interface OpenAPITSOptions extends OpenAPITSBaseOptions, LegacyCallbackOptions {
|
|
589
1390
|
}
|
|
1391
|
+
/** The options with `irCallbacks: true`: callbacks on IR nodes. */
|
|
590
1392
|
interface OpenAPITSIrOptions extends OpenAPITSBaseOptions, IrCallbackOptions {
|
|
591
1393
|
}
|
|
1394
|
+
/** Either form of the generator options. */
|
|
592
1395
|
type GeneratorOptions = OpenAPITSOptions | OpenAPITSIrOptions;
|
|
1396
|
+
/**
|
|
1397
|
+
* Context passed to all submodules, and to the callbacks as `options.ctx`. To call an exported
|
|
1398
|
+
* transformer outside a run, build one with the fields of openapi-typescript's context; the
|
|
1399
|
+
* fields openapi-typesafe added are optional.
|
|
1400
|
+
*/
|
|
593
1401
|
interface GlobalContext {
|
|
594
1402
|
additionalProperties: boolean;
|
|
595
1403
|
alphabetize: boolean;
|
|
596
1404
|
arrayLength: boolean;
|
|
597
|
-
|
|
1405
|
+
/** `format: binary` and `contentMediaType` strings become `Blob` (default: false). */
|
|
1406
|
+
binaryAsBlob?: boolean;
|
|
598
1407
|
defaultNonNullable: boolean;
|
|
599
1408
|
discriminators: {
|
|
600
1409
|
objects: Record<string, DiscriminatorObject>;
|
|
601
1410
|
refsHandled: string[];
|
|
602
|
-
enumParents?: ReadonlyMap<object, {
|
|
603
|
-
readonly schema: SchemaObject;
|
|
604
|
-
readonly path: string;
|
|
605
|
-
}>;
|
|
606
|
-
otherProperties?: Readonly<Record<string, readonly string[]>>;
|
|
607
1411
|
};
|
|
608
1412
|
emptyObjectsUnknown: boolean;
|
|
609
1413
|
enum: boolean;
|
|
@@ -612,14 +1416,20 @@ interface GlobalContext {
|
|
|
612
1416
|
dedupeEnums: boolean;
|
|
613
1417
|
excludeDeprecated: boolean;
|
|
614
1418
|
exportType: boolean;
|
|
1419
|
+
/** The opt-in output fixes of this run, `all` expanded (ADR-021). Unset: none. */
|
|
615
1420
|
fix?: readonly OutputFix[];
|
|
616
1421
|
immutable: boolean;
|
|
1422
|
+
/**
|
|
1423
|
+
* Declarations written after the main types, in order. The generator adds IR declarations;
|
|
1424
|
+
* callbacks may add IR declarations or TypeScript nodes.
|
|
1425
|
+
*/
|
|
617
1426
|
injectFooter: FooterEntry[];
|
|
618
|
-
runFooter?: DocumentFooter;
|
|
619
|
-
legacyCallbackWarnings?: Set<LegacyCallbackName>;
|
|
620
|
-
logger?: Logger;
|
|
621
1427
|
pathParamsAsTypes: boolean;
|
|
622
|
-
|
|
1428
|
+
/**
|
|
1429
|
+
* Whether the callbacks below take IR (`OpenAPITSIrOptions`) or TypeScript nodes
|
|
1430
|
+
* (default: false, TypeScript nodes).
|
|
1431
|
+
*/
|
|
1432
|
+
irCallbacks?: boolean;
|
|
623
1433
|
postTransform: GeneratorOptions["postTransform"];
|
|
624
1434
|
propertiesRequiredByDefault: boolean;
|
|
625
1435
|
rootTypes: boolean;
|
|
@@ -629,20 +1439,70 @@ interface GlobalContext {
|
|
|
629
1439
|
silent: boolean;
|
|
630
1440
|
transform: GeneratorOptions["transform"];
|
|
631
1441
|
transformProperty: GeneratorOptions["transformProperty"];
|
|
1442
|
+
/** retrieve a node by $ref */
|
|
632
1443
|
resolve<T>($ref: string): T | undefined;
|
|
633
1444
|
inject?: string;
|
|
634
1445
|
makePathsEnum: boolean;
|
|
635
1446
|
generatePathParams: boolean;
|
|
636
1447
|
readWriteMarkers: boolean;
|
|
637
1448
|
}
|
|
1449
|
+
/** generic options for most internal transform* functions */
|
|
638
1450
|
interface TransformNodeOptions {
|
|
639
1451
|
path?: string;
|
|
640
1452
|
schema?: SchemaObject | ReferenceObject;
|
|
641
1453
|
ctx: GlobalContext;
|
|
642
1454
|
}
|
|
643
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
|
+
|
|
1470
|
+
/** The debug groups of the original `DEBUG=openapi-ts:<group>` output. */
|
|
1471
|
+
type DebugGroup = "redoc" | "lint" | "bundle" | "ts";
|
|
1472
|
+
/**
|
|
1473
|
+
* Where the generator reports progress and problems (ENGINEERING_PLAN 4.5). Whether warnings are
|
|
1474
|
+
* printed (`silent`) and debug output (`DEBUG`) is decided by the adapter, when it is created.
|
|
1475
|
+
*/
|
|
1476
|
+
interface Logger {
|
|
1477
|
+
/**
|
|
1478
|
+
* A debug line, with how long the step took when it was measured. A line without a group is
|
|
1479
|
+
* written whenever debug output is on.
|
|
1480
|
+
*/
|
|
1481
|
+
debug(message: string, group?: DebugGroup, durationMs?: number): void;
|
|
1482
|
+
warn(message: string): void;
|
|
1483
|
+
error(message: string): void;
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Convert an OpenAPI schema to TypeScript declarations (IR nodes; print them with `astToString`)
|
|
1488
|
+
* @param {string|URL|object|Readable} source OpenAPI schema source:
|
|
1489
|
+
* - YAML: string
|
|
1490
|
+
* - JSON: parsed object
|
|
1491
|
+
* - URL: URL to a YAML or JSON file (local or remote)
|
|
1492
|
+
* - Readable: Readable stream of YAML or JSON
|
|
1493
|
+
*/
|
|
644
1494
|
declare function openapiTS(source: SchemaSource, options?: GeneratorOptions): Promise<IrDeclaration[]>;
|
|
645
1495
|
|
|
1496
|
+
/**
|
|
1497
|
+
* Typed errors (ENGINEERING_PLAN 4.6, ADR-011). Every expected failure of the generator and the CLI
|
|
1498
|
+
* is an `OpenAPITypesafeError` with a stable machine-readable `code` and structured `details`. The
|
|
1499
|
+
* `message` is English text for people; programs and the CLI decide by `code`. A bug (a broken
|
|
1500
|
+
* invariant) is a plain `Error`, not one of these.
|
|
1501
|
+
*/
|
|
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
|
+
*/
|
|
646
1506
|
declare const ERROR_CODES: {
|
|
647
1507
|
readonly SCHEMA_SOURCE_EMPTY: "SCHEMA_SOURCE_EMPTY";
|
|
648
1508
|
readonly SCHEMA_SOURCE_INVALID: "SCHEMA_SOURCE_INVALID";
|
|
@@ -672,46 +1532,87 @@ declare const ERROR_CODES: {
|
|
|
672
1532
|
readonly OUTPUT_WRITE_FAILED: "OUTPUT_WRITE_FAILED";
|
|
673
1533
|
};
|
|
674
1534
|
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
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
|
+
*/
|
|
675
1539
|
type ErrorDetails = Readonly<Record<string, unknown>>;
|
|
676
1540
|
interface OpenAPITypesafeErrorInit {
|
|
677
1541
|
readonly code: ErrorCode;
|
|
678
1542
|
readonly message: string;
|
|
679
1543
|
readonly details?: ErrorDetails;
|
|
1544
|
+
/** The lower-level error this one reports, if any (kept as the standard `cause`). */
|
|
680
1545
|
readonly cause?: unknown;
|
|
681
1546
|
}
|
|
1547
|
+
/**
|
|
1548
|
+
* The base of every expected failure; check `code`, not the class or the message. The message
|
|
1549
|
+
* never shows the user info of a URL (`url-credentials.ts`).
|
|
1550
|
+
*/
|
|
682
1551
|
declare class OpenAPITypesafeError extends Error {
|
|
683
1552
|
readonly code: ErrorCode;
|
|
684
1553
|
readonly details: ErrorDetails;
|
|
685
1554
|
constructor(init: OpenAPITypesafeErrorInit);
|
|
686
1555
|
}
|
|
1556
|
+
/** Whether a thrown value is one of our typed errors (also across bundled copies of the class). */
|
|
687
1557
|
declare function isOpenAPITypesafeError(value: unknown): value is OpenAPITypesafeError;
|
|
688
1558
|
|
|
1559
|
+
/** Options of `astToString` for the TypeScript printer, as in the original. */
|
|
689
1560
|
interface AstToStringOptions {
|
|
690
1561
|
fileName?: string;
|
|
691
1562
|
sourceText?: string;
|
|
1563
|
+
/** The installed compiler's printer options (ADR-032: named without `ts.PrinterOptions`). */
|
|
692
1564
|
formatOptions?: ts.PrinterOptions;
|
|
693
1565
|
}
|
|
694
1566
|
|
|
1567
|
+
/** Anything the IR printer can print at the top level of a file. */
|
|
695
1568
|
type IrPrintable = IrDeclaration | IrMember | IrType;
|
|
696
1569
|
|
|
1570
|
+
/** What `astToString` prints: IR (from `openapiTS` and the transformers) or TypeScript nodes. */
|
|
697
1571
|
type AstToStringInput = IrPrintable | ts.Node | readonly (IrPrintable | ts.Node)[];
|
|
1572
|
+
/**
|
|
1573
|
+
* Print declarations, members or types as a TypeScript file body. IR is printed by our printer;
|
|
1574
|
+
* with TypeScript nodes in the input, or with TypeScript printer options, everything goes
|
|
1575
|
+
* through the TypeScript printer as before (ADR-004, decision 1).
|
|
1576
|
+
*/
|
|
698
1577
|
declare function astToString(ast: AstToStringInput, options?: AstToStringOptions): string;
|
|
699
1578
|
|
|
1579
|
+
/** The header of every generated file; the CLI writes it before the declarations. */
|
|
700
1580
|
declare const COMMENT_HEADER = "/**\n * This file was auto-generated by openapi-typesafe.\n * Do not make direct changes to the file.\n */\n\n";
|
|
701
1581
|
|
|
1582
|
+
/**
|
|
1583
|
+
* The `discriminator-values` fix (#1700). With `--enum`, the enum the scan adds to a member
|
|
1584
|
+
* (`petType: "Cat"`) is declared as an enum of its own (`CatPetType`), which is not assignable to
|
|
1585
|
+
* the parent's enum (`PetType`). The parent's enum is found here, so the member's property can be
|
|
1586
|
+
* typed with its members (`PetType.Cat`).
|
|
1587
|
+
*/
|
|
1588
|
+
/** The parent's enum schema and the location it is typed at, which gives the enum its name. */
|
|
702
1589
|
interface EnumParent {
|
|
703
1590
|
readonly schema: SchemaObject;
|
|
704
1591
|
readonly path: string;
|
|
705
1592
|
}
|
|
706
1593
|
|
|
1594
|
+
/** The discriminators of a bundled document, after patching the mapped schemas in place. */
|
|
707
1595
|
interface DiscriminatorScan {
|
|
708
1596
|
objects: Record<string, DiscriminatorObject>;
|
|
709
1597
|
refsHandled: string[];
|
|
1598
|
+
/** With `discriminator-values`: the owner's enum of each enum the scan added. */
|
|
710
1599
|
enumParents: ReadonlyMap<object, EnumParent>;
|
|
1600
|
+
/** With `discriminator-values`: the properties of the other discriminators a schema inherits. */
|
|
711
1601
|
otherProperties: Readonly<Record<string, readonly string[]>>;
|
|
712
1602
|
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Return a key–value map of discriminator objects found in a schema. Warnings go to `logger`;
|
|
1605
|
+
* without one, to the default terminal logger, as the original did.
|
|
1606
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1607
|
+
*/
|
|
713
1608
|
declare function scanDiscriminators(schema: OpenAPI3, options: GeneratorOptions, logger?: Logger): DiscriminatorScan;
|
|
714
1609
|
|
|
1610
|
+
/**
|
|
1611
|
+
* The public type helpers (ENGINEERING_PLAN 6.2, ADR-004 decision 2). Same names and call
|
|
1612
|
+
* signatures as the original helpers; they return IR types. A `ts.TypeNode` argument (from user
|
|
1613
|
+
* code built with `ts.factory`) is read into IR by the bridge.
|
|
1614
|
+
*/
|
|
1615
|
+
/** A helper argument: an IR type, or a TypeScript type node from user code. */
|
|
715
1616
|
type TypeInput = IrType | ts.TypeNode;
|
|
716
1617
|
declare const BOOLEAN: IrType;
|
|
717
1618
|
declare const FALSE: IrType;
|
|
@@ -721,24 +1622,54 @@ declare const NUMBER: IrType;
|
|
|
721
1622
|
declare const STRING: IrType;
|
|
722
1623
|
declare const TRUE: IrType;
|
|
723
1624
|
declare const UNDEFINED: IrType;
|
|
1625
|
+
/** The shared `unknown` type; the transformers compare with it by identity, as the original did. */
|
|
724
1626
|
declare const UNKNOWN: IrType;
|
|
1627
|
+
/** `A | B`: `never` for no types, the type itself for one; repeated primitives are removed. */
|
|
725
1628
|
declare function tsUnion(types: readonly TypeInput[]): IrType;
|
|
1629
|
+
/** `A & B`, with the same rules as `tsUnion`. */
|
|
726
1630
|
declare function tsIntersection(types: readonly TypeInput[]): IrType;
|
|
1631
|
+
/** `A | null`, without removing repeated types. */
|
|
727
1632
|
declare function tsNullable(types: readonly TypeInput[]): IrType;
|
|
1633
|
+
/** `Omit<T, "a" | "b">`. */
|
|
728
1634
|
declare function tsOmit(type: TypeInput, keys: readonly string[]): IrType;
|
|
1635
|
+
/** `Record<K, V>`. */
|
|
729
1636
|
declare function tsRecord(key: TypeInput, value: TypeInput): IrType;
|
|
1637
|
+
/**
|
|
1638
|
+
* The literal type of a JSON value: strings, numbers, booleans and `null` as literals, arrays as
|
|
1639
|
+
* tuples (an empty one as `never[]`), objects as object types; anything else is `unknown`.
|
|
1640
|
+
*/
|
|
730
1641
|
declare function tsLiteral(value: unknown): IrType;
|
|
1642
|
+
/**
|
|
1643
|
+
* `WithRequired<T, "a" | "b">`, or the type itself for no keys. Adds the `WithRequired` helper
|
|
1644
|
+
* type to the footer once.
|
|
1645
|
+
*/
|
|
731
1646
|
declare function tsWithRequired(type: TypeInput, keys: readonly string[], injectFooter: FooterEntry[]): IrType;
|
|
732
1647
|
interface OapiRefOptions {
|
|
1648
|
+
/** Whether to wrap with FlattenedDeepRequired<> (default: false) */
|
|
733
1649
|
deep?: boolean;
|
|
1650
|
+
/** Array of property names to wrap with Extract<> when accessing */
|
|
734
1651
|
extractProperties?: string[];
|
|
735
1652
|
}
|
|
1653
|
+
/**
|
|
1654
|
+
* The generated type a JSON Pointer refers to, as an indexed access: `#/components/schemas/Foo`
|
|
1655
|
+
* → `components["schemas"]["Foo"]`. Object `properties` are skipped, and a referenced parameter
|
|
1656
|
+
* is indexed by its location (`resolved`).
|
|
1657
|
+
*/
|
|
736
1658
|
declare function oapiRef(path: string, resolved?: ParameterObject | ReferenceObject, options?: OapiRefOptions): IrType;
|
|
737
1659
|
|
|
1660
|
+
/**
|
|
1661
|
+
* The original's helpers that build TypeScript compiler nodes, kept for 1.x and deprecated
|
|
1662
|
+
* (ADR-004, decision 9). They load TypeScript on first use through the bridge; the generator
|
|
1663
|
+
* itself does not use them.
|
|
1664
|
+
*/
|
|
738
1665
|
declare const JS_PROPERTY_INDEX_RE: RegExp;
|
|
739
1666
|
declare const JS_ENUM_INVALID_CHARS_RE: RegExp;
|
|
740
1667
|
declare const JS_PROPERTY_INDEX_INVALID_CHARS_RE: RegExp;
|
|
741
1668
|
declare const SPECIAL_CHARACTER_MAP: Record<string, string>;
|
|
1669
|
+
/**
|
|
1670
|
+
* The `?` token. Created on first use, so importing the package needs no TypeScript.
|
|
1671
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1672
|
+
*/
|
|
742
1673
|
declare const QUESTION_TOKEN: ts.QuestionToken;
|
|
743
1674
|
interface AnnotatedSchemaObject {
|
|
744
1675
|
const?: unknown;
|
|
@@ -754,9 +1685,23 @@ interface AnnotatedSchemaObject {
|
|
|
754
1685
|
title?: string;
|
|
755
1686
|
type?: string | string[];
|
|
756
1687
|
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Add the schema's JSDoc comment to a TypeScript property signature.
|
|
1690
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1691
|
+
*/
|
|
757
1692
|
declare function addJSDocComment(schemaObject: AnnotatedSchemaObject, node: ts.PropertySignature): void;
|
|
1693
|
+
/**
|
|
1694
|
+
* Deduplicate simple primitive types from an array of nodes
|
|
1695
|
+
* Note: won’t deduplicate complex types like objects
|
|
1696
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1697
|
+
*/
|
|
758
1698
|
declare function tsDedupe(types: TypeInput[]): ts.TypeNode[];
|
|
1699
|
+
/** @deprecated The generator keeps its own enum registry per run; kept for 1.x (ADR-004). */
|
|
759
1700
|
declare const enumCache: Map<string, ts.EnumDeclaration>;
|
|
1701
|
+
/**
|
|
1702
|
+
* Create a TS enum (with sanitized name and members)
|
|
1703
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1704
|
+
*/
|
|
760
1705
|
declare function tsEnum(name: string, members: (string | number)[], metadata?: {
|
|
761
1706
|
name?: string;
|
|
762
1707
|
description?: string | null;
|
|
@@ -764,78 +1709,259 @@ declare function tsEnum(name: string, members: (string | number)[], metadata?: {
|
|
|
764
1709
|
export?: boolean;
|
|
765
1710
|
shouldCache?: boolean;
|
|
766
1711
|
}): ts.EnumDeclaration;
|
|
1712
|
+
/**
|
|
1713
|
+
* Create an exported TS array literal expression
|
|
1714
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1715
|
+
*/
|
|
767
1716
|
declare function tsArrayLiteralExpression(name: string, elementType: TypeInput, values: (string | number)[], options?: {
|
|
768
1717
|
export?: boolean;
|
|
769
1718
|
readonly?: boolean;
|
|
770
1719
|
injectFooter?: FooterEntry[];
|
|
771
1720
|
}): ts.VariableStatement;
|
|
1721
|
+
/**
|
|
1722
|
+
* Sanitize TS enum member expression
|
|
1723
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1724
|
+
*/
|
|
772
1725
|
declare function tsEnumMember(value: string | number, metadata?: {
|
|
773
1726
|
name?: string;
|
|
774
1727
|
description?: string | null;
|
|
775
1728
|
}): ts.EnumMember;
|
|
1729
|
+
/**
|
|
1730
|
+
* Is this a primitive type (string, number, boolean, null, undefined)?
|
|
1731
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1732
|
+
*/
|
|
776
1733
|
declare function tsIsPrimitive(input: TypeInput): boolean;
|
|
1734
|
+
/**
|
|
1735
|
+
* Modifiers (readonly)
|
|
1736
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1737
|
+
*/
|
|
777
1738
|
declare function tsModifiers(modifiers: {
|
|
778
1739
|
readonly?: boolean;
|
|
779
1740
|
export?: boolean;
|
|
780
1741
|
}): ts.Modifier[];
|
|
1742
|
+
/**
|
|
1743
|
+
* Create a valid property index
|
|
1744
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1745
|
+
*/
|
|
781
1746
|
declare function tsPropertyIndex(index: string | number): ts.Identifier | ts.NumericLiteral | ts.StringLiteral;
|
|
1747
|
+
/**
|
|
1748
|
+
* Enhanced ReadonlyArray.
|
|
1749
|
+
* eg: type Foo = ReadonlyArray<T>; type Bar = ReadonlyArray<T[]>
|
|
1750
|
+
* Foo and Bar are both of type `readonly T[]`
|
|
1751
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1752
|
+
*/
|
|
782
1753
|
declare function tsReadonlyArray(type: TypeInput, injectFooter?: FooterEntry[]): ts.TypeNode;
|
|
783
1754
|
|
|
1755
|
+
/** `$ref` resolution and the document walk that the generator's pre-pass uses. */
|
|
784
1756
|
interface ResolveRefOptions {
|
|
785
1757
|
silent: boolean;
|
|
786
1758
|
visited?: string[];
|
|
1759
|
+
/** @internal Where warnings go; the default terminal logger (respecting `silent`) if absent. */
|
|
787
1760
|
logger?: Logger;
|
|
788
1761
|
}
|
|
789
1762
|
|
|
1763
|
+
/**
|
|
1764
|
+
* The shared ansi-colors instance.
|
|
1765
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9). Use a color library directly.
|
|
1766
|
+
*/
|
|
790
1767
|
declare const c: typeof colors;
|
|
1768
|
+
/**
|
|
1769
|
+
* The discriminator property of a schema at `path`, typed as its discriminator value. Returns IR
|
|
1770
|
+
* (task 6.2), like the exported transformers.
|
|
1771
|
+
*/
|
|
791
1772
|
declare function createDiscriminatorProperty(discriminator: DiscriminatorObject, { path, readonly }: {
|
|
792
1773
|
path: string;
|
|
793
1774
|
readonly?: boolean;
|
|
794
1775
|
}): IrPropertySignature;
|
|
1776
|
+
/** Create a $ref pointer (even from other $refs) */
|
|
795
1777
|
declare function createRef(parts: (number | string | undefined | null)[]): string;
|
|
1778
|
+
/**
|
|
1779
|
+
* Print debug message (cribbed from the `debug` package, but without all the bells & whistles
|
|
1780
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1781
|
+
*/
|
|
796
1782
|
declare function debug(msg: string, group?: string, time?: number): void;
|
|
1783
|
+
/**
|
|
1784
|
+
* Print error message
|
|
1785
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1786
|
+
*/
|
|
797
1787
|
declare function error(msg: string): void;
|
|
1788
|
+
/** Format a performance log in a friendly format */
|
|
798
1789
|
declare function formatTime(t: number): string;
|
|
1790
|
+
/** Call Object.entries() and optionally sort */
|
|
799
1791
|
declare function getEntries<T>(obj: ArrayLike<T> | Record<string, T>, options?: {
|
|
800
1792
|
alphabetize?: boolean;
|
|
801
1793
|
excludeDeprecated?: boolean;
|
|
802
1794
|
}): [string, T][];
|
|
803
1795
|
|
|
804
|
-
|
|
1796
|
+
/**
|
|
1797
|
+
* resolve a $ref in a schema
|
|
1798
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1799
|
+
*/
|
|
1800
|
+
declare function resolveRef<T>(schema: unknown, $ref: string, options: ResolveRefOptions): T | undefined;
|
|
1801
|
+
/**
|
|
1802
|
+
* Walk through any JSON-serializable (i.e. non-circular) object
|
|
1803
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1804
|
+
*/
|
|
805
1805
|
declare function walk(obj: unknown, cb: (value: Record<string, unknown>, path: (string | number)[]) => void, path?: (string | number)[]): void;
|
|
1806
|
+
/**
|
|
1807
|
+
* Print warning message
|
|
1808
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 9).
|
|
1809
|
+
*/
|
|
806
1810
|
declare function warn(msg: string, silent?: boolean): void;
|
|
807
1811
|
|
|
808
|
-
|
|
809
|
-
|
|
1812
|
+
/**
|
|
1813
|
+
* Convert an arbitrary string to TS (assuming it’s valid). Parses with the TypeScript bridge, so
|
|
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.
|
|
1816
|
+
* @deprecated Kept for 1.x; removed in 2.0 (ADR-004, decision 7). Use type text in IR callbacks.
|
|
1817
|
+
*/
|
|
1818
|
+
declare function stringToAST(source: string): unknown[];
|
|
810
1819
|
|
|
1820
|
+
/**
|
|
1821
|
+
* The whole document as IR declarations (ENGINEERING_PLAN 6.1–6.2); `openapiTS` returns the same
|
|
1822
|
+
* for a loaded document.
|
|
1823
|
+
*/
|
|
811
1824
|
declare function transformSchema(schema: OpenAPI3, ctx: GlobalContext): IrDeclaration[];
|
|
812
1825
|
|
|
1826
|
+
/**
|
|
1827
|
+
* Typed warnings. A warning does not stop the run: the output is written and the CLI exits with 0.
|
|
1828
|
+
* Each one ends with a stable machine-readable code in parentheses, as the CLI prints errors
|
|
1829
|
+
* (`message (CODE)`), so a script or a person can search for it.
|
|
1830
|
+
*/
|
|
1831
|
+
/** Every warning code. */
|
|
1832
|
+
declare const WARNING_CODES: {
|
|
1833
|
+
readonly CLI_INPUT_IGNORED: "CLI_INPUT_IGNORED";
|
|
1834
|
+
readonly CONFIG_SETTING_UNKNOWN: "CONFIG_SETTING_UNKNOWN";
|
|
1835
|
+
readonly DISCRIMINATOR_MAPPING_INVALID: "DISCRIMINATOR_MAPPING_INVALID";
|
|
1836
|
+
readonly DISCRIMINATOR_VALUE_NOT_ALLOWED: "DISCRIMINATOR_VALUE_NOT_ALLOWED";
|
|
1837
|
+
readonly ENUM_VALUES_EXCLUDED: "ENUM_VALUES_EXCLUDED";
|
|
1838
|
+
readonly FIX_NEEDS_OPTION: "FIX_NEEDS_OPTION";
|
|
1839
|
+
readonly LINT_PROBLEM: "LINT_PROBLEM";
|
|
1840
|
+
readonly PATH_TEMPLATES_IDENTICAL: "PATH_TEMPLATES_IDENTICAL";
|
|
1841
|
+
readonly QUERYSTRING_NEXT_TO_QUERY: "QUERYSTRING_NEXT_TO_QUERY";
|
|
1842
|
+
readonly REF_CIRCULAR: "REF_CIRCULAR";
|
|
1843
|
+
readonly REF_NOT_FOUND: "REF_NOT_FOUND";
|
|
1844
|
+
};
|
|
1845
|
+
type WarningCode = (typeof WARNING_CODES)[keyof typeof WARNING_CODES];
|
|
1846
|
+
|
|
1847
|
+
/**
|
|
1848
|
+
* Transform the ComponentsObject (4.8.7)
|
|
1849
|
+
* @see https://spec.openapis.org/oas/latest.html#components-object
|
|
1850
|
+
*
|
|
1851
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 6). Same name and parameters as the original;
|
|
1852
|
+
* returns IR (task 6.2). For the public API: the `components` type, then the root type aliases.
|
|
1853
|
+
*/
|
|
813
1854
|
declare function transformComponentsObject(componentsObject: ComponentsObject, ctx: GlobalContext): (IrType | IrTypeAliasDeclaration)[];
|
|
814
1855
|
|
|
1856
|
+
/**
|
|
1857
|
+
* Transform HeaderObject nodes (4.8.21)
|
|
1858
|
+
* @see https://spec.openapis.org/oas/v3.1.0#header-object
|
|
1859
|
+
*
|
|
1860
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 3). Same name and parameters as the original;
|
|
1861
|
+
* returns IR (task 6.2). For the public API and for users who call it from callbacks.
|
|
1862
|
+
*/
|
|
815
1863
|
declare function transformHeaderObject(headerObject: HeaderObject, options: TransformNodeOptions): IrType;
|
|
816
1864
|
|
|
1865
|
+
/**
|
|
1866
|
+
* Transform MediaTypeObject nodes (4.8.14)
|
|
1867
|
+
* @see https://spec.openapis.org/oas/v3.1.0#media-type-object
|
|
1868
|
+
*
|
|
1869
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 3). Same name and parameters as the original;
|
|
1870
|
+
* returns IR (task 6.2). For the public API and for users who call it from callbacks.
|
|
1871
|
+
*/
|
|
817
1872
|
declare function transformMediaTypeObject(mediaTypeObject: MediaTypeObject, options: TransformNodeOptions): IrType;
|
|
818
1873
|
|
|
1874
|
+
/**
|
|
1875
|
+
* Transform OperationObject nodes (4.8.10)
|
|
1876
|
+
* @see https://spec.openapis.org/oas/v3.1.0#operation-object
|
|
1877
|
+
*
|
|
1878
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 5). Same name and parameters as the original;
|
|
1879
|
+
* returns IR (task 6.2). For the public API and for users who call it from callbacks.
|
|
1880
|
+
*/
|
|
819
1881
|
declare function transformOperationObject(operationObject: OperationObject, options: TransformNodeOptions): IrMember[];
|
|
1882
|
+
/** inject an operation at the top level */
|
|
820
1883
|
declare function injectOperationObject(operationId: string, operationObject: OperationObject, options: TransformNodeOptions): void;
|
|
821
1884
|
|
|
1885
|
+
/**
|
|
1886
|
+
* Transform ParameterObject nodes (4.8.12)
|
|
1887
|
+
* @see https://spec.openapis.org/oas/v3.1.0#parameter-object
|
|
1888
|
+
*
|
|
1889
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 3). Same name and parameters as the original;
|
|
1890
|
+
* returns IR (task 6.2). For the public API and for users who call it from callbacks.
|
|
1891
|
+
*/
|
|
822
1892
|
declare function transformParameterObject(parameterObject: ParameterObject, options: TransformNodeOptions): IrType;
|
|
823
1893
|
|
|
1894
|
+
/** The methods every generated path item lists, with `?: never` when the document has none. */
|
|
824
1895
|
type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace";
|
|
1896
|
+
/**
|
|
1897
|
+
* The OpenAPI 3.2 QUERY method. Its member is written only when the path item declares it, so
|
|
1898
|
+
* documents without it keep their output (ADR-020).
|
|
1899
|
+
*/
|
|
1900
|
+
declare const QUERY_METHOD = "query";
|
|
1901
|
+
/** Every operation field of a path item. */
|
|
1902
|
+
type PathItemMethod = HttpMethod | typeof QUERY_METHOD;
|
|
825
1903
|
|
|
826
|
-
|
|
1904
|
+
/**
|
|
1905
|
+
* The operation methods of a path item: openapi-typescript's eight, plus the OpenAPI 3.2 `query`
|
|
1906
|
+
* (ADR-020), as `HttpMethod` of openapi-typesafe-helpers lists them.
|
|
1907
|
+
*/
|
|
1908
|
+
type Method = PathItemMethod;
|
|
1909
|
+
/**
|
|
1910
|
+
* Transform PathItem nodes (4.8.9)
|
|
1911
|
+
* @see https://spec.openapis.org/oas/v3.1.0#path-item-object
|
|
1912
|
+
*
|
|
1913
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 5). Same name and parameters as the original;
|
|
1914
|
+
* returns IR (task 6.2). For the public API and for users who call it from callbacks.
|
|
1915
|
+
*/
|
|
827
1916
|
declare function transformPathItemObject(pathItem: PathItemObject, options: TransformNodeOptions): IrType;
|
|
828
1917
|
|
|
1918
|
+
/**
|
|
1919
|
+
* Transform the PathsObject node (4.8.8)
|
|
1920
|
+
* @see https://spec.openapis.org/oas/v3.1.0#operation-object
|
|
1921
|
+
*
|
|
1922
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 5). Same name and parameters as the original;
|
|
1923
|
+
* returns IR (task 6.2). For the public API and for users who call it from callbacks.
|
|
1924
|
+
*/
|
|
829
1925
|
declare function transformPathsObject(pathsObject: PathsObject, ctx: GlobalContext): IrType;
|
|
830
1926
|
|
|
1927
|
+
/**
|
|
1928
|
+
* Transform RequestBodyObject nodes (4.8.13)
|
|
1929
|
+
* @see https://spec.openapis.org/oas/v3.1.0#request-body-object
|
|
1930
|
+
*
|
|
1931
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 4). Same name and parameters as the original;
|
|
1932
|
+
* returns IR (task 6.2). For the public API and for users who call it from callbacks.
|
|
1933
|
+
*/
|
|
831
1934
|
declare function transformRequestBodyObject(requestBodyObject: RequestBodyObject, options: TransformNodeOptions): IrType;
|
|
832
1935
|
|
|
1936
|
+
/**
|
|
1937
|
+
* Transform ResponseObject nodes (4.8.17)
|
|
1938
|
+
* @see https://spec.openapis.org/oas/v3.1.0#response-object
|
|
1939
|
+
*
|
|
1940
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 4). Same name and parameters as the original;
|
|
1941
|
+
* returns IR (task 6.2). For the public API and for users who call it from callbacks.
|
|
1942
|
+
*/
|
|
833
1943
|
declare function transformResponseObject(responseObject: ResponseObject, options: TransformNodeOptions): IrType;
|
|
834
1944
|
|
|
1945
|
+
/**
|
|
1946
|
+
* Transform ResponsesObject nodes (4.8.16)
|
|
1947
|
+
* @see https://spec.openapis.org/oas/v3.1.0#responses-object
|
|
1948
|
+
*
|
|
1949
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 4). Same name and parameters as the original;
|
|
1950
|
+
* returns IR (task 6.2). For the public API and for users who call it from callbacks.
|
|
1951
|
+
*/
|
|
835
1952
|
declare function transformResponsesObject(responsesObject: ResponsesObject, options: TransformNodeOptions): IrType;
|
|
836
1953
|
|
|
1954
|
+
/**
|
|
1955
|
+
* Transform SchemaObject nodes (4.8.24)
|
|
1956
|
+
* @see https://spec.openapis.org/oas/v3.1.0#schema-object
|
|
1957
|
+
*
|
|
1958
|
+
* Ported to IR (ENGINEERING_PLAN Phase 5, step 2): the work happens in
|
|
1959
|
+
* `application/transform/schema`; this keeps the original name and parameters, returning IR
|
|
1960
|
+
* (task 6.2), for the public API and for users who call it from callbacks.
|
|
1961
|
+
*/
|
|
837
1962
|
declare function transformSchemaObject(schemaObject: SchemaObject | ReferenceObject, options: TransformNodeOptions, fromAdditionalProperties?: boolean): IrType;
|
|
1963
|
+
/** Transform SchemaObjects without the `postTransform` callback at the top level. */
|
|
838
1964
|
declare function transformSchemaObjectWithComposition(schemaObject: SchemaObject | ReferenceObject, options: TransformNodeOptions, fromAdditionalProperties?: boolean): IrType;
|
|
839
1965
|
|
|
840
|
-
export {
|
|
841
|
-
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, 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 };
|