Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add migration notes #306

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lazy-elephants-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"openapi-ts-docs": patch
---

docs: add migration notes
4 changes: 4 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ features:

Please read our [migration guide](/openapi-ts/migrating#openapi-typescript-codegen).

### Sponsors and Partners

Interested in partnership or sponsoring Hey API? [Send us an email](mailto:[email protected])

<style>
:root {
--vp-home-hero-name-color: transparent;
Expand Down
11 changes: 6 additions & 5 deletions docs/openapi-ts/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ description: Get started with @hey-api/openapi-ts.

# Get Started

`openapi-ts` allows you to create TypeScript interfaces, REST clients, and schemas from an OpenAPI specification.
`openapi-ts` allows you to create TypeScript interfaces, REST clients, and JSON Schemas from an OpenAPI specification.

## Features

- generate TypeScript interfaces from OpenAPI v2.0, v3.0, and v3.1 specifications
- use with CLI, Node.js, or npx
- export TypeScript interfaces from OpenAPI v2.0, v3.0, and v3.1 specifications
- support JSON or YAML input files
- handle external references using [JSON Schema $Ref Parser](https://github.com/APIDevTools/json-schema-ref-parser/)
- generate fetch, axios, angular, node.js, or xhr REST clients
- usable with CLI, Node.js, or npx
- support external references using [json-schema-ref-parser](https://github.com/APIDevTools/json-schema-ref-parser/)
- create fetch, axios, angular, node.js, or xhr REST clients
- export JSON Schemas from OpenAPI specifications
- abortable requests through cancellable promise pattern

## Quick Start
Expand Down
111 changes: 99 additions & 12 deletions docs/openapi-ts/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,65 @@ description: Migrating to @hey-api/openapi-ts.

# Migrating

While we try to avoid breaking changes, sometimes it's unavoidable in order to offer you the latest features.
While we try to avoid breaking changes, sometimes it's unavoidable in order to offer you the latest features. This page lists changes that require updates to your code.

## @next

These changes haven't been released yet. However, you can migrate your code today to save time on migration once they're released.

### Deprecated `useOptions`

This config option is deprecated and will be removed.

### Deprecated `postfixServices`

This config option is deprecated and will be removed.

### Deprecated `request`

This config option is deprecated and will be removed.

### Deprecated `name`

This config option is deprecated and will be removed.

## v0.36.0

### JSON Schema 2020-12

Schemas are exported directly from OpenAPI specification. This means your schemas might change depending on which OpenAPI version you're using. If this release caused a field to be removed, consult the JSON Schema documentation on how to obtain the same value from JSON Schema (eg. [required properties](https://json-schema.org/understanding-json-schema/reference/object#required)).

### Renamed `exportSchemas`

This config option is now called `schemas`.

## v0.35.0

### Removed `postfixModels`

This config option has been removed.

## v0.34.0

### Single `services.ts` file

Services are now exported from a single file. If you used imports from individual service files, these will need to be updated to refer to the single `services.ts` file.

## v0.31.1

### Merged enums options

`useLegacyEnums` config option is now `enums: 'typescript'` and existing `enums: true` option is now `enums: 'javascript'`.

## v0.31.0

### Single `models.ts` file

TypeScript interfaces are now exported from a single file. If you used imports from individual model files, these will need to be updated to refer to the single `models.ts` file.

### Single `schemas.ts` file

Schemas are now exported from a single file. If you used imports from individual schema files, these will need to be updated to refer to the single `schemas.ts` file.

## v0.27.38

Expand All @@ -21,24 +79,53 @@ import { DefaultService } from 'client_v2' // <-- new client with options argume

This way, you can gradually switch over to the new syntax as you update parts of your code. Once you've removed all instances of `client` imports, you can safely delete the old `client` folder and find and replace all `client_v2` calls to `client`.

## v0.27.36

### `exportSchemas: true`

By default, we will create schemas from your OpenAPI specification. Use `exportSchemas: false` to preserve the old behavior.

## v0.27.32

### Renamed `Config` interface

This interface is now called `UserConfig`.

## v0.27.29

### Renamed `openapi` CLI command

This command is now called `openapi-ts`.

## v0.27.26

### Removed `indent`

This config option has been removed. Use a [code formatter](/openapi-ts/configuration#formatting) to modify the generated files code style according to your preferences.

## v0.27.24

### Removed `useUnionTypes`

This config option has been removed. Generated types will behave the same as `useUnionTypes: true` before.

## OpenAPI TypeScript Codegen

`openapi-ts` was originally forked from Ferdi Koomen's [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen). At first, we only added support for OpenAPI v3.1, but we've changed more things since. As of v0.34.5, our APIs are similar, so migrating should be relatively straightforward. If you run into an issue with migration, please [open an issue](https://github.com/hey-api/openapi-ts/issues).
`openapi-ts` was originally forked from Ferdi Koomen's [openapi-typescript-codegen](https://github.com/ferdikoomen/openapi-typescript-codegen). Therefore, we want you to be able to migrate your openapi-typescript-codegen projects. Migration should be relatively straightforward if you follow the release notes on this page. If you run into an issue with migration, please [open an issue](https://github.com/hey-api/openapi-ts/issues).

### Changes
### Changed

- `exportSchemas` is `true` by default (set `exportSchemas` to `false` to preserve the old behavior, in v0.36.0 this has been renamed to `schemas`)
- `client` is optional (old behavior preserved, but can be most likely removed)
- `exportSchemas` is `true` by default (see [v0.27.36](#v0-27-36))
- `useOptions` is `true` by default (see [v0.27.38](#v0-27-38))

### Removed

- `useUnionTypes` has been removed (`openapi-ts` works the same as `useUnionTypes: true` before)
- `indent` has been removed (use [code formatter](/openapi-ts/configuration#formatting) to style output)
- `postfixModels` has been removed (open an [issue](https://github.com/hey-api/openapi-ts/issues) if you have a critical use case)
- `useUnionTypes` has been removed (see [v0.27.24](#v0-27-24))
- `indent` has been removed (see [v0.27.26](#v0-27-26))
- `postfixModels` has been removed (see [v0.35.0](#v0-35-0))

### Deprecated

- `useOptions: false` is deprecated and `true` by default (see [v0.27.38](#v0-27-38))
- `postfixServices` is deprecated and will be removed in future releases
- `request` will be deprecated and removed in future releases
- `name` will be deprecated and removed in future releases
- `postfixServices` is deprecated (see [@next](#next))
- `request` is deprecated (see [@next](#next))
- `name` is deprecated (see [@next](#next))