|
1 | 1 | # openapi-typescript
|
2 | 2 |
|
| 3 | +## 7.0.0 |
| 4 | + |
| 5 | +### Major Changes |
| 6 | + |
| 7 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ **Breaking**: The Node.js API now returns the TypeScript AST for the main method as well as `transform()` and `postTransform()`. To migrate, you’ll have to use the `typescript` compiler API: |
| 8 | + |
| 9 | + ```diff |
| 10 | + + import ts from "typescript"; |
| 11 | + |
| 12 | + + const DATE = ts.factory.createIdentifier("Date"); |
| 13 | + + const NULL = ts.factory.createLiteralTypeNode(ts.factory.createNull()); |
| 14 | + |
| 15 | + const ast = await openapiTS(mySchema, { |
| 16 | + transform(schemaObject, metadata) { |
| 17 | + if (schemaObject.format === "date-time") { |
| 18 | + - return schemaObject.nullable ? "Date | null" : "Date"; |
| 19 | + + return schemaObject.nullable |
| 20 | + + ? ts.factory.createUnionTypeNode([DATE, NULL]) |
| 21 | + + : DATE; |
| 22 | + } |
| 23 | + }, |
| 24 | + }; |
| 25 | + ``` |
| 26 | + |
| 27 | + Though it’s more verbose, it’s also more powerful, as now you have access to additional properties of the generated code you didn’t before (such as injecting comments). |
| 28 | + |
| 29 | + For example syntax, search this codebae to see how the TypeScript AST is used. |
| 30 | + |
| 31 | + Also see [AST Explorer](https://astexplorer.net/)’s `typescript` parser to inspect how TypeScript is interpreted as an AST. |
| 32 | + |
| 33 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ **Breaking**: Changing of several CLI flags and Node.js API options |
| 34 | + |
| 35 | + - The `--auth`, `--httpHeaders`, `--httpMethod`, and `fetch` (Node.js-only) options were all removed from the CLI and Node.js API |
| 36 | + - To migrate, you’ll need to create a [redocly.yaml config](https://redocly.com/docs/cli/configuration/) that specifies your auth options [in the http setting](https://redocly.com/docs/cli/configuration/#resolve-non-public-or-non-remote-urls) |
| 37 | + - You can also set your fetch client in redocly.yaml as well. |
| 38 | + - `--immutable-types` has been renamed to `--immutable` |
| 39 | + - `--support-array-length` has been renamed to `--array-length` |
| 40 | + |
| 41 | +- [`fbaf96d`](https://github.com/drwpow/openapi-typescript/commit/fbaf96d33181a2fabd3d4748e54c0f111ed6756e) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ **Breaking**: Remove globbing schemas in favor of `redocly.yaml` config. Specify multiple schemas with outputs in there instead. See [Multiple schemas](https://openapi-ts.pages.dev/docs/cli/#multiple-schemas) for more info. |
| 42 | + |
| 43 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ **Breaking**: Most optional objects are now always present in types, just typed as `:never`. This includes keys of the Components Object as well as HTTP methods. |
| 44 | + |
| 45 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ **Breaking**: No more `external` export in schemas anymore. Everything gets flattened into the `components` object instead (if referencing a schema object from a remote partial, note it may have had a minor name change to avoid conflict). |
| 46 | + |
| 47 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ **Breaking** `defaultNonNullable` option now defaults to `true`. You’ll now need to manually set `false` to return to old behavior. |
| 48 | + |
| 49 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ **Breaking**: additionalProperties no longer have `| undefined` automatically appended |
| 50 | + |
| 51 | +### Minor Changes |
| 52 | + |
| 53 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ✨ **Feature**: automatically validate schemas with Redocly CLI ([docs](https://redocly.com/docs/cli/)). No more need for external tools to report errors! 🎉 |
| 54 | + |
| 55 | + - By default, it will only throw on actual schema errors (uses Redocly’s default settings) |
| 56 | + - For stricter linting or custom rules, you can create a [redocly.yaml config](https://redocly.com/docs/cli/configuration/) |
| 57 | + |
| 58 | +- [`312b7ba`](https://github.com/drwpow/openapi-typescript/commit/312b7ba03fc0334153d4eeb51d6159f3fc63934e) Thanks [@drwpow](https://github.com/drwpow)! - ✨ **Feature:** allow configuration of schemas via `apis` key in redocly.config.yaml. [See docs](https://openapi-ts.pages.dev/cli/) for more info. |
| 59 | + |
| 60 | + - Any options passed into your [redocly.yaml config](https://redocly.com/docs/cli/configuration/) are respected |
| 61 | + |
| 62 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ✨ **Feature**: add `enum` option to export top-level enums from schemas |
| 63 | + |
| 64 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ✨ **Feature**: add `formatOptions` to allow formatting TS output |
| 65 | + |
| 66 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ✨ **Feature**: header responses add `[key: string]: unknown` index type to allow for additional untyped headers |
| 67 | + |
| 68 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - ✨ **Feature**: bundle schemas with Redocly CLI |
| 69 | + |
| 70 | +### Patch Changes |
| 71 | + |
| 72 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - Refactor internals to use TypeScript AST rather than string mashing |
| 73 | + |
| 74 | +- [`6d1eb32`](https://github.com/drwpow/openapi-typescript/commit/6d1eb32e610cb62effbd1a817ae8fc93337126a6) Thanks [@drwpow](https://github.com/drwpow)! - 🧹 Cleaned up and reorganized all tests |
| 75 | + |
3 | 76 | ## 6.7.0
|
4 | 77 |
|
5 | 78 | ### Minor Changes
|
|
0 commit comments