Skip to content

Commit

Permalink
Merge pull request #1008 from hey-api/fix/legacy-clients-name
Browse files Browse the repository at this point in the history
feat: rename legacy clients with 'legacy/' prefix
  • Loading branch information
mrlubos authored Sep 4, 2024
2 parents cb56eb0 + dc4a40d commit 820d0de
Show file tree
Hide file tree
Showing 54 changed files with 184 additions and 125 deletions.
5 changes: 5 additions & 0 deletions .changeset/mean-needles-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/openapi-ts': minor
---

feat: rename legacy clients with 'legacy/' prefix
2 changes: 1 addition & 1 deletion docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Hey API's objective is to provide a suite of TypeScript tools to manage API inte
Typically, developers of such applications want to:

- use TypeScript interfaces to model data for their APIs
- send and fetch this data from server in a typesafe way
- send and fetch this data from server in a type-safe way
- build further abstractions on top of this data

Doing any of these steps manually quickly becomes a huge time sink as your project grows and APIs evolve. Ideally, you want to spend most time on your application. Hey API allows you to do just that.
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout: home

hero:
name: High-quality tools for interacting with APIs
tagline: Abstractions for your TypeScript code. Automate type generation and typesafe data fetching.
tagline: Abstractions for your TypeScript code. Automate type generation and type-safe data fetching.
actions:
- theme: brand
text: Get Started
Expand All @@ -28,7 +28,7 @@ features:
linkText: Learn more
- icon: 🦴
title: Data Fetching
details: Typesafe data with our REST clients. Fetch, Axios, Angular, Node, and XHR are available.
details: Type-safe data with our REST clients. Fetch, Axios, Angular, Node, and XHR are available.
link: /openapi-ts/clients
linkText: See all clients
- icon: <svg class="icon-json-schema xmlns="http://www.w3.org/2000/svg" viewBox="0 0 70.423 70.423" height="24" width="24"><g fill="#fff"><path d="M122.994 114.19c-4.329-.94-7.58-3.479-8.712-6.801-.79-2.316-.677-6.072.333-11.15.485-2.439.882-5.349.882-6.467-.001-3.718-1.712-5.736-5.1-6.017l-1.955-.162v-4.785l1.852-.251c2.702-.366 3.744-1.029 4.576-2.91.611-1.38.689-2.068.505-4.472-.119-1.562-.535-4.349-.924-6.192-.99-4.683-.949-8.485.117-10.773 1.568-3.369 5.437-5.855 9.932-6.383l1.933-.227v5.036h-1.3c-1.771 0-4.25 1.262-4.883 2.488-.608 1.176-.654 2.864-.158 5.802.783 4.644 1.047 9.099.676 11.422-.425 2.658-1.975 5.796-3.68 7.448l-1.18 1.144 1.615 1.983c1.99 2.443 2.765 4.148 3.243 7.142.378 2.369.085 7.283-.67 11.214-1.054 5.485.162 7.652 4.661 8.306l1.676.244v2.448c0 2.792.171 2.697-3.439 1.913z" style="stroke-width:.35277775" transform="translate(-104.228 -45.508)"/><path d="M152.23 112.25v-2.43l2.05-.424c2.263-.467 4.054-1.863 4.459-3.475.127-.507-.113-3.164-.534-5.903-1.372-8.93-.611-13.537 2.855-17.297l1.482-1.608-1.11-1.266c-3.98-4.53-4.67-8.552-3.154-18.37.763-4.945.764-4.993.087-6.173-.797-1.388-3.284-2.776-4.975-2.776h-1.16v-2.47c0-2.81-.058-2.773 3.246-2.072 3.965.841 6.805 2.853 8.278 5.865.846 1.728.973 2.4.95 5.01-.016 1.66-.358 4.683-.762 6.72-1.499 7.564-1.365 9.576.765 11.533.99.908 1.64 1.173 3.37 1.368l2.145.243v4.848h-1.676c-2.151.001-3.932.91-4.838 2.47-.952 1.637-.893 5.206.173 10.406.907 4.422 1.053 8.459.389 10.729-.701 2.394-3.82 5.296-6.748 6.277-1.261.423-2.968.871-3.792.996l-1.5.228z" style="stroke-width:.35277778" transform="translate(-104.228 -45.508)"/><path d="M131.742 108.266c-1.021-1.299-.873-3.537.381-5.732.928-1.624 4.809-6.948 7.61-10.44l1.132-1.41-1.802-5.226c-2.022-5.86-2.01-5.974.656-6.372l1.468-.219 1.64 3.35c.903 1.843 1.77 3.351 1.928 3.351.158 0 1.775-1.755 3.594-3.9 3.16-3.727 3.357-3.892 4.426-3.694.645.12 1.218.047 1.354-.173.318-.515 1.23.247 1.23 1.027 0 .32-.453 1.134-1.009 1.81-2.267 2.755-7.104 9.27-7.104 9.57 0 .177.975 2.454 2.167 5.059l2.166 4.736-.658.985c-.362.541-.662 1.126-.667 1.299-.005.173-.278.483-.606.69-.832.525-1.447-.115-3.99-4.153-1.164-1.848-2.231-3.365-2.372-3.37-.313-.01-3.79 5.133-6.48 9.581-2.37 3.924-1.938 3.42-3.265 3.801-.956.274-1.194.199-1.799-.57zM131.986 83.677c-2.152-3.847-6.019-9.428-7.579-10.938-.792-.767-1.44-1.575-1.44-1.796 0-.601 1.616-1.22 3.19-1.22 1.698 0 3.496 1.479 5.1 4.193.582.985 1.156 1.794 1.276 1.798.12.004.809-1.651 1.53-3.678 1.547-4.34 5.624-12.778 7.225-14.951 1.373-1.863 3.43-2.865 5.903-2.876 3.234-.013 3.243.13.205 3.297-4.636 4.832-6.764 8.81-11.252 21.037-1.246 3.396-2.39 6.48-2.542 6.852-.23.566-.498.281-1.616-1.718z" style="stroke-width:.35277775" transform="translate(-104.228 -45.508)"/></g></svg>
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi-ts/clients.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ We all send HTTP requests in a slightly different way. Hey API doesn't force you
## Features

