openapi-typesafe 1.0.0-rc.1 → 1.0.0-rc.2

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