Releases: openapi-ts/openapi-typescript
[email protected]
[email protected]
[email protected]
Major Changes
-
6d1eb32Thanks @drwpow! -โ ๏ธ Breaking: The Node.js API now returns the TypeScript AST for the main method as well astransform()andpostTransform(). To migrate, youโll have to use thetypescriptcompiler API:+ import ts from "typescript"; + const DATE = ts.factory.createIdentifier("Date"); + const NULL = ts.factory.createLiteralTypeNode(ts.factory.createNull()); const ast = await openapiTS(mySchema, { transform(schemaObject, metadata) { if (schemaObject.format === "date-time") { - return schemaObject.nullable ? "Date | null" : "Date"; + return schemaObject.nullable + ? ts.factory.createUnionTypeNode([DATE, NULL]) + : DATE; } }, };
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).
For example syntax, search this codebae to see how the TypeScript AST is used.
Also see AST Explorerโs
typescriptparser to inspect how TypeScript is interpreted as an AST. -
6d1eb32Thanks @drwpow! -โ ๏ธ Breaking: Changing of several CLI flags and Node.js API options- The
--auth,--httpHeaders,--httpMethod, andfetch(Node.js-only) options were all removed from the CLI and Node.js API- To migrate, youโll need to create a redocly.yaml config that specifies your auth options in the http setting
- You can also set your fetch client in redocly.yaml as well.
--immutable-typeshas been renamed to--immutable--support-array-lengthhas been renamed to--array-length
- The
-
fbaf96dThanks @drwpow! -โ ๏ธ Breaking: Remove globbing schemas in favor ofredocly.yamlconfig. Specify multiple schemas with outputs in there instead. See Multiple schemas for more info. -
6d1eb32Thanks @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. -
6d1eb32Thanks @drwpow! -โ ๏ธ Breaking: No moreexternalexport in schemas anymore. Everything gets flattened into thecomponentsobject instead (if referencing a schema object from a remote partial, note it may have had a minor name change to avoid conflict). -
6d1eb32Thanks @drwpow! -โ ๏ธ BreakingdefaultNonNullableoption now defaults totrue. Youโll now need to manually setfalseto return to old behavior. -
799194dThanks @drwpow~ -โ ๏ธ Breaking TypeScript is now a peerDependency and must be installed alongsideopenapi-typescript
Minor Changes
-
6d1eb32Thanks @drwpow! - โจ Feature: automatically validate schemas with Redocly CLI (docs). No more need for external tools to report errors! ๐- By default, it will only throw on actual schema errors (uses Redoclyโs default settings)
- For stricter linting or custom rules, you can create a redocly.yaml config
-
312b7baThanks @drwpow! - โจ Feature: allow configuration of schemas viaapiskey in redocly.config.yaml. See docs for more info.- Any options passed into your redocly.yaml config are respected
-
6d1eb32Thanks @drwpow! - โจ Feature: addenumoption to export top-level enums from schemas -
6d1eb32Thanks @drwpow! - โจ Feature: addformatOptionsto allow formatting TS output -
6d1eb32Thanks @drwpow! - โจ Feature: header responses add[key: string]: unknownindex type to allow for additional untyped headers -
6d1eb32Thanks @drwpow! - โจ Feature: bundle schemas with Redocly CLI -
6d1eb32Thanks @drwpow! - โจ Feature: Added debugger that lets you profile performance and see more in-depth messages -
#1374
7ac5174Thanks @ElForastero! - Add support for x-enum-varnames and x-enum-descriptions -
#1545
9158b81Thanks @jaredLunde! - Replace # characters in operation IDs with a slash
Patch Changes
[email protected]
Minor Changes
-
โ ๏ธ Breaking Change:openapi-typescript@7is needed to work. Youโll get type errors withopenapi-typescript@6and below. -
โ ๏ธ Breaking Change: The Middleware API has changed to be an object rather than(request, options)or(response, options). See Middleware docs for updated API. -
โ ๏ธ Breaking Change: TheContent-Typeheader is no longer sent by default if a body payload is attached. -
โ ๏ธ Breaking Change: TheEdit: this has been reverted due to errors reported in some environments. ThecustomFetchtype now callsfetch(input: string, init: RequestInit)and the types have been updated, rather thanfetch(input: Request)introduced in0.9.0.0.9.0behavior is still present wherefetch(input: Request)is called for the final request. -
โ ๏ธ Breaking Change: the error type no longer is a union of all possible values; it will take the first it finds (due to some error type in some schemas being missing or incomplete, resulting in an unresolvable union)
Patch Changes
- Added
idto middleware handlers that create a unique ID per-fetch
[email protected]
Patch Changes
- #1697
e77ce50Thanks @armandabric! - Expose original request on Middleware.onResponse
[email protected]
Patch Changes
- #1648
37885c2aec15d406720c5457da5bcaf7a142ab75Thanks @nzapponi! - Fix SecurityRequirementsObject to allow partial security schemes
[email protected]
Patch Changes
- #1672
64cb619Thanks @jaredLunde! - Fixes issue where native properties were not excluded from custom properties in the CustomRequest class
[email protected]
openapi-typescript
7.0.0
Major Changes
-
6d1eb32Thanks @drwpow! -โ ๏ธ Breaking: The Node.js API now returns the TypeScript AST for the main method as well astransform()andpostTransform(). To migrate, youโll have to use thetypescriptcompiler API:+ import ts from "typescript"; + const DATE = ts.factory.createIdentifier("Date"); + const NULL = ts.factory.createLiteralTypeNode(ts.factory.createNull()); const ast = await openapiTS(mySchema, { transform(schemaObject, metadata) { if (schemaObject.format === "date-time") { - return schemaObject.nullable ? "Date | null" : "Date"; + return schemaObject.nullable + ? ts.factory.createUnionTypeNode([DATE, NULL]) + : DATE; } }, };
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).
For example syntax, search this codebae to see how the TypeScript AST is used.
Also see AST Explorerโs
typescriptparser to inspect how TypeScript is interpreted as an AST. -
6d1eb32Thanks @drwpow! -โ ๏ธ Breaking: Changing of several CLI flags and Node.js API options- The
--auth,--httpHeaders,--httpMethod, andfetch(Node.js-only) options were all removed from the CLI and Node.js API- To migrate, youโll need to create a redocly.yaml config that specifies your auth options in the http setting
- You can also set your fetch client in redocly.yaml as well.
--immutable-typeshas been renamed to--immutable--support-array-lengthhas been renamed to--array-length
- The
-
fbaf96dThanks @drwpow! -โ ๏ธ Breaking: Remove globbing schemas in favor ofredocly.yamlconfig. Specify multiple schemas with outputs in there instead. See Multiple schemas for more info. -
6d1eb32Thanks @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. -
6d1eb32Thanks @drwpow! -โ ๏ธ Breaking: No moreexternalexport in schemas anymore. Everything gets flattened into thecomponentsobject instead (if referencing a schema object from a remote partial, note it may have had a minor name change to avoid conflict). -
6d1eb32Thanks @drwpow! -โ ๏ธ BreakingdefaultNonNullableoption now defaults totrue. Youโll now need to manually setfalseto return to old behavior. -
799194dThanks @drwpow~ -โ ๏ธ Breaking TypeScript is now a peerDependency and must be installed alongsideopenapi-typescript
Minor Changes
-
6d1eb32Thanks @drwpow! - โจ Feature: automatically validate schemas with Redocly CLI (docs). No more need for external tools to report errors! ๐- By default, it will only throw on actual schema errors (uses Redoclyโs default settings)
- For stricter linting or custom rules, you can create a redocly.yaml config
-
312b7baThanks @drwpow! - โจ Feature: allow configuration of schemas viaapiskey in redocly.config.yaml. See docs for more info.- Any options passed into your redocly.yaml config are respected
-
6d1eb32Thanks @drwpow! - โจ Feature: addenumoption to export top-level enums from schemas -
6d1eb32Thanks @drwpow! - โจ Feature: addformatOptionsto allow formatting TS output -
6d1eb32Thanks @drwpow! - โจ Feature: header responses add[key: string]: unknownindex type to allow for additional untyped headers -
6d1eb32Thanks @drwpow! - โจ Feature: bundle schemas with Redocly CLI -
6d1eb32Thanks @drwpow! - โจ Feature: Added debugger that lets you profile performance and see more in-depth messages -
#1374
7ac5174Thanks @ElForastero! - Add support for x-enum-varnames and x-enum-descriptions -
#1545
9158b81Thanks @jaredLunde! - Replace # characters in operation IDs with a slash
Patch Changes
-
6d1eb32Thanks @drwpow! - Refactor internals to use TypeScript AST rather than string mashing -
6d1eb32Thanks @drwpow! - ๐งน Cleaned up and reorganized all tests -
#1602
9da96cdThanks @JeanRemiDelteil! - Do not add readonly on Typescript enum when the --immutable option is used.
6.7.0
Minor Changes
6.6.2
Patch Changes
-
#1348
f6fdd2fThanks @drwpow! - Improve YAML vs JSON parsing -
#1345
6f078c1Thanks @SchabaJo! - Mirror directory structure of input files if output is a directory to prevent overwriting the same file again and again.
6.6.1
Patch Changes
6.6.0
Minor Changes
- #1335
7cb02acThanks @duncanbeevers! - Request parameters member is optional when all parameters are optional.
6.5.5
Patch Changes
6.5.4
Patch Changes
6.5.3
Patch Changes
- #1320 [
3cf78b9](3cf78b920ab23624c0524e0d5833...