- seamless integration with `@hey-api/openapi-ts`
- typesafe response data and errors
- type-safe response data and errors
- access to the original request and response
- granular request and response customization options
- minimal learning curve thanks to extending the underlying technology
Expand Down
12 changes: 6 additions & 6 deletions docs/openapi-ts/clients/legacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,39 +15,39 @@ Before standalone client packages, clients were generated using `@hey-api/openap

```js [fetch]
export default {
client: 'fetch', // [!code ++]
client: 'legacy/fetch', // [!code ++]
input: 'path/to/openapi.json',
output: 'src/client',
};
```

```js [axios]
export default {
client: 'axios', // [!code ++]
client: 'legacy/axios', // [!code ++]
input: 'path/to/openapi.json',
output: 'src/client',
};
```

```js [angular]
export default {
client: 'angular', // [!code ++]
client: 'legacy/angular', // [!code ++]
input: 'path/to/openapi.json',
output: 'src/client',
};
```

```js [node]
export default {
client: 'node', // [!code ++]
client: 'legacy/node', // [!code ++]
input: 'path/to/openapi.json',
output: 'src/client',
};
```

```js [xhr]
export default {
client: 'xhr', // [!code ++]
client: 'legacy/xhr', // [!code ++]
input: 'path/to/openapi.json',
output: 'src/client',
};
Expand All @@ -67,7 +67,7 @@ export default {

Please be aware that legacy clients are missing some key features:

- no typesafe errors 🚫
- no type-safe errors 🚫
- no access to the original request and response 🚫
- hard to configure individual requests 👎
- inconsistent interceptors and response APIs 👎
Expand Down
4 changes: 2 additions & 2 deletions docs/openapi-ts/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ import { defineConfig } from '@hey-api/openapi-ts';
export default defineConfig([
{
client: 'fetch',
client: 'legacy/fetch',
input: 'path/to/openapi_one.json',
output: 'src/client_one',
},
{
client: 'axios',
client: 'legacy/axios',
input: 'path/to/openapi_two.json',
output: 'src/client_two',
},
Expand Down
55 changes: 55 additions & 0 deletions docs/openapi-ts/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,61 @@ This config option is deprecated and will be removed in favor of [clients](./cli

This config option is deprecated and will be removed.

## v0.53.0

### Renamed legacy clients

Legacy clients were renamed to signal they are deprecated more clearly. To continue using legacy clients, you will need to update your configuration and prefix them with `legacy/`.

::: code-group

```js [fetch]
export default {
client: 'fetch', // [!code --]
client: 'legacy/fetch', // [!code ++]
input: 'path/to/openapi.json',
output: 'src/client',
};
```

```js [axios]
export default {
client: 'axios', // [!code --]
client: 'legacy/axios', // [!code ++]
input: 'path/to/openapi.json',
output: 'src/client',
};
```

```js [angular]
export default {
client: 'angular', // [!code --]
client: 'legacy/angular', // [!code ++]
input: 'path/to/openapi.json',
output: 'src/client',
};
```

```js [node]
export default {
client: 'node', // [!code --]
client: 'legacy/node', // [!code ++]
input: 'path/to/openapi.json',
output: 'src/client',
};
```

```js [xhr]
export default {
client: 'xhr', // [!code --]
client: 'legacy/xhr', // [!code ++]
input: 'path/to/openapi.json',
output: 'src/client',
};
```

:::

## v0.52.0

### Removed internal `client` export
Expand Down
4 changes: 2 additions & 2 deletions packages/client-axios/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<img width="150" height="150" src="https://heyapi.vercel.app/logo.png" alt="Logo">
<h1 align="center"><b>Axios Client</b></h1>
<p align="center">🚀 Typesafe Axios client for your Hey API types.</p>
<p align="center">🚀 Type-safe Axios client for your Hey API types.</p>
</div>

Plug and play Axios wrapper for `@hey-api/openapi-ts` generator.
Expand All @@ -11,7 +11,7 @@ Plug and play Axios wrapper for `@hey-api/openapi-ts` generator.
## Features

- seamless integration with `@hey-api/openapi-ts`
- typesafe response data and errors
- type-safe response data and errors
- access to the original request and response
- granular request and response customization options
- minimal learning curve thanks to extending the underlying technology
Expand Down
2 changes: 1 addition & 1 deletion packages/client-axios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@hey-api/client-axios",
"version": "0.2.3",
"type": "module",
"description": "Typesafe Axios client for your @hey-api/openapi-ts types",
"description": "Type-safe Axios client for your @hey-api/openapi-ts types",
"homepage": "https://heyapi.vercel.app/",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/client-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.1",
"private": true,
"type": "module",
"description": "Core utilities for typesafe @hey-api/openapi-ts clients",
"description": "Core utilities for type-safe @hey-api/openapi-ts clients",
"homepage": "https://heyapi.vercel.app/",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions packages/client-fetch/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<img width="150" height="150" src="https://heyapi.vercel.app/logo.png" alt="Logo">
<h1 align="center"><b>Fetch API Client</b></h1>
<p align="center">🚀 Typesafe Fetch API client for your Hey API types.</p>
<p align="center">🚀 Type-safe Fetch API client for your Hey API types.</p>
</div>

Plug and play Fetch API wrapper for `@hey-api/openapi-ts` generator.
Expand All @@ -11,7 +11,7 @@ Plug and play Fetch API wrapper for `@hey-api/openapi-ts` generator.
## Features

- seamless integration with `@hey-api/openapi-ts`
- typesafe response data and errors
- type-safe response data and errors
- access to the original request and response
- granular request and response customization options
- minimal learning curve thanks to extending the underlying technology
Expand Down
2 changes: 1 addition & 1 deletion packages/client-fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@hey-api/client-fetch",
"version": "0.2.4",
"type": "module",
"description": "Typesafe Fetch API client for your @hey-api/openapi-ts types",
"description": "Type-safe Fetch API client for your @hey-api/openapi-ts types",
"homepage": "https://heyapi.vercel.app/",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-ts/bin/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const params = program
)
.option(
'-c, --client <value>',
'HTTP client to generate [angular, axios, fetch, node, xhr]',
'HTTP client to generate [@hey-api/client-axios, @hey-api/client-fetch, legacy/angular, legacy/axios, legacy/fetch, legacy/node, legacy/xhr]',
)
.option('-d, --debug', 'Run in debug mode?')
.option('--dry-run [value]', 'Skip writing files to disk?')
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-ts/src/generate/__tests__/class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('generateClientClass', () => {
it('writes to filesystem', async () => {
setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down
6 changes: 3 additions & 3 deletions packages/openapi-ts/src/generate/__tests__/core.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('generateCore', () => {

setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('generateCore', () => {

const config = setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down Expand Up @@ -132,7 +132,7 @@ describe('generateCore', () => {
const config = setConfig({
base: 'foo',
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-ts/src/generate/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('generateIndexFile', () => {
it('writes to filesystem', async () => {
setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-ts/src/generate/__tests__/output.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('generateOutput', () => {
it('writes to filesystem', async () => {
setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-ts/src/generate/__tests__/schemas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('generateSchemas', () => {
it('writes to filesystem', async () => {
setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down
8 changes: 4 additions & 4 deletions packages/openapi-ts/src/generate/__tests__/services.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('generateServices', () => {
it('writes to filesystem', async () => {
setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down Expand Up @@ -136,7 +136,7 @@ describe('methodNameBuilder', () => {
it('use default name', async () => {
setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down Expand Up @@ -179,7 +179,7 @@ describe('methodNameBuilder', () => {

setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down Expand Up @@ -225,7 +225,7 @@ describe('methodNameBuilder', () => {

setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-ts/src/generate/__tests__/types.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('generateTypes', () => {
it('writes to filesystem', async () => {
setConfig({
client: {
name: 'fetch',
name: 'legacy/fetch',
},
configFile: '',
debug: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-ts/src/generate/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const generateCore = async (
...context,
}),
);
if (config.client.name !== 'angular') {
if (config.client.name !== 'legacy/angular') {
await writeFileSync(
path.resolve(outputPath, 'CancelablePromise.ts'),
templates.core.cancelablePromise({
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-ts/src/generate/indexFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const generateIndexFile = async ({
}),
);
}
if (config.client.name !== 'angular') {
if (config.client.name !== 'legacy/angular') {
files.index.add(
compiler.exportNamedDeclaration({
exports: ['CancelablePromise', 'CancelError'],
Expand Down
Loading

0 comments on commit 820d0de

Please sign in to comment.