Releases: openapi-ts/openapi-typescript
[email protected]
Major Changes
-
6d1eb32
Thanks @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 thetypescript
compiler 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
typescript
parser to inspect how TypeScript is interpreted as an AST. -
6d1eb32
Thanks @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-types
has been renamed to--immutable
--support-array-length
has been renamed to--array-length
- The
-
fbaf96d
Thanks @drwpow! -β οΈ Breaking: Remove globbing schemas in favor ofredocly.yaml
config. Specify multiple schemas with outputs in there instead. See Multiple schemas for more info. -
6d1eb32
Thanks @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. -
6d1eb32
Thanks @drwpow! -β οΈ Breaking: No moreexternal
export in schemas anymore. Everything gets flattened into thecomponents
object instead (if referencing a schema object from a remote partial, note it may have had a minor name change to avoid conflict). -
6d1eb32
Thanks @drwpow! -β οΈ BreakingdefaultNonNullable
option now defaults totrue
. Youβll now need to manually setfalse
to return to old behavior. -
799194d
Thanks @drwpow~ -β οΈ Breaking TypeScript is now a peerDependency and must be installed alongsideopenapi-typescript
Minor Changes
-
6d1eb32
Thanks @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
-
312b7ba
Thanks @drwpow! - β¨ Feature: allow configuration of schemas viaapis
key in redocly.config.yaml. See docs for more info.- Any options passed into your redocly.yaml config are respected
-
6d1eb32
Thanks @drwpow! - β¨ Feature: addenum
option to export top-level enums from schemas -
6d1eb32
Thanks @drwpow! - β¨ Feature: addformatOptions
to allow formatting TS output -
6d1eb32
Thanks @drwpow! - β¨ Feature: header responses add[key: string]: unknown
index type to allow for additional untyped headers -
6d1eb32
Thanks @drwpow! - β¨ Feature: bundle schemas with Redocly CLI -
6d1eb32
Thanks @drwpow! - β¨ Feature: Added debugger that lets you profile performance and see more in-depth messages -
#1374
7ac5174
Thanks @ElForastero! - Add support for x-enum-varnames and x-enum-descriptions -
#1545
9158b81
Thanks @jaredLunde! - Replace # characters in operation IDs with a slash
Patch Changes
[email protected]
Minor Changes
-
β οΈ Breaking Change:openapi-typescript@7
is needed to work. Youβll get type errors withopenapi-typescript@6
and 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-Type
header 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. ThecustomFetch
type now callsfetch(input: string, init: RequestInit)
and the types have been updated, rather thanfetch(input: Request)
introduced in0.9.0
.0.9.0
behavior 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
id
to middleware handlers that create a unique ID per-fetch
[email protected]
Patch Changes
- #1697
e77ce50
Thanks @armandabric! - Expose original request on Middleware.onResponse
[email protected]
Patch Changes
- #1648
37885c2aec15d406720c5457da5bcaf7a142ab75
Thanks @nzapponi! - Fix SecurityRequirementsObject to allow partial security schemes
[email protected]
Patch Changes
- #1672
64cb619
Thanks @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
-
6d1eb32
Thanks @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 thetypescript
compiler 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
typescript
parser to inspect how TypeScript is interpreted as an AST. -
6d1eb32
Thanks @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-types
has been renamed to--immutable
--support-array-length
has been renamed to--array-length
- The
-
fbaf96d
Thanks @drwpow! -β οΈ Breaking: Remove globbing schemas in favor ofredocly.yaml
config. Specify multiple schemas with outputs in there instead. See Multiple schemas for more info. -
6d1eb32
Thanks @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. -
6d1eb32
Thanks @drwpow! -β οΈ Breaking: No moreexternal
export in schemas anymore. Everything gets flattened into thecomponents
object instead (if referencing a schema object from a remote partial, note it may have had a minor name change to avoid conflict). -
6d1eb32
Thanks @drwpow! -β οΈ BreakingdefaultNonNullable
option now defaults totrue
. Youβll now need to manually setfalse
to return to old behavior. -
799194d
Thanks @drwpow~ -β οΈ Breaking TypeScript is now a peerDependency and must be installed alongsideopenapi-typescript
Minor Changes
-
6d1eb32
Thanks @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
-
312b7ba
Thanks @drwpow! - β¨ Feature: allow configuration of schemas viaapis
key in redocly.config.yaml. See docs for more info.- Any options passed into your redocly.yaml config are respected
-
6d1eb32
Thanks @drwpow! - β¨ Feature: addenum
option to export top-level enums from schemas -
6d1eb32
Thanks @drwpow! - β¨ Feature: addformatOptions
to allow formatting TS output -
6d1eb32
Thanks @drwpow! - β¨ Feature: header responses add[key: string]: unknown
index type to allow for additional untyped headers -
6d1eb32
Thanks @drwpow! - β¨ Feature: bundle schemas with Redocly CLI -
6d1eb32
Thanks @drwpow! - β¨ Feature: Added debugger that lets you profile performance and see more in-depth messages -
#1374
7ac5174
Thanks @ElForastero! - Add support for x-enum-varnames and x-enum-descriptions -
#1545
9158b81
Thanks @jaredLunde! - Replace # characters in operation IDs with a slash
Patch Changes
-
6d1eb32
Thanks @drwpow! - Refactor internals to use TypeScript AST rather than string mashing -
6d1eb32
Thanks @drwpow! - π§Ή Cleaned up and reorganized all tests -
#1602
9da96cd
Thanks @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
f6fdd2f
Thanks @drwpow! - Improve YAML vs JSON parsing -
#1345
6f078c1
Thanks @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
7cb02ac
Thanks @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...
[email protected]
[email protected]
[email protected]
Patch Changes
-
#1597
1f7ad9d
Thanks @armandabric! - Allow to select the response content type -
#1585
4e06f86
Thanks @mikestopcontinues! - Update types for path-methods object -
#1610
cc8073b
Thanks @illright! - Fix data/error discrimination when there are empty-body errors
[email protected]
Patch Changes
-
#1535
48ca069fd889acd469955589ff3ec74e775ca9fd
Thanks @tvanier! - Support single operation parameter -
#1524
fe6c6d1526c59e4f9021d71cad74feba315f337f
Thanks @WickyNilliams! - Keep type information for nullable fields when possible