Skip to content

Commit

Permalink
fix: rename Hey API plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Nov 22, 2024
1 parent 00417a7 commit d9dc33d
Show file tree
Hide file tree
Showing 279 changed files with 602 additions and 596 deletions.
13 changes: 13 additions & 0 deletions .changeset/fast-fishes-compare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@hey-api/openapi-ts': minor
---

feat: rename Hey API plugins

### Renamed `@hey-api/services` plugin

This plugin has been renamed to `@hey-api/sdk`.

### Renamed `@hey-api/types` plugin

This plugin has been renamed to `@hey-api/typescript`.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<p align="center">🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.</p>
</div>

[Live demo](https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fservices.gen.ts,src%2Fclient%2Ftypes.gen.ts)
[Live demo](https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts)

## Features

- works with CLI, Node.js 18+, or npx
- supports OpenAPI 2.0, 3.0, and 3.1 specifications
- supports both JSON and YAML input files
- generates TypeScript interfaces, REST clients, and JSON Schemas
- generates TypeScript interfaces, SDKs, and JSON Schemas
- Fetch API, Axios, Angular, Node.js, and XHR clients available
- plugin ecosystem to reduce third-party boilerplate

Expand Down
6 changes: 3 additions & 3 deletions docs/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ export const embedProject = (projectId: string) => async (event: Event) => {
return await sdk.embedProjectId(container, projectId, {
height: 700,
openFile:
'openapi-ts.config.ts,src/client/schemas.gen.ts,src/client/services.gen.ts,src/client/types.gen.ts,src/App.tsx',
'openapi-ts.config.ts,src/client/schemas.gen.ts,src/client/sdk.gen.ts,src/client/types.gen.ts,src/App.tsx',
view: 'editor',
});
case 'hey-api-client-fetch-example':
return await sdk.embedProjectId(container, projectId, {
height: 700,
openFile:
'openapi-ts.config.ts,src/client/schemas.gen.ts,src/client/services.gen.ts,src/client/types.gen.ts,src/App.tsx',
'openapi-ts.config.ts,src/client/schemas.gen.ts,src/client/sdk.gen.ts,src/client/types.gen.ts,src/App.tsx',
view: 'editor',
});
case 'hey-api-client-fetch-plugin-fastify-example':
Expand All @@ -49,7 +49,7 @@ export const embedProject = (projectId: string) => async (event: Event) => {
return await sdk.embedProjectId(container, projectId, {
height: 700,
openFile:
'openapi-ts.config.ts,src/client/schemas.gen.ts,src/client/services.gen.ts,src/client/types.gen.ts',
'openapi-ts.config.ts,src/client/schemas.gen.ts,src/client/sdk.gen.ts,src/client/types.gen.ts',
view: 'editor',
});
}
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ hero:
link: /openapi-ts/get-started
- theme: alt
text: View Demo
link: https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fservices.gen.ts,src%2Fclient%2Ftypes.gen.ts
link: https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts
image:
src: /logo.png
alt: logo
Expand Down
20 changes: 10 additions & 10 deletions docs/openapi-ts/clients/axios.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ You can now run `openapi-ts` to use the new Axios client. 🎉

## Configuration

If you're using services, you will want to configure the internal client instance. You can do that with the `setConfig()` method. Call it at the beginning of your application.
If you're using SDKs, you will want to configure the internal client instance. You can do that with the `setConfig()` method. Call it at the beginning of your application.

```js
import { client } from 'client/services.gen';
import { client } from 'client/sdk.gen';

client.setConfig({
baseURL: 'https://example.com',
});
```

If you aren't using services, you can create your own client instance.
If you aren't using SDKs, you can create your own client instance.

```js
import { createClient } from '@hey-api/client-axios';
Expand All @@ -84,7 +84,7 @@ Interceptors (middleware) can be used to modify requests before they're sent or
We expose the Axios instance through the `instance` field.

```js
import { client } from 'client/services.gen';
import { client } from 'client/sdk.gen';

client.instance.interceptors.request.use((config) => {
config.headers.set('Authorization', 'Bearer <my_token>');
Expand All @@ -94,14 +94,14 @@ client.instance.interceptors.request.use((config) => {

## Customization

Our Axios client is built as a thin wrapper on top of Axios, extending its functionality to work with Hey API. If you're already familiar with Axios, customizing your client will feel like working directly with Axios. You can customize requests in three ways – through services, per client, or per request.
Our Axios client is built as a thin wrapper on top of Axios, extending its functionality to work with Hey API. If you're already familiar with Axios, customizing your client will feel like working directly with Axios. You can customize requests in three ways – through SDKs, per client, or per request.

### Services
### SDKs

This is the most common requirement. Our generated services consume an internal Axios instance, so you will want to configure that.
This is the most common requirement. Our generated SDKs consume an internal Axios instance, so you will want to configure that.

```js
import { client } from 'client/services.gen';
import { client } from 'client/sdk.gen';

client.setConfig({
baseURL: 'https://example.com',
Expand All @@ -122,7 +122,7 @@ const myClient = createClient({
});
```

You can then pass this instance to any generated service through the `client` option. This will override the internal instance.
You can then pass this instance to any SDK function through the `client` option. This will override the internal instance.

```js
const response = await getFoo({
Expand All @@ -132,7 +132,7 @@ const response = await getFoo({

### Request

Alternatively, you can pass the Axios configuration options to each service call directly. This is useful if you don't want to create a separate client for one-off use cases.
Alternatively, you can pass the Axios configuration options to each SDK function. This is useful if you don't want to create a client instance for one-off use cases.

```js
const response = await getFoo({
Expand Down
26 changes: 13 additions & 13 deletions docs/openapi-ts/clients/fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ You can now run `openapi-ts` to use the new Fetch API client. 🎉

## Configuration

If you're using services, you will want to configure the internal client instance. You can do that with the `setConfig()` method. Call it at the beginning of your application.
If you're using SDKs, you will want to configure the internal client instance. You can do that with the `setConfig()` method. Call it at the beginning of your application.

```js
import { client } from 'client/services.gen';
import { client } from 'client/sdk.gen';

client.setConfig({
baseUrl: 'https://example.com',
});
```

If you aren't using services, you can create your own client instance.
If you aren't using SDKs, you can create your own client instance.

```js
import { createClient } from '@hey-api/client-fetch';
Expand All @@ -84,7 +84,7 @@ Interceptors (middleware) can be used to modify requests before they're sent or
::: code-group

```js [use]
import { client } from 'client/services.gen';
import { client } from 'client/sdk.gen';

client.interceptors.request.use((request, options) => {
request.headers.set('Authorization', 'Bearer <my_token>');
Expand All @@ -93,7 +93,7 @@ client.interceptors.request.use((request, options) => {
```

```js [eject]
import { client } from 'client/services.gen';
import { client } from 'client/sdk.gen';

client.interceptors.request.eject((request, options) => {
request.headers.set('Authorization', 'Bearer <my_token>');
Expand All @@ -108,7 +108,7 @@ and an example response interceptor
::: code-group

```js [use]
import { client } from 'client/services.gen';
import { client } from 'client/sdk.gen';

client.interceptors.response.use((response, request, options) => {
trackAnalytics(response);
Expand All @@ -117,7 +117,7 @@ client.interceptors.response.use((response, request, options) => {
```

```js [eject]
import { client } from 'client/services.gen';
import { client } from 'client/sdk.gen';

client.interceptors.response.eject((response, request, options) => {
trackAnalytics(response);
Expand All @@ -133,14 +133,14 @@ To eject, you must provide a reference to the function that was passed to `use()

## Customization

Our Fetch client is built as a thin wrapper on top of Fetch API, extending its functionality to work with Hey API. If you're already familiar with Fetch, customizing your client will feel like working directly with Fetch API. You can customize requests in three ways – through services, per client, or per request.
Our Fetch client is built as a thin wrapper on top of Fetch API, extending its functionality to work with Hey API. If you're already familiar with Fetch, customizing your client will feel like working directly with Fetch API. You can customize requests in three ways – through SDKs, per client, or per request.

### Services
### SDKs

This is the most common requirement. Our generated services consume an internal Fetch instance, so you will want to configure that.
This is the most common requirement. The generated SDKs consume an internal Fetch instance, so you will want to configure that.

```js
import { client } from 'client/services.gen';
import { client } from 'client/sdk.gen';

client.setConfig({
baseUrl: 'https://example.com',
Expand All @@ -161,7 +161,7 @@ const myClient = createClient({
});
```

You can then pass this instance to any generated service through the `client` option. This will override the internal instance.
You can then pass this instance to any SDK function through the `client` option. This will override the internal instance.

```js
const response = await getFoo({
Expand All @@ -171,7 +171,7 @@ const response = await getFoo({

### Request

Alternatively, you can pass the Fetch API configuration options to each service call directly. This is useful if you don't want to create a separate client for one-off use cases.
Alternatively, you can pass the Fetch API configuration options to each SDK function. This is useful if you don't want to create a client instance for one-off use cases.

```js
const response = await getFoo({
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 @@ -194,7 +194,7 @@ You can also prevent your output from being linted by adding your output path to

## Clients

Clients are responsible for sending the actual HTTP requests. The `client` value is not required, but you must define it if you're generating the service layer (enabled by default).
Clients are responsible for sending the actual HTTP requests. The `client` value is not required, but you must define it if you're generating SDKs (enabled by default).

You can learn more on the [Clients](/openapi-ts/clients) page.

Expand Down Expand Up @@ -225,7 +225,7 @@ export default defineConfig([

## Plugins

Plugins are responsible for generating artifacts from your input. By default, Hey API will generate TypeScript interfaces, JSON Schemas, and services from your OpenAPI specification. You can add, remove, or customize any of the plugins. In fact, we highly encourage you to do so!
Plugins are responsible for generating artifacts from your input. By default, Hey API will generate TypeScript interfaces, an SDK, and JSON Schemas from your OpenAPI specification. You can add, remove, or customize any of the plugins. In fact, we highly encourage you to do so!

You can learn more on the [Output](/openapi-ts/output) page.

Expand Down
2 changes: 1 addition & 1 deletion docs/openapi-ts/fastify.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ The Fastify plugin will generate the following artifacts, depending on the input

## Route Handlers

Route handlers are generated from all endpoints. The generated interface follows the naming convention of services.
Route handlers are generated from all endpoints. The generated interface follows the naming convention of SDK functions.

```ts
const fastify = Fastify();
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi-ts/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Live demo
- works with CLI, Node.js 18+, or npx
- supports OpenAPI 2.0, 3.0, and 3.1 specifications
- supports both JSON and YAML input files
- generates TypeScript interfaces, REST clients, and JSON Schemas
- generates TypeScript interfaces, SDKs, and JSON Schemas
- Fetch API, Axios, Angular, Node.js, and XHR clients available
- plugin ecosystem to reduce third-party boilerplate

Expand Down
2 changes: 1 addition & 1 deletion docs/openapi-ts/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Integrations allow you to automate your client generation workflow. Create depen

## Upload OpenAPI Spec

First, you need to configure your API services to send us OpenAPI specifications. This can be done by adding our [hey-api/upload-openapi-spec](https://github.com/marketplace/actions/upload-openapi-spec-by-hey-api) GitHub Action into your CI workflow.
First, you need to configure your API build workflow to send us OpenAPI specifications. This can be done by adding our [hey-api/upload-openapi-spec](https://github.com/marketplace/actions/upload-openapi-spec-by-hey-api) GitHub Action into your CI workflow.

```yaml
name: Upload OpenAPI Specification
Expand Down
33 changes: 10 additions & 23 deletions docs/openapi-ts/migrating.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,6 @@ While we try to avoid breaking changes, sometimes it's unavoidable in order to o

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

### Deprecated exports from `index.ts`

Currently, `index.ts` file exports all generated artifacts. We will be slowly moving away from this practice as it increases the chance of export conflicts.

```js
export { ApiError } from './core/ApiError';
export { CancelablePromise, CancelError } from './core/CancelablePromise';
export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI';
export * from './schemas.gen'; // [!code --]
export * from './services.gen'; // [!code --]
export * from './types.gen'; // [!code --]
```

Any non-core related imports should be imported as

```js
import { $Schema } from 'client/schemas.gen';
import { DefaultService } from 'client/services.gen';
import type { Model } from 'client/types.gen';
```

You don't have to update imports from `core` folder. These will be addressed in later releases.

### Deprecated `base`

This config option is deprecated and will be removed in favor of [clients](./clients).
Expand All @@ -50,6 +27,16 @@ This config option is deprecated and will be removed in favor of [clients](./cli

This config option is deprecated and will be removed.

## v0.57.0

### Renamed `@hey-api/services` plugin

This plugin has been renamed to `@hey-api/sdk`.

### Renamed `@hey-api/types` plugin

This plugin has been renamed to `@hey-api/typescript`.

## v0.56.0

### Deprecated `tree` in `@hey-api/types`
Expand Down
Loading

0 comments on commit d9dc33d

Please sign in to comment.