Skip to content

Releases: openapi-ts/openapi-typescript

[email protected]

24 Jun 17:03
a9f529e

Choose a tag to compare

Patch Changes

[email protected]

21 Jun 23:25
ff93eac

Choose a tag to compare

Patch Changes

[email protected]

20 Jun 03:48
d7494ba

Choose a tag to compare

Major Changes

  • 6d1eb32 Thanks @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:

    + 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, and fetch (Node.js-only) options were all removed from the CLI and Node.js API
    • --immutable-types has been renamed to --immutable
    • --support-array-length has been renamed to --array-length
  • fbaf96d Thanks @drwpow! - โš ๏ธ Breaking: Remove globbing schemas in favor of redocly.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 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).

  • 6d1eb32 Thanks @drwpow! - โš ๏ธ Breaking defaultNonNullable option now defaults to true. Youโ€™ll now need to manually set false to return to old behavior.

  • 799194d Thanks @drwpow~ - โš ๏ธ Breaking TypeScript is now a peerDependency and must be installed alongside openapi-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 via apis key in redocly.config.yaml. See docs for more info.

  • 6d1eb32 Thanks @drwpow! - โœจ Feature: add enum option to export top-level enums from schemas

  • 6d1eb32 Thanks @drwpow! - โœจ Feature: add formatOptions 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.

[email protected]

20 Jun 03:47
b43f815

Choose a tag to compare

Minor Changes

  • โš ๏ธ Breaking Change: openapi-typescript@7 is needed to work. Youโ€™ll get type errors with openapi-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: The Content-Type header is no longer sent by default if a body payload is attached.

  • โš ๏ธ Breaking Change: The customFetch type now calls fetch(input: string, init: RequestInit) and the types have been updated, rather than fetch(input: Request) introduced in 0.9.0. Edit: this has been reverted due to errors reported in some environments. The 0.9.0 behavior is still present where fetch(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]

19 Jun 19:59
41ea873

Choose a tag to compare

Patch Changes

[email protected]

24 May 17:41

Choose a tag to compare

Patch Changes

[email protected]

19 May 19:22
24eca72

Choose a tag to compare

Patch Changes

  • #1672 64cb619 Thanks @jaredLunde! - Fixes issue where native properties were not excluded from custom properties in the CustomRequest class

[email protected]

19 May 19:01
bda737c

Choose a tag to compare

[email protected] Pre-release
Pre-release

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 as transform() and postTransform(). To migrate, youโ€™ll have to use the typescript 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, and fetch (Node.js-only) options were all removed from the CLI and Node.js API
    • --immutable-types has been renamed to --immutable
    • --support-array-length has been renamed to --array-length
  • fbaf96d Thanks @drwpow! - โš ๏ธ Breaking: Remove globbing schemas in favor of redocly.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 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).

  • 6d1eb32 Thanks @drwpow! - โš ๏ธ Breaking defaultNonNullable option now defaults to true. Youโ€™ll now need to manually set false to return to old behavior.

  • 799194d Thanks @drwpow~ - โš ๏ธ Breaking TypeScript is now a peerDependency and must be installed alongside openapi-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 via apis key in redocly.config.yaml. See docs for more info.

  • 6d1eb32 Thanks @drwpow! - โœจ Feature: add enum option to export top-level enums from schemas

  • 6d1eb32 Thanks @drwpow! - โœจ Feature: add formatOptions 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

6.6.1

Patch Changes

6.6.0

Minor Changes

6.5.5

Patch Changes

6.5.4

Patch Changes

  • #1324 0357325 Thanks @drwpow! - Fix accidental quote appearing in components/responses with $refs

6.5.3

Patch Changes

Read more

[email protected]

16 May 17:08
a7dbe90

Choose a tag to compare

Patch Changes

[email protected]

28 Apr 22:57
7e3df85

Choose a tag to compare

Patch Changes