- #2415
f55fb72Thanks @remy90! - SupportadditionalProperties: trueon string enums by generating a loose autocomplete union ((enum literals) | (string & {})), preserving editor suggestions while still accepting arbitrary string values.
- #2549
a690e52Thanks @abumalick! - Add readOnly/writeOnly support via--read-write-markersflag. When enabled, readOnly properties are wrapped with$Read<T>and writeOnly properties with$Write<T>. openapi-fetch usesReadable<T>andWritable<T>helpers to exclude these properties from responses and request bodies respectively.
- #2524
697f7feThanks @gunnarvelle! - Added flag to keep casing for exported root types
- #2536
e3c05a4Thanks @darkbasic! - FixenumValues: trueoutput for schemas that useoneOf/anyOfunions by narrowing union types withExtract<>before accessing variant-specific properties. This prevents invalid type paths when an accessed property only exists on some union members.
-
#2139
12f9c29Thanks @darkbasic! - All kinds of enum related fixes (enums in arrays, in optional props, in unions, in request body, with record types...) -
#2548
4385590Thanks @mynnx! - Fixes the--redoclyflag so that it no longer hangs and is able to lookup the Redocly file at a custom path
- #2480
e04dc65Thanks @MatissJanis! - Fix multi-line jsdoc comments
-
#2449
bdd5ddbThanks @kristianjf! - Add transformProperty hook for property signature modification -
#2288
0f22be2Thanks @hontas! - Add support for patternProperties
-
#2393
6943ccfThanks @simon-curtis! - Now checking for null & empty string when generating enum description -
#2375
5be22d7Thanks @ParkerVR! - Fix behavior when using enum and export-type flags
- #2374
c5ebbb8Thanks @cmlee-accelins! - Add JSDoc support for the recommended examples array on JSON Schema objects.
- #2185
67889baThanks @duncanbeevers! - Fix invalid $ref index into path
- #2260
7205e12Thanks @zrosenbauer! - Prevents aTypeErrordue to a bad in operator fortype: "array"when abooleanis set onitems
-
#2199
fc3f7f8Thanks @StefanTerdell! - Fix boolean object property schemas -
#2152
47e4b5eThanks @insertmike! - - Fixed --make-paths-enum option transforming the paths URL (:idinstead of{id}) -
#2241
ef23947Thanks @stanleyk! - Replacinganywithunknownin theReadonlyArraytype declaration.
- #2131
41bed98Thanks @htunnicliff! - Update @redocly/openapi-core to fix punycode deprecation bug
- #2102
0cdfc47Thanks @ViktorPontinen! - Support generating path params for flaky schemas using --generate-path-params option
- #2049
39f9b2fThanks @duncanbeevers! - Add schema to postTransform options
-
#2052
d2de5c7Thanks @laurenz-glueck! - brings back --make-paths-enum option to generate ApiPaths enum -
#2059
9e4f61cThanks @gduliscouet-ubitransport! - Allow all types except UNKNOWN to be nullable
- #1873
c2c396dThanks @DanDeMicco! - Support for generating enums when enums definition has null value
- #1876
a9cd9aaThanks @BradHacker! - Add option to export all root component types
- #1877
94592a4Thanks @phk422! - fix: replace special characters usingSPECIAL_CHARACTER_MAPfor duplicate-identifiers
- #1849
08bde72Thanks @liangskyli! - fix: keyedParameters use unique key
- #1784
c2f8655Thanks @yoshi2no! - Fix: Correct handling of identical minItems and maxItems in array schemas when arrayLength option is true
-
#1772
41cb9a2Thanks @ashwin153! - fix: add explicit import of performance to fix bazel compatibility issues -
#1764
2793049Thanks @michalfedyna! - Fix --properties-required-by-default flag not working -
#1763
19b9383Thanks @nkt! - fix: schema.content might be omitted
- #1746
e705909Thanks @phk422! - fix: Correct handling of default parameter values in referenced component schema
- #1761
8043c5dThanks @yoshi2no! - fix: Enum option cannot generate enums if values are not valid property names
-
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
-
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
-
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.
-
#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.
- #1335
7cb02acThanks @duncanbeevers! - Request parameters member is optional when all parameters are optional.
- #1320
3cf78b9Thanks @duncanbeevers! - Wrap nested readonly types in parentheses, allowing for nested immutable arrays
- #1295
99a1648Thanks @pvanagtmaal! - Avoid adding a undefined union to additionProperties
-
#1280
50441d0Thanks @pvanagtmaal! - Fix invalid typescript for empty request bodies, fix headers being left out when response body is omitted -
#1289
7f452faThanks @adamschoenemann! - Fixed a bug where references to types with discriminators with implicit mappings would generate incorrect types
- #1281
ebd31ffThanks @pvanagtmaal! - Refactor CLI path handling, fixing several bugs
- #1278
d7420e3Thanks @pvanagtmaal! - Fix externalizing external refs
- #1269
e735ff2Thanks @pimveldhuisen! - Stop trimming whitespace other than linebreaks in string values
-
#1248
c145f5fThanks @drwpow! - Fix Record<string, never> appearing in union -
#1248
c145f5fThanks @drwpow! - Improve oneOf generated types
-
#1231
e1ce2d6Thanks @tkrotoff! - Do not append trailing spaces to JSDoc tags -
#1232
31c030dThanks @tkrotoff! - Remove unnecessary array parenthesis
- #1200
4fc8c20Thanks @toomuchdesign! - Remove unexpected empty string in generated nullable polymophic enum types (["string", "null"])
- #1193
64decb7Thanks @psychedelicious! - Add example forBlobtype transforms
- #1166
db37f3cThanks @pvanagtmaal! - Fix property escaping for discriminators
-
#1149
b82cffbThanks @duncanbeevers! - Stringify const values with no specified type -
#1156
ad017a9Thanks @horaklukas! - Avoid index signature TS error for paths with empty params
- 7d09c3b: Support nested path parameters in
--path-params-as-types(#1130). Thanks, barakalon!
- Fix remote
$refs to complete schemas (#1087) - Fix incorrect check for protocol by @happycollision (#1088)
- Fix missing parameters in operation object (#1090)
- Fix tuples type generation by @liangskyli (#1085)
- Fix path generation by @HiiiiD (#991)
- If no type is specified, type as
unknownby @mitchell-merry (#1049) - Ensure not required parameters are created as optional properties by @AplusKminus (#1053)
- Fix missing type defs (#1072)
- Deduplicate unions by @mitchell-merry (#1069)
- Fix tuples type generation support by @liangskyli (#1011)
- Fix
$ref’d parameters missing (#1061) - Fix
oneOfnumber const (#1056) by @qnp
- New
--empty-objects-unknownflag for better control over unspecified object types’ default shape by @duncanbeevers (#1032)
- JSDoc improvements by @mitchell-merry (#1029)
- Fix readonly nullable properties by @mtth (#1036)
- Tiny QoL improvements to invalid schema errors (#1043)
- Fix response key for HTTP ranges (#1010) @stefanmaric
- Escape constant string in generated schema (#1014) @mvdbeek
- Support fully-qualified refs as discriminator mapping values (#1017) @sgrimm
- Improve behavior of allOf + required properties (#1027) @Swiftwork
- Make params non-nullable even if all params are optional (#1022) @sgrimm
- Adds
webhooktypings by @yacinehmito (#1001) - Use undici’s
fetch()instead ofrequest()which can be overridden locally by @yacinehmito (#1002) - Adds type helpers only when used by @imagoiq (#992)
- Fixes bug in glob output by @BTMPL (#999)
- Fixes header casing by @HiiiiD (#990)
- Fixed multiple causes of bug #988 “cannot read properties of undefined” by @HiiiiD and @yacinehmito (#990 and #1002)
- Fixed
nullable: true(#983) - Fixed
additionalPropertiesbug (#983)
- Fixes #975 where
#/components/exampleswere being parsed as schema objects
- Remove
postinstallhook only meant for dev
- Dropped Prettier formatting and all formatting options. Now, simply format at your discretion (or not at all!)
- Dropped support for Swagger 2.0
- Dropped Node 14 support (it still works for now, but Node 14 bugs won’t be fixed if any arise)
--versionwas changed to return the version of this library (also by dropping Swagger 2.0 support the old usage was no longer needed)- Dropped
--raw-schema. Your entry schema MUST be valid and complete (however, your $refs to subschemas may be partials). - Dropped
--make-paths-enumbecause it was incompatible with--path-params-as-types - Dropped the CLI aliases
-itand-ap(specify the full --immutable-typesor--additional-propertiesflag) - Empty content:
{}now returnsnever. Dropped the--content-neverflag as this is now the default behavior. - Renamed and upgraded the Node API’s
formatter()function totransform()andpostTransform(). It’s an overall improvement on the original concept with even more power than before.
- Sped up type generation by 3× by dropping Prettier & optimizing deep-object crawl speed
- OpenAPI 3.1 support for
discriminatorand polymorphic types - Complete codebase rewrite and cleanup
- Now ships modern ESNext code rather than ES2018
- Improved internal types & documentation
- Test cleanup, now powered by Vitest
- New
transform()andpostTransform()hooks give you more control in overriding/extending generated types
- More accurate types for
oneOf/anyOf/allOf(#894) --immutable-typeshas a new-talias- Addition of path.default types
- Support
nullableas type arrays for OpenAPI 3.1 (#898)
- Fixed multiple bugs with deep-linked remote schemas and complex
$refs - Fixed
anyOfintersections resulting in unexpected type signatures - Fixed
[string, null]generating asunknown - Fixed
{ property: unknown; }withallOfunion - Fixed
requestBodymissingcontentproperty - Fixed headers missing remote
$refs
- New
--content-neverflag forces never response body by @duncanbeevers (#905)
- Empty strings are now allowed for properties like
@defaultby @duncanbeevers (#906) - Throws friendlier error on bad
--prettier-configpath by @duncanbeevers (#909) - Objects are now allowed for properties like
@defaultby @duncanbeevers (#910) - Fixes
enumexport of operation paths by @duncanbeevers (#912)
- New
--make-paths-enumCLI flag by @berzi (#883) - New
--path-params-as-typesCLI flag by @Powell-v2 (#891) - Supports
/** @constant */JSDoc comments by @PhilipTrauner (#896) - You can now add your own custom comment header at the top of every generated doc (#904)
- Fixes inconsistent comment title (#904)
- The
--export-typeflag was added to generate type instead of interface by @dominikdosoudil (#868) - Updated schemas & examples
- Tiny optimizations for a little speed boost (#881)
- Fixes CommonJS error for undici on older versions of Node (#879)
- Removes CJS version from npm (to use CJS, use
openapi-typescript@4). Version 5 switched to ESM as default anyway, and since tests are now testing ESM, the reliability of CJS was dubious (and there were TypeScript problems as well) - Fixes type error when using TypeScript nightly (#847)
- Patches security vulnerability with node-fetch (by replacing with undici)
- Adds constants support by @sadfsdfdsa (#831)
- Fixes a syntax error caused by an empty
oneOfby @sadfsdfdsa (#830)
- Adds missing types for CJS build (#861)
- 5.x drops support for Node 12. If you’re still on Node 12, be sure to lock your version to 4.x.
- Updates this library to full ESM! ✨ This is the future of JavaScript, and is now natively supported in Node 14+.
- Now supports a
URL()as input to make ESM usage easier (see example)
- Significantly-enhanced JSDoc output by @sadfsdfdsa (#797)
- Adds TypeScript
@deprecatedcomment to deprecated schema objects by @bunkscene
- In many areas, changed out
anywithunknown(#769). See #554 for more explanation / context
- An old bug is now gone! openapi-typescript would incorrectly generate
{ [key: string]: unknown }for a type when it may have been astringornumber. Now it will generate a more genericunknowntype, unless it knows it’s dealing with an object for sure.
- Reference arbitrary data on generated types via the
propertieskey by @Peteck (#626)
- Fixes the remote schema URL cache being too long-lived by @mbelsky (#708)
- New
--headersObjectand--headersCLI flags by @ericzorn93 (#764)
"type": "file"no longer generates unexpected results (#766)
- Loading in-memory schemas through the JS API resulted in broken
$refs (#689)
- Fixes
properties+anyOfwith onlyrequiredproperties by @gr2m (#643)
- The Node.js API now returns a promise, and can no longer be run synchronously (a necessity because resolving remote schemas can never be synchronous). Other than that, there are no other breaking changes. CLI users are unaffected, and the types generated are backwards-compatible with previous versions.
- Now supports remote references (
$ref: "remote.yaml#/components/schemas/User) 🎉 (#602)!
- Fix glob accidentally generating empty folders alongside single-file schemas (#633)
- Adds glob support thanks to @sharmarajdaksh (#615)
- Reverts #613 and adds a
--default-non-nullableflag (#631)
- Schema objects that have a
default:property shouldn’t be marked as nullable (#613)
- Changes default behavior of #585 to require an opt-in
--additional-propertiesflag (#607) - Adds
-cshortcut alias for--prettier-config(#607) - Adds
-itshortcut alias for--immutable-types(#607)
additionalPropertiesnow default totrueper the OpenAPI 3.0 spec by @mehalter (#583)
- Fixed a parse error on
enum: [](#563) - Fixed another parse error on responses missing schemas (#565)
- Fixed a bug with the latest version of Prettier and
options.prettierConfig(#566)
- RequestBodies that had hyphens in their name would generate an error (#550). Thanks (again), @ashsmith!
- Fixed an issue where a comment within a schema definition would break type gen (#548). Thanks, @ashsmith!
- Added a new
--immutable-typesflag by @dnalborczyk (#522)
- The
operationsinterface inherits parameters properly by @henhal (#530)
- Fixes package types for TypeScript projects (#520)
- Better handles remote schema content types (#516)
- Remote schema loading now follows redirects (#510)
- New
--authflag to access private schemas (#508) - npm version now ships with ESM package exports for better interop between ESM & CommonJS (#509)
- Fixes an OpenAPI V2 parameter bug by @yamacent (#489)
- If using OpenAPI 2.0, and you didn’t have
definitions, an unexpected error was encountered. This is now fixed.
- Improves handling of complex
oneOfby @gr2m (#491)
- Fixed generation bug where responseBodies that contained both a
$refandoperationIdgenerated invalid TypeScript (#464)
- This is marked as a breaking version for safety. Swagger v2 users should be able to migrate to
3.0.0with no problems; OpenAPI v3 users will either experience no changes or minor changes that should be an overall improvement.
- Adds long-requested paths support to Swagger v2 schemas
- Adds more compact comments, resulting more readable generated types
- Fixes bugs in paths generation (missing $refs support in areas, inconsistent generation)
- Comments can now be single-line, saving some needed space in the specs (#443)
additionalProperties.oneOfis now generating as expected (#442)
- Fixes
paths.requestBody.contentpossibly missing by @robertmassaioli (#369) - Fix: check if path item is method operation by @rendall (#366)
- escape quotes in enum string values by @gr2m (#365)
- Add
operationsinterface by @gr2m (#353)
- Allow
$ref: 'foo.yaml#bar'syntax, but cast toanytype (TODO: full external schema support) (#354)
$refsin paths now respect optional parameters (#352) by @gr2m
- Handle parameters on paths as well as methods by @samdbmg (#347)
- Set index type to all possible values (#348)
requestBodyand$ref-type parameters added in response types by @gr2m
🐣 Minor Changes
- responses without content schemas changed from
anytoneverorunknownby @gr2m
- New name! Now published at
openapi-typescript. - Added paths support (#328)
- Support for components.responses (#258)
- Adds tuple support (#293)
- Fix missing port bug (#252)
- additionalProperties interpolation, primitive enums (#266)
- bubble up the error message / improve error message when failing to parse the schema (#269)
- Improve error message when server is unreachable (#288)
- OpenAPI 3.0 support (#223)
- Schema names are no longer transformed (e.g.
UserRoleis nowdefinitions['user']['role']). See README for migration instructions. (#223) - Flags with “deprecated” warnings in
1.xwere dropped and no longer work (#223)
- Adds support for JSDoc comments (#223)
- Support for null values (#223)
- Improves Prettier config resolution (#224)
- Improves array and object handling (#226)
- Now handles the
@character in namespaces thanks to @sorin-davidoi 🎉 - Updates Prettier to
2.0
- Swagger v3 is no longer unsupported! 🎉 But it’s in beta. Which means errors will probably arise. Please test it out on your existing v3 schema, and file any bugs here.
- The
--swaggerflag is now deprecated; this library will automatically parse the version from the schema.
- Fixes a bug where
additionalPropertiesweren’t respected for nestedproperties(#92).
- Fixes an issue where
--camelcasewouldn’t camelCase$refs properly
- Fixes a bug where a definition with a missing
typewould be skipped, rather than assume it’s anobjectlike Swagger does by default.
- Adds Property mapper function (see README) that supports
x-nullableand other properties by @atlefren (#118)
- Convert names containing spaces to use underscores (#75) thanks to @svnv
- Puts out JSDoc thanks to @lbenie
- Fix nested arrays (#54)
- The
--nowrapperflag was added to the CLI, courtesy of @scvnathan (#33). Now you don’t have to wrap your interfaces if you don’t want to!
- This fixes underscores from accidentally appearing in some TypeScript interface names (#29)
- Swagger properties in
kebab-casewould break generation unless they were converted to--camelcase(#13). This has been fixed! 🎉 You still have the option of converting to--camelcase, but now you can keepkebab-casetoo if needed
- Adds
--wrapperoption, letting you specify any namespace or module wrapper for exporting types. See the README for full description
--namespaceand--exportoptions are now deprecated, in favor of the more versatile--wrapper
- Now supports an
--exportoption to export namespaces thanks to @tpdewolf
- No longer generates empty interfaces (caused by top-level definitions being array types, referencing other definitions)
- Improves enum generation to be simpler-to-use (values are now just hardcoded inline, rather than trying to use TypeScript enums).
- Changes default behavior to preserve
snake_caseproperties (you can still convert with--camelcase)
- Bundles & ships with @pika/pack
- Falls back to
objectif it can’t grab properties
- Different API, now requires
namespaceas 2nd parameter. Because namespacing is good.
- Maybe a bug; maybe not—if a Swagger spec had a common name like
Errorit would break your build if another type extended from it
- Fixes bug where number enums names could be generated.
- Supports TypeScript enums
- Exists