diff --git a/docs/.vitepress/config/en.ts b/docs/.vitepress/config/en.ts
index 689c33995c..48a67a4192 100644
--- a/docs/.vitepress/config/en.ts
+++ b/docs/.vitepress/config/en.ts
@@ -94,6 +94,10 @@ export default defineConfig({
link: '/openapi-ts/clients/fetch',
text: 'Fetch API',
},
+ {
+ link: '/openapi-ts/clients/angular',
+ text: 'Angular',
+ },
{
link: '/openapi-ts/clients/axios',
text: 'Axios',
@@ -106,10 +110,6 @@ export default defineConfig({
link: '/openapi-ts/clients/nuxt',
text: 'Nuxt',
},
- {
- link: '/openapi-ts/clients/angular',
- text: 'Angular',
- },
{
link: '/openapi-ts/clients/effect',
text: 'Effect soon ',
@@ -218,6 +218,10 @@ export default defineConfig({
{
collapsed: true,
items: [
+ {
+ link: '/openapi-ts/plugins/angular',
+ text: 'Angular',
+ },
{
link: '/openapi-ts/plugins/fastify',
text: 'Fastify',
diff --git a/docs/.vitepress/config/index.ts b/docs/.vitepress/config/index.ts
index 84261e5d8b..164d2221dd 100644
--- a/docs/.vitepress/config/index.ts
+++ b/docs/.vitepress/config/index.ts
@@ -1,3 +1,5 @@
+import path from 'node:path';
+
import { defineConfig } from 'vitepress';
import en from './en';
@@ -13,6 +15,12 @@ export default defineConfig({
...shared.vite,
resolve: {
...shared.vite?.resolve,
+ alias: {
+ ...shared.vite?.resolve?.alias,
+ '@components': path.resolve(__dirname, '..', 'theme', 'components'),
+ '@data': path.resolve(__dirname, '..', '..', 'data'),
+ '@versions': path.resolve(__dirname, '..', 'theme', 'versions'),
+ },
preserveSymlinks: true,
},
},
diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts
index 8b0195dbcc..37e486cc9f 100644
--- a/docs/.vitepress/theme/index.ts
+++ b/docs/.vitepress/theme/index.ts
@@ -5,21 +5,10 @@ import DefaultTheme from 'vitepress/theme';
// custom CSS must be imported after default theme to correctly apply styles
import './custom.css';
-import AuthorsList from './components/AuthorsList.vue';
-import FeatureStatus from './components/FeatureStatus.vue';
-import Heading from './components/Heading.vue';
-import VersionLabel from './components/VersionLabel.vue';
-import VersionSwitcher from './components/VersionSwitcher.vue';
import Layout from './Layout.vue';
export default {
Layout,
- enhanceApp: ({ app }) => {
- app.component('AuthorsList', AuthorsList);
- app.component('FeatureStatus', FeatureStatus);
- app.component('Heading', Heading);
- app.component('VersionLabel', VersionLabel);
- app.component('VersionSwitcher', VersionSwitcher);
- },
+ enhanceApp: () => {},
extends: DefaultTheme,
} satisfies Theme;
diff --git a/docs/.vitepress/theme/versions/AngularVersionSwitcher.vue b/docs/.vitepress/theme/versions/AngularVersionSwitcher.vue
new file mode 100644
index 0000000000..28f9d7fe8c
--- /dev/null
+++ b/docs/.vitepress/theme/versions/AngularVersionSwitcher.vue
@@ -0,0 +1,20 @@
+
+
+
+
+
diff --git a/docs/openapi-ts/plugins/zod/ZodHeading.vue b/docs/.vitepress/theme/versions/ZodVersionSwitcher.vue
similarity index 70%
rename from docs/openapi-ts/plugins/zod/ZodHeading.vue
rename to docs/.vitepress/theme/versions/ZodVersionSwitcher.vue
index 1efde228e5..1b6b0ede2e 100644
--- a/docs/openapi-ts/plugins/zod/ZodHeading.vue
+++ b/docs/.vitepress/theme/versions/ZodVersionSwitcher.vue
@@ -1,4 +1,6 @@
-
-
-
-
+
diff --git a/docs/data/people.ts b/docs/data/people.ts
new file mode 100644
index 0000000000..215f7f86d7
--- /dev/null
+++ b/docs/data/people.ts
@@ -0,0 +1,14 @@
+type Person = {
+ github: string;
+ name: string;
+};
+
+export const jacobCohen: Person = {
+ github: 'https://github.com/jacobinu',
+ name: 'Jacob Cohen',
+};
+
+export const maxScopp: Person = {
+ github: 'https://github.com/max-scopp',
+ name: 'Max Scopp',
+};
diff --git a/docs/openapi-ts/clients.md b/docs/openapi-ts/clients.md
index 385019d943..2d6944a719 100644
--- a/docs/openapi-ts/clients.md
+++ b/docs/openapi-ts/clients.md
@@ -26,10 +26,10 @@ We all send HTTP requests in a slightly different way. Hey API doesn't force you
Hey API natively supports the following clients.
- [Fetch API](/openapi-ts/clients/fetch)
+- [Angular](/openapi-ts/clients/angular)
- [Axios](/openapi-ts/clients/axios)
- [Next.js](/openapi-ts/clients/next-js)
- [Nuxt](/openapi-ts/clients/nuxt)
-- [Angular](/openapi-ts/clients/angular) Soon
- [Effect](/openapi-ts/clients/effect) Soon
- [Legacy](/openapi-ts/clients/legacy)
diff --git a/docs/openapi-ts/clients/angular.md b/docs/openapi-ts/clients/angular.md
index 8c05827728..1379a30041 100644
--- a/docs/openapi-ts/clients/angular.md
+++ b/docs/openapi-ts/clients/angular.md
@@ -1,58 +1,77 @@
---
-title: Angular client
-description: Angular client for Hey API. Compatible with all our features.
+title: Angular v20 Client
+description: Generate a type-safe Angular v20 client from OpenAPI with the Angular client for openapi-ts. Fully compatible with validators, transformers, and all core features.
---
Angular
-
-
+
+::: warning
+Angular client is currently in beta. The interface might change before it becomes stable. We encourage you to leave feedback on [GitHub](https://github.com/hey-api/openapi-ts/issues).
+:::
+
### About
-[Angular](https://angular.dev/) is a web framework for building fast, reliable applications.
+[Angular](https://angular.dev/) is a web framework that empowers developers to build fast, reliable applications.
-::: warning Requirements
-**Angular 19+** is required for full feature support, including the experimental `httpResource` API.
-:::
+The Angular client for Hey API generates a type-safe client from your OpenAPI spec, fully compatible with validators, transformers, and all core features.
-::: tip First Release
-Angular client support is in its first release. Share your feedback on [GitHub](https://github.com/hey-api/openapi-ts/issues).
-:::
+### Collaborators
+
+
## Features
-- Modern Angular patterns with signals and reactive programming
-- Dependency injection with `@Injectable()` decorators
-- Type-safe response data and errors
-- Experimental **httpResource** support (Angular 19+)
+- Angular v20 support
+- seamless integration with `@hey-api/openapi-ts` ecosystem
+- type-safe response data and errors
+- support for [`@Injectable()`](https://angular.dev/api/core/Injectable) decorators
+- response data validation and transformation
+- access to the original request and response
+- granular request and response customization options
+- minimal learning curve thanks to extending the underlying technology
+- support bundling inside the generated output
-## Usage
+## Installation
-Add `@hey-api/client-angular` to your plugins:
+In your [configuration](/openapi-ts/get-started), add `@hey-api/client-angular` to your plugins and you'll be ready to generate client artifacts. :tada:
-```js
+::: code-group
+
+```js [config]
export default {
input: 'https://get.heyapi.dev/hey-api/backend',
output: 'src/client',
- plugins: [
- '@hey-api/client-angular', // [!code ++]
- ],
+ plugins: ['@hey-api/client-angular'], // [!code ++]
};
```
-After generating the client, integrate it with Angular's `HttpClient` by adding `provideHeyApiClient` to your app configuration:
+```sh [cli]
+npx @hey-api/openapi-ts \
+ -i https://get.heyapi.dev/hey-api/backend \
+ -o src/client \
+ -c @hey-api/client-angular # [!code ++]
+```
+
+:::
+
+### Providers
+
+You can use the Angular client in your application by adding `provideHeyApiClient` to your providers.
```ts
-import { provideHttpClient, withFetch } from '@angular/common/http';
import { provideHeyApiClient, client } from './client/client.gen';
-export const appConfig = {
+export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(withFetch()),
provideHeyApiClient(client), // [!code ++]
@@ -62,46 +81,63 @@ export const appConfig = {
## Configuration
-### Injectable Classes Configuration
+The Angular client is built as a thin wrapper on top of Angular, extending its functionality to work with Hey API. If you're already familiar with Angular, configuring your client will feel like working directly with Angular.
+
+When we installed the client above, it created a [`client.gen.ts`](/openapi-ts/output#client) file. You will most likely want to configure the exported `client` instance. There are two ways to do that.
+
+### `setConfig()`
+
+This is the simpler approach. You can call the `setConfig()` method at the beginning of your application or anytime you need to update the client configuration. You can pass any `HttpRequest` configuration option to `setConfig()`, and even your own [`httpClient`](#custom-httpclient) implementation.
+
+```js
+import { client } from 'client/client.gen';
+
+client.setConfig({
+ baseUrl: 'https://example.com',
+});
+```
+
+The disadvantage of this approach is that your code may call the `client` instance before it's configured for the first time. Depending on your use case, you might need to use the second approach.
+
+### Runtime API
-You can configure the SDK to generate injectable classes by setting the `asClass` option to `true` in your plugin configuration. This will generate Angular services with `@Injectable()` decorators, making them available for dependency injection.
+Since `client.gen.ts` is a generated file, we can't directly modify it. Instead, we can tell our configuration to use a custom file implementing the Runtime API. We do that by specifying the `runtimeConfigPath` option.
```js
export default {
input: 'https://get.heyapi.dev/hey-api/backend',
output: 'src/client',
plugins: [
- '@hey-api/client-angular',
{
- name: '@hey-api/sdk',
- asClass: true, // [!code ++]
+ name: '@hey-api/client-angular',
+ runtimeConfigPath: './src/hey-api.ts', // [!code ++]
},
],
};
```
-::: warning
-While this feature is available, it is **discouraged** as it can negatively impact tree shaking, leading to larger bundle sizes. Consider using other configuration options for better optimization.
-:::
-
-### Angular Providers
+In our custom file, we need to export a `createClientConfig()` method. This function is a simple wrapper allowing us to override configuration values.
-Use `provideHeyApiClient` to integrate the generated client with Angular's `HttpClient`:
+::: code-group
-```ts
-import { provideHttpClient, withFetch } from '@angular/common/http';
-import { provideHeyApiClient, client } from './client/client.gen';
+```ts [hey-api.ts]
+import type { CreateClientConfig } from './client/client.gen';
-export const appConfig = {
- providers: [provideHttpClient(withFetch()), provideHeyApiClient(client)],
-};
+export const createClientConfig: CreateClientConfig = (config) => ({
+ ...config,
+ baseUrl: 'https://example.com',
+});
```
+:::
+
+With this approach, `client.gen.ts` will call `createClientConfig()` before initializing the `client` instance. If needed, you can still use `setConfig()` to update the client configuration later.
+
### `createClient()`
-Manually create a client instance for custom configurations:
+You can also create your own client instance. You can use it to manually send requests or point it to a different domain.
-```ts
+```js
import { createClient } from './client/client';
const myClient = createClient({
@@ -109,37 +145,113 @@ const myClient = createClient({
});
```
-## Plugin Configuration
+You can also pass this instance to any SDK function through the `client` option. This will override the default instance from `client.gen.ts`.
+
+```js
+const response = await getFoo({
+ client: myClient,
+});
+```
+
+### SDKs
-The `@hey-api/client-angular` plugin supports options like `throwOnError` for error handling:
+Alternatively, you can pass the client 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({
+ baseUrl: 'https://example.com', // <-- override default configuration
+});
+```
+
+## `@Injectable`
+
+If you prefer to use the [`@Injectable()`](https://angular.dev/api/core/Injectable) decorators, set the `asClass` option in your SDK plugin to `true`.
+
+::: code-group
+
+```ts [example]
+@Injectable({ providedIn: 'root' })
+export class FooService {
+ // class methods
+}
+```
+
+```js [config]
export default {
input: 'https://get.heyapi.dev/hey-api/backend',
output: 'src/client',
plugins: [
+ '@hey-api/client-angular',
{
- name: '@hey-api/client-angular',
- throwOnError: false,
+ name: '@hey-api/sdk',
+ asClass: true, // [!code ++]
},
],
};
```
-## httpResource
+:::
-Angular 19 introduces a experimental api – `httpResource`, a reactive approach to data loading. Enable it with:
+## Interceptors
-```js
-export default {
- plugins: [
- {
- name: '@angular/common',
- httpResource: {
- enabled: true,
- asClass: true,
- },
- },
- ],
+::: warning
+This section is under construction. We appreciate your patience.
+:::
+
+## Auth
+
+::: warning
+This section is under construction. We appreciate your patience.
+:::
+
+## Build URL
+
+If you need to access the compiled URL, you can use the `buildUrl()` method. It's loosely typed by default to accept almost any value; in practice, you will want to pass a type hint.
+
+```ts
+type FooData = {
+ path: {
+ fooId: number;
+ };
+ query?: {
+ bar?: string;
+ };
+ url: '/foo/{fooId}';
};
+
+const url = client.buildUrl({
+ path: {
+ fooId: 1,
+ },
+ query: {
+ bar: 'baz',
+ },
+ url: '/foo/{fooId}',
+});
+console.log(url); // prints '/foo/1?bar=baz'
```
+
+## Custom `httpClient`
+
+You can implement your own `httpClient`. This is useful if you need to extend the default `httpClient` methods with extra functionality, or replace it altogether.
+
+```js
+import { client } from 'client/client.gen';
+
+client.setConfig({
+ httpClient: inject(CustomHttpClient),
+});
+```
+
+You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom client to be.
+
+## Plugins
+
+You might be also interested in the [Angular](/openapi-ts/plugins/angular) plugin.
+
+## API
+
+You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-angular/types.d.ts) interface.
+
+
+
diff --git a/docs/openapi-ts/clients/angular/v19.md b/docs/openapi-ts/clients/angular/v19.md
new file mode 100644
index 0000000000..07cabac479
--- /dev/null
+++ b/docs/openapi-ts/clients/angular/v19.md
@@ -0,0 +1,257 @@
+---
+title: Angular v19 Client
+description: Generate a type-safe Angular v19 client from OpenAPI with the Angular client for openapi-ts. Fully compatible with validators, transformers, and all core features.
+---
+
+
+
+
+ Angular
+
+
+
+::: warning
+Angular client is currently in beta. The interface might change before it becomes stable. We encourage you to leave feedback on [GitHub](https://github.com/hey-api/openapi-ts/issues).
+:::
+
+### About
+
+[Angular](https://angular.dev/) is a web framework that empowers developers to build fast, reliable applications.
+
+The Angular client for Hey API generates a type-safe client from your OpenAPI spec, fully compatible with validators, transformers, and all core features.
+
+### Collaborators
+
+
+
+## Features
+
+- Angular v19 support
+- seamless integration with `@hey-api/openapi-ts` ecosystem
+- type-safe response data and errors
+- support for [`@Injectable()`](https://angular.dev/api/core/Injectable) decorators
+- response data validation and transformation
+- access to the original request and response
+- granular request and response customization options
+- minimal learning curve thanks to extending the underlying technology
+- support bundling inside the generated output
+
+## Installation
+
+In your [configuration](/openapi-ts/get-started), add `@hey-api/client-angular` to your plugins and you'll be ready to generate client artifacts. :tada:
+
+::: code-group
+
+```js [config]
+export default {
+ input: 'https://get.heyapi.dev/hey-api/backend',
+ output: 'src/client',
+ plugins: ['@hey-api/client-angular'], // [!code ++]
+};
+```
+
+```sh [cli]
+npx @hey-api/openapi-ts \
+ -i https://get.heyapi.dev/hey-api/backend \
+ -o src/client \
+ -c @hey-api/client-angular # [!code ++]
+```
+
+:::
+
+### Providers
+
+You can use the Angular client in your application by adding `provideHeyApiClient` to your providers.
+
+```ts
+import { provideHeyApiClient, client } from './client/client.gen';
+
+export const appConfig: ApplicationConfig = {
+ providers: [
+ provideHttpClient(withFetch()),
+ provideHeyApiClient(client), // [!code ++]
+ ],
+};
+```
+
+## Configuration
+
+The Angular client is built as a thin wrapper on top of Angular, extending its functionality to work with Hey API. If you're already familiar with Angular, configuring your client will feel like working directly with Angular.
+
+When we installed the client above, it created a [`client.gen.ts`](/openapi-ts/output#client) file. You will most likely want to configure the exported `client` instance. There are two ways to do that.
+
+### `setConfig()`
+
+This is the simpler approach. You can call the `setConfig()` method at the beginning of your application or anytime you need to update the client configuration. You can pass any `HttpRequest` configuration option to `setConfig()`, and even your own [`httpClient`](#custom-httpclient) implementation.
+
+```js
+import { client } from 'client/client.gen';
+
+client.setConfig({
+ baseUrl: 'https://example.com',
+});
+```
+
+The disadvantage of this approach is that your code may call the `client` instance before it's configured for the first time. Depending on your use case, you might need to use the second approach.
+
+### Runtime API
+
+Since `client.gen.ts` is a generated file, we can't directly modify it. Instead, we can tell our configuration to use a custom file implementing the Runtime API. We do that by specifying the `runtimeConfigPath` option.
+
+```js
+export default {
+ input: 'https://get.heyapi.dev/hey-api/backend',
+ output: 'src/client',
+ plugins: [
+ {
+ name: '@hey-api/client-angular',
+ runtimeConfigPath: './src/hey-api.ts', // [!code ++]
+ },
+ ],
+};
+```
+
+In our custom file, we need to export a `createClientConfig()` method. This function is a simple wrapper allowing us to override configuration values.
+
+::: code-group
+
+```ts [hey-api.ts]
+import type { CreateClientConfig } from './client/client.gen';
+
+export const createClientConfig: CreateClientConfig = (config) => ({
+ ...config,
+ baseUrl: 'https://example.com',
+});
+```
+
+:::
+
+With this approach, `client.gen.ts` will call `createClientConfig()` before initializing the `client` instance. If needed, you can still use `setConfig()` to update the client configuration later.
+
+### `createClient()`
+
+You can also create your own client instance. You can use it to manually send requests or point it to a different domain.
+
+```js
+import { createClient } from './client/client';
+
+const myClient = createClient({
+ baseUrl: 'https://example.com',
+});
+```
+
+You can also pass this instance to any SDK function through the `client` option. This will override the default instance from `client.gen.ts`.
+
+```js
+const response = await getFoo({
+ client: myClient,
+});
+```
+
+### SDKs
+
+Alternatively, you can pass the client 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({
+ baseUrl: 'https://example.com', // <-- override default configuration
+});
+```
+
+## `@Injectable`
+
+If you prefer to use the [`@Injectable()`](https://angular.dev/api/core/Injectable) decorators, set the `asClass` option in your SDK plugin to `true`.
+
+::: code-group
+
+```ts [example]
+@Injectable({ providedIn: 'root' })
+export class FooService {
+ // class methods
+}
+```
+
+```js [config]
+export default {
+ input: 'https://get.heyapi.dev/hey-api/backend',
+ output: 'src/client',
+ plugins: [
+ '@hey-api/client-angular',
+ {
+ name: '@hey-api/sdk',
+ asClass: true, // [!code ++]
+ },
+ ],
+};
+```
+
+:::
+
+## Interceptors
+
+::: warning
+This section is under construction. We appreciate your patience.
+:::
+
+## Auth
+
+::: warning
+This section is under construction. We appreciate your patience.
+:::
+
+## Build URL
+
+If you need to access the compiled URL, you can use the `buildUrl()` method. It's loosely typed by default to accept almost any value; in practice, you will want to pass a type hint.
+
+```ts
+type FooData = {
+ path: {
+ fooId: number;
+ };
+ query?: {
+ bar?: string;
+ };
+ url: '/foo/{fooId}';
+};
+
+const url = client.buildUrl({
+ path: {
+ fooId: 1,
+ },
+ query: {
+ bar: 'baz',
+ },
+ url: '/foo/{fooId}',
+});
+console.log(url); // prints '/foo/1?bar=baz'
+```
+
+## Custom `httpClient`
+
+You can implement your own `httpClient`. This is useful if you need to extend the default `httpClient` methods with extra functionality, or replace it altogether.
+
+```js
+import { client } from 'client/client.gen';
+
+client.setConfig({
+ httpClient: inject(CustomHttpClient),
+});
+```
+
+You can use any of the approaches mentioned in [Configuration](#configuration), depending on how granular you want your custom client to be.
+
+## Plugins
+
+You might be also interested in the [Angular](/openapi-ts/plugins/angular/v19) plugin.
+
+## API
+
+You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@hey-api/client-angular/types.d.ts) interface.
+
+
+
diff --git a/docs/openapi-ts/clients/axios.md b/docs/openapi-ts/clients/axios.md
index b1ef2b87fe..729418ac4e 100644
--- a/docs/openapi-ts/clients/axios.md
+++ b/docs/openapi-ts/clients/axios.md
@@ -1,9 +1,12 @@
---
-title: Axios client
-description: Axios client for Hey API. Compatible with all our features.
+title: Axios v1 Client
+description: Generate a type-safe Axios v1 client from OpenAPI with the Axios client for openapi-ts. Fully compatible with validators, transformers, and all core features.
---
@@ -16,6 +19,8 @@ import { embedProject } from '../../embed'
[Axios](https://axios-http.com) is a simple promise based HTTP client for the browser and Node.js. Axios provides a simple to use library in a small package with a very extensible interface.
+The Axios client for Hey API generates a type-safe client from your OpenAPI spec, fully compatible with validators, transformers, and all core features.
+
### Demo
embedProject('hey-api-client-axios-example')(event)">
@@ -24,6 +29,7 @@ Launch demo
## Features
+- Axios v1 support
- seamless integration with `@hey-api/openapi-ts` ecosystem
- type-safe response data and errors
- response data validation and transformation
diff --git a/docs/openapi-ts/clients/effect.md b/docs/openapi-ts/clients/effect.md
index c0e60d5b69..441384784c 100644
--- a/docs/openapi-ts/clients/effect.md
+++ b/docs/openapi-ts/clients/effect.md
@@ -3,6 +3,10 @@ title: Effect client
description: Effect client for Hey API. Compatible with all our features.
---
+
+
# Effect soon
diff --git a/docs/openapi-ts/clients/fetch.md b/docs/openapi-ts/clients/fetch.md
index d68ce56a5b..b87f08dbcc 100644
--- a/docs/openapi-ts/clients/fetch.md
+++ b/docs/openapi-ts/clients/fetch.md
@@ -1,6 +1,6 @@
---
-title: Fetch API client
-description: Fetch API client for Hey API. Compatible with all our features.
+title: Fetch API Client
+description: Generate a type-safe Fetch API client from OpenAPI with the Fetch API client for openapi-ts. Fully compatible with validators, transformers, and all core features.
---
+
Nuxt
@@ -16,12 +21,11 @@ Nuxt client is currently in beta. The interface might change before it becomes s
[Nuxt](https://nuxt.com) is an open source framework that makes web development intuitive and powerful.
-
+The Nuxt client for Hey API generates a type-safe client from your OpenAPI spec, fully compatible with validators, transformers, and all core features.
## Features
+- Nuxt v3 support
- seamless integration with `@hey-api/openapi-ts` ecosystem
- type-safe response data and errors
- response data validation and transformation
diff --git a/docs/openapi-ts/plugins.md b/docs/openapi-ts/plugins.md
index 1a8cf482e4..2cc02898fa 100644
--- a/docs/openapi-ts/plugins.md
+++ b/docs/openapi-ts/plugins.md
@@ -25,6 +25,7 @@ These plugins help reduce boilerplate associated with third-party dependencies.
- [`@tanstack/solid-query`](/openapi-ts/plugins/tanstack-query)
- [`@tanstack/svelte-query`](/openapi-ts/plugins/tanstack-query)
- [`@tanstack/vue-query`](/openapi-ts/plugins/tanstack-query)
+- [`@angular/common`](/openapi-ts/plugins/angular)
- [`fastify`](/openapi-ts/plugins/fastify)
- [`valibot`](/openapi-ts/plugins/valibot)
- [`zod`](/openapi-ts/plugins/zod)
diff --git a/docs/openapi-ts/plugins/adonis.md b/docs/openapi-ts/plugins/adonis.md
index 8ec7590abe..4675c2e214 100644
--- a/docs/openapi-ts/plugins/adonis.md
+++ b/docs/openapi-ts/plugins/adonis.md
@@ -3,6 +3,10 @@ title: AdonisJS
description: AdonisJS plugin for Hey API. Compatible with all our features.
---
+
+
# AdonisJS soon
diff --git a/docs/openapi-ts/plugins/ajv.md b/docs/openapi-ts/plugins/ajv.md
index 696c05b2dd..1ce6bfdb25 100644
--- a/docs/openapi-ts/plugins/ajv.md
+++ b/docs/openapi-ts/plugins/ajv.md
@@ -3,6 +3,10 @@ title: Ajv
description: Ajv plugin for Hey API. Compatible with all our features.
---
+
+
# Ajv soon
diff --git a/docs/openapi-ts/plugins/angular.md b/docs/openapi-ts/plugins/angular.md
new file mode 100644
index 0000000000..32b1a10930
--- /dev/null
+++ b/docs/openapi-ts/plugins/angular.md
@@ -0,0 +1,123 @@
+---
+title: Angular v20 Plugin
+description: Generate Angular v20 HTTP requests and resources from OpenAPI with the Angular plugin for openapi-ts. Fully compatible with validators, transformers, and all core features.
+---
+
+
+
+
+ Angular
+
+
+
+::: warning
+Angular client is currently in beta. The interface might change before it becomes stable. We encourage you to leave feedback on [GitHub](https://github.com/hey-api/openapi-ts/issues).
+:::
+
+### About
+
+[Angular](https://angular.dev/) is a web framework that empowers developers to build fast, reliable applications.
+
+The Angular plugin for Hey API generates HTTP requests and resources from your OpenAPI spec, fully compatible with validators, transformers, and all core features.
+
+### Collaborators
+
+
+
+## Features
+
+- Angular v20 support
+- seamless integration with `@hey-api/openapi-ts` ecosystem
+- generate HTTP requests
+- generate HTTP resources
+- minimal learning curve thanks to extending the underlying technology
+
+## Installation
+
+In your [configuration](/openapi-ts/get-started), add `@angular/common` to your plugins and you'll be ready to generate Angular artifacts. :tada:
+
+```js
+export default {
+ input: 'https://get.heyapi.dev/hey-api/backend',
+ output: 'src/client',
+ plugins: [
+ // ...other plugins
+ '@angular/common', // [!code ++]
+ ],
+};
+```
+
+## Output
+
+The Angular plugin will generate the following artifacts, depending on the input specification.
+
+## Requests
+
+A single function is generated for each endpoint. It returns an [`HttpRequest`](https://angular.dev/api/common/http/HttpRequest) result.
+
+::: code-group
+
+```ts [example]
+export const addPetRequest = (options) =>
+ client.requestOptions({
+ method: 'POST',
+ responseStyle: 'data',
+ url: '/pet',
+ ...options,
+ });
+```
+
+```js [config]
+export default {
+ input: 'https://get.heyapi.dev/hey-api/backend',
+ output: 'src/client',
+ plugins: [
+ // ...other plugins
+ {
+ name: '@angular/common',
+ httpRequests: true, // [!code ++]
+ },
+ ],
+};
+```
+
+:::
+
+## Resources
+
+A single function is generated for each endpoint. It returns a result from [`httpResource`](https://angular.dev/api/common/http/httpResource) call.
+
+::: code-group
+
+```ts [example]
+export const addPetResource = (options) =>
+ httpResource(() => addPetRequest(options()));
+```
+
+```js [config]
+export default {
+ input: 'https://get.heyapi.dev/hey-api/backend',
+ output: 'src/client',
+ plugins: [
+ // ...other plugins
+ {
+ name: '@angular/common',
+ httpResources: true, // [!code ++]
+ },
+ ],
+};
+```
+
+:::
+
+## API
+
+You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@angular/common/types.d.ts) interface.
+
+
+
diff --git a/docs/openapi-ts/plugins/angular/v19.md b/docs/openapi-ts/plugins/angular/v19.md
new file mode 100644
index 0000000000..5f0f985567
--- /dev/null
+++ b/docs/openapi-ts/plugins/angular/v19.md
@@ -0,0 +1,123 @@
+---
+title: Angular v19 Plugin
+description: Generate Angular v19 HTTP requests and resources from OpenAPI with the Angular plugin for openapi-ts. Fully compatible with validators, transformers, and all core features.
+---
+
+
+
+
+ Angular
+
+
+
+::: warning
+Angular client is currently in beta. The interface might change before it becomes stable. We encourage you to leave feedback on [GitHub](https://github.com/hey-api/openapi-ts/issues).
+:::
+
+### About
+
+[Angular](https://angular.dev/) is a web framework that empowers developers to build fast, reliable applications.
+
+The Angular plugin for Hey API generates HTTP requests and resources from your OpenAPI spec, fully compatible with validators, transformers, and all core features.
+
+### Collaborators
+
+
+
+## Features
+
+- Angular v19 support
+- seamless integration with `@hey-api/openapi-ts` ecosystem
+- generate HTTP requests
+- generate HTTP resources
+- minimal learning curve thanks to extending the underlying technology
+
+## Installation
+
+In your [configuration](/openapi-ts/get-started), add `@angular/common` to your plugins and you'll be ready to generate Angular artifacts. :tada:
+
+```js
+export default {
+ input: 'https://get.heyapi.dev/hey-api/backend',
+ output: 'src/client',
+ plugins: [
+ // ...other plugins
+ '@angular/common', // [!code ++]
+ ],
+};
+```
+
+## Output
+
+The Angular plugin will generate the following artifacts, depending on the input specification.
+
+## Requests
+
+A single function is generated for each endpoint. It returns an [`HttpRequest`](https://v19.angular.dev/api/common/http/HttpRequest) result.
+
+::: code-group
+
+```ts [example]
+export const addPetRequest = (options) =>
+ client.requestOptions({
+ method: 'POST',
+ responseStyle: 'data',
+ url: '/pet',
+ ...options,
+ });
+```
+
+```js [config]
+export default {
+ input: 'https://get.heyapi.dev/hey-api/backend',
+ output: 'src/client',
+ plugins: [
+ // ...other plugins
+ {
+ name: '@angular/common',
+ httpRequests: true, // [!code ++]
+ },
+ ],
+};
+```
+
+:::
+
+## Resources
+
+A single function is generated for each endpoint. It returns a result from [`httpResource`](https://v19.angular.dev/api/common/http/httpResource) call.
+
+::: code-group
+
+```ts [example]
+export const addPetResource = (options) =>
+ httpResource(() => addPetRequest(options()));
+```
+
+```js [config]
+export default {
+ input: 'https://get.heyapi.dev/hey-api/backend',
+ output: 'src/client',
+ plugins: [
+ // ...other plugins
+ {
+ name: '@angular/common',
+ httpResources: true, // [!code ++]
+ },
+ ],
+};
+```
+
+:::
+
+## API
+
+You can view the complete list of options in the [UserConfig](https://github.com/hey-api/openapi-ts/blob/main/packages/openapi-ts/src/plugins/@angular/common/types.d.ts) interface.
+
+
+
diff --git a/docs/openapi-ts/plugins/arktype.md b/docs/openapi-ts/plugins/arktype.md
index 6e7462eebc..c032e3bd09 100644
--- a/docs/openapi-ts/plugins/arktype.md
+++ b/docs/openapi-ts/plugins/arktype.md
@@ -3,6 +3,10 @@ title: Arktype
description: Arktype plugin for Hey API. Compatible with all our features.
---
+
+
# Arktype soon
diff --git a/docs/openapi-ts/plugins/express.md b/docs/openapi-ts/plugins/express.md
index b5209dcfcb..2af188b493 100644
--- a/docs/openapi-ts/plugins/express.md
+++ b/docs/openapi-ts/plugins/express.md
@@ -3,6 +3,10 @@ title: Express
description: Express plugin for Hey API. Compatible with all our features.
---
+
+
# Express soon
diff --git a/docs/openapi-ts/plugins/faker.md b/docs/openapi-ts/plugins/faker.md
index 9979319053..683c3f4031 100644
--- a/docs/openapi-ts/plugins/faker.md
+++ b/docs/openapi-ts/plugins/faker.md
@@ -3,6 +3,10 @@ title: Faker
description: Faker plugin for Hey API. Compatible with all our features.
---
+
+
# Faker soon
diff --git a/docs/openapi-ts/plugins/fastify.md b/docs/openapi-ts/plugins/fastify.md
index 1a73130efa..b23f0d02c3 100644
--- a/docs/openapi-ts/plugins/fastify.md
+++ b/docs/openapi-ts/plugins/fastify.md
@@ -3,6 +3,13 @@ title: Fastify v5 Plugin
description: Generate Fastify v5 route handlers from OpenAPI with the Fastify plugin for openapi-ts. Fully compatible with validators, transformers, and all core features.
---
+
+
Fastify
@@ -18,17 +25,9 @@ Fastify plugin is currently in beta. The interface might change before it become
The Fastify plugin for Hey API generates route handlers from your OpenAPI spec, fully compatible with all core features.
-
-
### Collaborators
-
+
## Features
diff --git a/docs/openapi-ts/plugins/hono.md b/docs/openapi-ts/plugins/hono.md
index 0f8a81832b..be85878e94 100644
--- a/docs/openapi-ts/plugins/hono.md
+++ b/docs/openapi-ts/plugins/hono.md
@@ -3,6 +3,10 @@ title: Hono
description: Hono plugin for Hey API. Compatible with all our features.
---
+
+
# Hono soon
diff --git a/docs/openapi-ts/plugins/joi.md b/docs/openapi-ts/plugins/joi.md
index f13db1cca1..016ae47288 100644
--- a/docs/openapi-ts/plugins/joi.md
+++ b/docs/openapi-ts/plugins/joi.md
@@ -3,6 +3,10 @@ title: Joi
description: Joi plugin for Hey API. Compatible with all our features.
---
+
+
# Joi soon
diff --git a/docs/openapi-ts/plugins/koa.md b/docs/openapi-ts/plugins/koa.md
index 7fbba71d62..4aca4dc6bf 100644
--- a/docs/openapi-ts/plugins/koa.md
+++ b/docs/openapi-ts/plugins/koa.md
@@ -3,6 +3,10 @@ title: Koa
description: Koa plugin for Hey API. Compatible with all our features.
---
+
+
# Koa soon
diff --git a/docs/openapi-ts/plugins/msw.md b/docs/openapi-ts/plugins/msw.md
index 23483045e5..56decd8c05 100644
--- a/docs/openapi-ts/plugins/msw.md
+++ b/docs/openapi-ts/plugins/msw.md
@@ -3,6 +3,10 @@ title: MSW
description: MSW plugin for Hey API. Compatible with all our features.
---
+
+
# MSW soon
diff --git a/docs/openapi-ts/plugins/nest.md b/docs/openapi-ts/plugins/nest.md
index 99b365f912..a2b8d0f1ae 100644
--- a/docs/openapi-ts/plugins/nest.md
+++ b/docs/openapi-ts/plugins/nest.md
@@ -3,6 +3,10 @@ title: Nest
description: Nest plugin for Hey API. Compatible with all our features.
---
+
+
# Nest soon
diff --git a/docs/openapi-ts/plugins/nock.md b/docs/openapi-ts/plugins/nock.md
index 91e9d4ca81..0115deb7fa 100644
--- a/docs/openapi-ts/plugins/nock.md
+++ b/docs/openapi-ts/plugins/nock.md
@@ -3,6 +3,10 @@ title: Nock
description: Nock plugin for Hey API. Compatible with all our features.
---
+
+
# Nock soon
diff --git a/docs/openapi-ts/plugins/pinia-colada.md b/docs/openapi-ts/plugins/pinia-colada.md
index a60fbb0861..1b44cf72c2 100644
--- a/docs/openapi-ts/plugins/pinia-colada.md
+++ b/docs/openapi-ts/plugins/pinia-colada.md
@@ -3,6 +3,10 @@ title: Pinia Colada
description: Pinia Colada plugin for Hey API. Compatible with all our features.
---
+
+
# Pinia Colada soon
diff --git a/docs/openapi-ts/plugins/superstruct.md b/docs/openapi-ts/plugins/superstruct.md
index 19ee13444c..539305ee6e 100644
--- a/docs/openapi-ts/plugins/superstruct.md
+++ b/docs/openapi-ts/plugins/superstruct.md
@@ -3,6 +3,10 @@ title: Superstruct
description: Superstruct plugin for Hey API. Compatible with all our features.
---
+
+
# Superstruct soon
diff --git a/docs/openapi-ts/plugins/supertest.md b/docs/openapi-ts/plugins/supertest.md
index fbbb1a8fea..e6f492ca7b 100644
--- a/docs/openapi-ts/plugins/supertest.md
+++ b/docs/openapi-ts/plugins/supertest.md
@@ -3,6 +3,10 @@ title: Supertest
description: Supertest plugin for Hey API. Compatible with all our features.
---
+
+
# Supertest soon
diff --git a/docs/openapi-ts/plugins/swr.md b/docs/openapi-ts/plugins/swr.md
index 684fe437e4..9acd63040d 100644
--- a/docs/openapi-ts/plugins/swr.md
+++ b/docs/openapi-ts/plugins/swr.md
@@ -3,6 +3,10 @@ title: SWR
description: SWR plugin for Hey API. Compatible with all our features.
---
+
+
# SWR soon
diff --git a/docs/openapi-ts/plugins/tanstack-query.md b/docs/openapi-ts/plugins/tanstack-query.md
index 946e9b2a78..26c8316717 100644
--- a/docs/openapi-ts/plugins/tanstack-query.md
+++ b/docs/openapi-ts/plugins/tanstack-query.md
@@ -4,6 +4,9 @@ description: Generate TanStack Query v5 functions and query keys from OpenAPI wi
---
diff --git a/docs/openapi-ts/plugins/typebox.md b/docs/openapi-ts/plugins/typebox.md
index f669c2fadb..4bb8ed1d19 100644
--- a/docs/openapi-ts/plugins/typebox.md
+++ b/docs/openapi-ts/plugins/typebox.md
@@ -3,6 +3,10 @@ title: TypeBox
description: TypeBox plugin for Hey API. Compatible with all our features.
---
+
+
# TypeBox soon
diff --git a/docs/openapi-ts/plugins/valibot.md b/docs/openapi-ts/plugins/valibot.md
index 9866dfe337..9ca9e1790b 100644
--- a/docs/openapi-ts/plugins/valibot.md
+++ b/docs/openapi-ts/plugins/valibot.md
@@ -3,9 +3,10 @@ title: Valibot v1 Plugin
description: Generate Valibot v1 schemas from OpenAPI with the Valibot plugin for openapi-ts. Fully compatible with validators, transformers, and all core features.
---
-
+
Valibot
@@ -18,12 +19,6 @@ import { embedProject } from '../../embed'
The Valibot plugin for Hey API generates schemas from your OpenAPI spec, fully compatible with validators, transformers, and all core features.
-
-
## Features
- Valibot v1 support
diff --git a/docs/openapi-ts/plugins/yup.md b/docs/openapi-ts/plugins/yup.md
index c284bf4230..6579ae89c0 100644
--- a/docs/openapi-ts/plugins/yup.md
+++ b/docs/openapi-ts/plugins/yup.md
@@ -3,6 +3,10 @@ title: Yup
description: Yup plugin for Hey API. Compatible with all our features.
---
+
+
# Yup soon
diff --git a/docs/openapi-ts/plugins/zod.md b/docs/openapi-ts/plugins/zod.md
index a3e6fa7f08..d2e4116b10 100644
--- a/docs/openapi-ts/plugins/zod.md
+++ b/docs/openapi-ts/plugins/zod.md
@@ -4,13 +4,14 @@ description: Generate Zod v4 schemas from OpenAPI with the Zod plugin for openap
---
-
+
Zod
-
+
+
### About
@@ -18,12 +19,6 @@ import ZodHeading from './zod/ZodHeading.vue';
The Zod plugin for Hey API generates schemas from your OpenAPI spec, fully compatible with validators, transformers, and all core features.
-
-
## Features
- Zod v4 support
diff --git a/docs/openapi-ts/plugins/zod/mini.md b/docs/openapi-ts/plugins/zod/mini.md
index d5e59f0e71..d1ee757341 100644
--- a/docs/openapi-ts/plugins/zod/mini.md
+++ b/docs/openapi-ts/plugins/zod/mini.md
@@ -4,13 +4,14 @@ description: Generate Zod Mini schemas from OpenAPI with the Zod plugin for open
---
-
+
Zod
-
+
+
### About
@@ -18,12 +19,6 @@ import ZodHeading from './ZodHeading.vue';
The Zod plugin for Hey API generates schemas from your OpenAPI spec, fully compatible with validators, transformers, and all core features.
-
-
## Features
- Zod Mini support
diff --git a/docs/openapi-ts/plugins/zod/v3.md b/docs/openapi-ts/plugins/zod/v3.md
index 3c61eb1572..5dc31875a1 100644
--- a/docs/openapi-ts/plugins/zod/v3.md
+++ b/docs/openapi-ts/plugins/zod/v3.md
@@ -4,13 +4,14 @@ description: Generate Zod v3 schemas from OpenAPI with the Zod plugin for openap
---
-
+
Zod
-
+
+
### About
@@ -18,12 +19,6 @@ import ZodHeading from './ZodHeading.vue';
The Zod plugin for Hey API generates schemas from your OpenAPI spec, fully compatible with validators, transformers, and all core features.
-
-
## Features
- Zod v3 support
diff --git a/docs/openapi-ts/plugins/zustand.md b/docs/openapi-ts/plugins/zustand.md
index e6d55417c1..4a809ddd6f 100644
--- a/docs/openapi-ts/plugins/zustand.md
+++ b/docs/openapi-ts/plugins/zustand.md
@@ -3,6 +3,10 @@ title: Zustand
description: Zustand plugin for Hey API. Compatible with all our features.
---
+
+
# Zustand soon
diff --git a/docs/openapi-ts/web-frameworks.md b/docs/openapi-ts/web-frameworks.md
index 5e7ded6349..013964646c 100644
--- a/docs/openapi-ts/web-frameworks.md
+++ b/docs/openapi-ts/web-frameworks.md
@@ -11,6 +11,7 @@ There are two approaches to developing APIs: code-first, where you start with th
Hey API natively supports the following frameworks.
+- [Angular](/openapi-ts/plugins/angular)
- [Fastify](/openapi-ts/plugins/fastify)
- [Adonis](/openapi-ts/plugins/adonis) Soon
- [Express](/openapi-ts/plugins/express) Soon
diff --git a/docs/tsconfig.json b/docs/tsconfig.json
new file mode 100644
index 0000000000..3eae96d919
--- /dev/null
+++ b/docs/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "compilerOptions": {
+ "baseUrl": ".",
+ "paths": {
+ "@components/*": ["./.vitepress/theme/components/*"],
+ "@data": ["./data/*"],
+ "@versions/*": ["./.vitepress/theme/versions/*"]
+ }
+ },
+ "include": [".vitepress/**/*", "./**/*.ts", "./**/*.vue"]
+}
diff --git a/examples/openapi-ts-angular-resource/.editorconfig b/examples/openapi-ts-angular-common/.editorconfig
similarity index 100%
rename from examples/openapi-ts-angular-resource/.editorconfig
rename to examples/openapi-ts-angular-common/.editorconfig
diff --git a/examples/openapi-ts-angular-resource/.gitignore b/examples/openapi-ts-angular-common/.gitignore
similarity index 100%
rename from examples/openapi-ts-angular-resource/.gitignore
rename to examples/openapi-ts-angular-common/.gitignore
diff --git a/examples/openapi-ts-angular-resource/.vscode/extensions.json b/examples/openapi-ts-angular-common/.vscode/extensions.json
similarity index 100%
rename from examples/openapi-ts-angular-resource/.vscode/extensions.json
rename to examples/openapi-ts-angular-common/.vscode/extensions.json
diff --git a/examples/openapi-ts-angular-resource/.vscode/launch.json b/examples/openapi-ts-angular-common/.vscode/launch.json
similarity index 100%
rename from examples/openapi-ts-angular-resource/.vscode/launch.json
rename to examples/openapi-ts-angular-common/.vscode/launch.json
diff --git a/examples/openapi-ts-angular-resource/.vscode/tasks.json b/examples/openapi-ts-angular-common/.vscode/tasks.json
similarity index 100%
rename from examples/openapi-ts-angular-resource/.vscode/tasks.json
rename to examples/openapi-ts-angular-common/.vscode/tasks.json
diff --git a/examples/openapi-ts-angular-resource/README.md b/examples/openapi-ts-angular-common/README.md
similarity index 100%
rename from examples/openapi-ts-angular-resource/README.md
rename to examples/openapi-ts-angular-common/README.md
diff --git a/examples/openapi-ts-angular-resource/angular.json b/examples/openapi-ts-angular-common/angular.json
similarity index 100%
rename from examples/openapi-ts-angular-resource/angular.json
rename to examples/openapi-ts-angular-common/angular.json
diff --git a/examples/openapi-ts-angular-resource/openapi-ts.config.ts b/examples/openapi-ts-angular-common/openapi-ts.config.ts
similarity index 89%
rename from examples/openapi-ts-angular-resource/openapi-ts.config.ts
rename to examples/openapi-ts-angular-common/openapi-ts.config.ts
index 0776943342..f9b24282ef 100644
--- a/examples/openapi-ts-angular-resource/openapi-ts.config.ts
+++ b/examples/openapi-ts-angular-common/openapi-ts.config.ts
@@ -14,9 +14,10 @@ export default defineConfig({
throwOnError: true,
},
{
- httpResource: {
+ exportFromIndex: true,
+ httpRequests: true,
+ httpResources: {
asClass: true,
- enabled: true,
},
name: '@angular/common',
},
diff --git a/examples/openapi-ts-angular-resource/package-lock.json b/examples/openapi-ts-angular-common/package-lock.json
similarity index 100%
rename from examples/openapi-ts-angular-resource/package-lock.json
rename to examples/openapi-ts-angular-common/package-lock.json
diff --git a/examples/openapi-ts-angular-resource/package.json b/examples/openapi-ts-angular-common/package.json
similarity index 96%
rename from examples/openapi-ts-angular-resource/package.json
rename to examples/openapi-ts-angular-common/package.json
index 0328c8298f..7f9dd0a0ed 100644
--- a/examples/openapi-ts-angular-resource/package.json
+++ b/examples/openapi-ts-angular-common/package.json
@@ -1,5 +1,5 @@
{
- "name": "@example/openapi-ts-angular-resource",
+ "name": "@example/openapi-ts-angular-common",
"private": true,
"version": "0.0.0",
"scripts": {
diff --git a/examples/openapi-ts-angular-resource/public/favicon.ico b/examples/openapi-ts-angular-common/public/favicon.ico
similarity index 100%
rename from examples/openapi-ts-angular-resource/public/favicon.ico
rename to examples/openapi-ts-angular-common/public/favicon.ico
diff --git a/examples/openapi-ts-angular-resource/src/app/app.component.css b/examples/openapi-ts-angular-common/src/app/app.component.css
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/app/app.component.css
rename to examples/openapi-ts-angular-common/src/app/app.component.css
diff --git a/examples/openapi-ts-angular-resource/src/app/app.component.html b/examples/openapi-ts-angular-common/src/app/app.component.html
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/app/app.component.html
rename to examples/openapi-ts-angular-common/src/app/app.component.html
diff --git a/examples/openapi-ts-angular-resource/src/app/app.component.spec.ts b/examples/openapi-ts-angular-common/src/app/app.component.spec.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/app/app.component.spec.ts
rename to examples/openapi-ts-angular-common/src/app/app.component.spec.ts
diff --git a/examples/openapi-ts-angular-resource/src/app/app.component.ts b/examples/openapi-ts-angular-common/src/app/app.component.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/app/app.component.ts
rename to examples/openapi-ts-angular-common/src/app/app.component.ts
diff --git a/examples/openapi-ts-angular-resource/src/app/app.config.server.ts b/examples/openapi-ts-angular-common/src/app/app.config.server.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/app/app.config.server.ts
rename to examples/openapi-ts-angular-common/src/app/app.config.server.ts
diff --git a/examples/openapi-ts-angular-resource/src/app/app.config.ts b/examples/openapi-ts-angular-common/src/app/app.config.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/app/app.config.ts
rename to examples/openapi-ts-angular-common/src/app/app.config.ts
diff --git a/examples/openapi-ts-angular-resource/src/app/app.routes.server.ts b/examples/openapi-ts-angular-common/src/app/app.routes.server.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/app/app.routes.server.ts
rename to examples/openapi-ts-angular-common/src/app/app.routes.server.ts
diff --git a/examples/openapi-ts-angular-resource/src/app/app.routes.ts b/examples/openapi-ts-angular-common/src/app/app.routes.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/app/app.routes.ts
rename to examples/openapi-ts-angular-common/src/app/app.routes.ts
diff --git a/examples/openapi-ts-angular-resource/src/app/demo/demo.css b/examples/openapi-ts-angular-common/src/app/demo/demo.css
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/app/demo/demo.css
rename to examples/openapi-ts-angular-common/src/app/demo/demo.css
diff --git a/examples/openapi-ts-angular-resource/src/app/demo/demo.html b/examples/openapi-ts-angular-common/src/app/demo/demo.html
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/app/demo/demo.html
rename to examples/openapi-ts-angular-common/src/app/demo/demo.html
diff --git a/examples/openapi-ts-angular-resource/src/app/demo/demo.ts b/examples/openapi-ts-angular-common/src/app/demo/demo.ts
similarity index 87%
rename from examples/openapi-ts-angular-resource/src/app/demo/demo.ts
rename to examples/openapi-ts-angular-common/src/app/demo/demo.ts
index 9e52b1fd47..7dc4188f6f 100644
--- a/examples/openapi-ts-angular-resource/src/app/demo/demo.ts
+++ b/examples/openapi-ts-angular-common/src/app/demo/demo.ts
@@ -2,7 +2,7 @@ import { JsonPipe } from '@angular/common';
import { Component, inject, signal } from '@angular/core';
import { RouterOutlet } from '@angular/router';
-import { PetResources } from '../../client';
+import { PetServiceResources } from '../../client';
@Component({
host: { ngSkipHydration: 'true' },
@@ -12,7 +12,7 @@ import { PetResources } from '../../client';
templateUrl: './demo.html',
})
export class Demo {
- #petResources = inject(PetResources);
+ #petResources = inject(PetServiceResources);
petId = signal(0);
diff --git a/examples/openapi-ts-angular-resource/src/client/@angular/common/http/httpRequests.gen.ts b/examples/openapi-ts-angular-common/src/client/@angular/common/http/requests.gen.ts
similarity index 84%
rename from examples/openapi-ts-angular-resource/src/client/@angular/common/http/httpRequests.gen.ts
rename to examples/openapi-ts-angular-common/src/client/@angular/common/http/requests.gen.ts
index 5c5c528b8f..e66f2fbc88 100644
--- a/examples/openapi-ts-angular-resource/src/client/@angular/common/http/httpRequests.gen.ts
+++ b/examples/openapi-ts-angular-common/src/client/@angular/common/http/requests.gen.ts
@@ -33,7 +33,7 @@ import type {
export const addPetRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'POST',
responseStyle: 'data',
url: '/pet',
@@ -47,7 +47,7 @@ export const addPetRequest = (
export const updatePetRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'PUT',
responseStyle: 'data',
url: '/pet',
@@ -61,7 +61,7 @@ export const updatePetRequest = (
export const findPetsByStatusRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'GET',
responseStyle: 'data',
url: '/pet/findByStatus',
@@ -75,7 +75,7 @@ export const findPetsByStatusRequest = (
export const findPetsByTagsRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'GET',
responseStyle: 'data',
url: '/pet/findByTags',
@@ -89,7 +89,7 @@ export const findPetsByTagsRequest = (
export const deletePetRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'DELETE',
responseStyle: 'data',
url: '/pet/{petId}',
@@ -103,7 +103,7 @@ export const deletePetRequest = (
export const getPetByIdRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'GET',
responseStyle: 'data',
url: '/pet/{petId}',
@@ -117,7 +117,7 @@ export const getPetByIdRequest = (
export const updatePetWithFormRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'POST',
responseStyle: 'data',
url: '/pet/{petId}',
@@ -131,7 +131,7 @@ export const updatePetWithFormRequest = (
export const uploadFileRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'POST',
responseStyle: 'data',
url: '/pet/{petId}/uploadImage',
@@ -145,7 +145,7 @@ export const uploadFileRequest = (
export const getInventoryRequest = (
options?: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'GET',
responseStyle: 'data',
url: '/store/inventory',
@@ -159,7 +159,7 @@ export const getInventoryRequest = (
export const placeOrderRequest = (
options?: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'POST',
responseStyle: 'data',
url: '/store/order',
@@ -173,7 +173,7 @@ export const placeOrderRequest = (
export const deleteOrderRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'DELETE',
responseStyle: 'data',
url: '/store/order/{orderId}',
@@ -187,7 +187,7 @@ export const deleteOrderRequest = (
export const getOrderByIdRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'GET',
responseStyle: 'data',
url: '/store/order/{orderId}',
@@ -201,7 +201,7 @@ export const getOrderByIdRequest = (
export const createUserRequest = (
options?: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'POST',
responseStyle: 'data',
url: '/user',
@@ -217,7 +217,7 @@ export const createUsersWithListInputRequest = <
>(
options?: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'POST',
responseStyle: 'data',
url: '/user/createWithList',
@@ -231,7 +231,7 @@ export const createUsersWithListInputRequest = <
export const loginUserRequest = (
options?: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'GET',
responseStyle: 'data',
url: '/user/login',
@@ -245,7 +245,7 @@ export const loginUserRequest = (
export const logoutUserRequest = (
options?: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'GET',
responseStyle: 'data',
url: '/user/logout',
@@ -259,7 +259,7 @@ export const logoutUserRequest = (
export const deleteUserRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'DELETE',
responseStyle: 'data',
url: '/user/{username}',
@@ -273,7 +273,7 @@ export const deleteUserRequest = (
export const getUserByNameRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'GET',
responseStyle: 'data',
url: '/user/{username}',
@@ -287,7 +287,7 @@ export const getUserByNameRequest = (
export const updateUserRequest = (
options: Options,
): HttpRequest =>
- (options?.client ? options.client : _heyApiClient).requestOptions({
+ (options?.client ?? _heyApiClient).requestOptions({
method: 'PUT',
responseStyle: 'data',
url: '/user/{username}',
diff --git a/examples/openapi-ts-angular-resource/src/client/@angular/common/http/httpResource.gen.ts b/examples/openapi-ts-angular-common/src/client/@angular/common/http/resources.gen.ts
similarity index 98%
rename from examples/openapi-ts-angular-resource/src/client/@angular/common/http/httpResource.gen.ts
rename to examples/openapi-ts-angular-common/src/client/@angular/common/http/resources.gen.ts
index 01bfe91e0b..2132781435 100644
--- a/examples/openapi-ts-angular-resource/src/client/@angular/common/http/httpResource.gen.ts
+++ b/examples/openapi-ts-angular-common/src/client/@angular/common/http/resources.gen.ts
@@ -59,12 +59,12 @@ import {
updatePetWithFormRequest,
updateUserRequest,
uploadFileRequest,
-} from './httpRequests.gen';
+} from './requests.gen';
@Injectable({
providedIn: 'root',
})
-export class PetResources {
+export class PetServiceResources {
/**
* Add a new pet to the store.
* Add a new pet to the store.
@@ -155,7 +155,7 @@ export class PetResources {
@Injectable({
providedIn: 'root',
})
-export class StoreResources {
+export class StoreServiceResources {
/**
* Returns pet inventories by status.
* Returns a map of status codes to quantities.
@@ -206,7 +206,7 @@ export class StoreResources {
@Injectable({
providedIn: 'root',
})
-export class UserResources {
+export class UserServiceResources {
/**
* Create user.
* This can only be done by the logged in user.
diff --git a/examples/openapi-ts-angular-resource/src/client/client.gen.ts b/examples/openapi-ts-angular-common/src/client/client.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/client.gen.ts
rename to examples/openapi-ts-angular-common/src/client/client.gen.ts
diff --git a/examples/openapi-ts-angular-resource/src/client/client/client.gen.ts b/examples/openapi-ts-angular-common/src/client/client/client.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/client/client.gen.ts
rename to examples/openapi-ts-angular-common/src/client/client/client.gen.ts
diff --git a/examples/openapi-ts-angular-resource/src/client/client/index.ts b/examples/openapi-ts-angular-common/src/client/client/index.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/client/index.ts
rename to examples/openapi-ts-angular-common/src/client/client/index.ts
diff --git a/examples/openapi-ts-angular-resource/src/client/client/types.gen.ts b/examples/openapi-ts-angular-common/src/client/client/types.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/client/types.gen.ts
rename to examples/openapi-ts-angular-common/src/client/client/types.gen.ts
diff --git a/examples/openapi-ts-angular-resource/src/client/client/utils.gen.ts b/examples/openapi-ts-angular-common/src/client/client/utils.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/client/utils.gen.ts
rename to examples/openapi-ts-angular-common/src/client/client/utils.gen.ts
diff --git a/examples/openapi-ts-angular-resource/src/client/core/auth.gen.ts b/examples/openapi-ts-angular-common/src/client/core/auth.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/core/auth.gen.ts
rename to examples/openapi-ts-angular-common/src/client/core/auth.gen.ts
diff --git a/examples/openapi-ts-angular-resource/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-angular-common/src/client/core/bodySerializer.gen.ts
similarity index 96%
rename from examples/openapi-ts-angular-resource/src/client/core/bodySerializer.gen.ts
rename to examples/openapi-ts-angular-common/src/client/core/bodySerializer.gen.ts
index 9c8e3ec6dc..49cd8925e3 100644
--- a/examples/openapi-ts-angular-resource/src/client/core/bodySerializer.gen.ts
+++ b/examples/openapi-ts-angular-common/src/client/core/bodySerializer.gen.ts
@@ -23,6 +23,8 @@ const serializeFormDataPair = (
): void => {
if (typeof value === 'string' || value instanceof Blob) {
data.append(key, value);
+ } else if (value instanceof Date) {
+ data.append(key, value.toISOString());
} else {
data.append(key, JSON.stringify(value));
}
diff --git a/examples/openapi-ts-angular-resource/src/client/core/params.gen.ts b/examples/openapi-ts-angular-common/src/client/core/params.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/core/params.gen.ts
rename to examples/openapi-ts-angular-common/src/client/core/params.gen.ts
diff --git a/examples/openapi-ts-angular-resource/src/client/core/pathSerializer.gen.ts b/examples/openapi-ts-angular-common/src/client/core/pathSerializer.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/core/pathSerializer.gen.ts
rename to examples/openapi-ts-angular-common/src/client/core/pathSerializer.gen.ts
diff --git a/examples/openapi-ts-angular-resource/src/client/core/types.gen.ts b/examples/openapi-ts-angular-common/src/client/core/types.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/core/types.gen.ts
rename to examples/openapi-ts-angular-common/src/client/core/types.gen.ts
diff --git a/examples/openapi-ts-angular-common/src/client/index.ts b/examples/openapi-ts-angular-common/src/client/index.ts
new file mode 100644
index 0000000000..6921f209d1
--- /dev/null
+++ b/examples/openapi-ts-angular-common/src/client/index.ts
@@ -0,0 +1,5 @@
+// This file is auto-generated by @hey-api/openapi-ts
+export * from './@angular/common/http/requests.gen';
+export * from './@angular/common/http/resources.gen';
+export * from './sdk.gen';
+export * from './types.gen';
diff --git a/examples/openapi-ts-angular-resource/src/client/schemas.gen.ts b/examples/openapi-ts-angular-common/src/client/schemas.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/schemas.gen.ts
rename to examples/openapi-ts-angular-common/src/client/schemas.gen.ts
diff --git a/examples/openapi-ts-angular-resource/src/client/sdk.gen.ts b/examples/openapi-ts-angular-common/src/client/sdk.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/sdk.gen.ts
rename to examples/openapi-ts-angular-common/src/client/sdk.gen.ts
diff --git a/examples/openapi-ts-angular-resource/src/client/types.gen.ts b/examples/openapi-ts-angular-common/src/client/types.gen.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/client/types.gen.ts
rename to examples/openapi-ts-angular-common/src/client/types.gen.ts
diff --git a/examples/openapi-ts-angular-resource/src/index.html b/examples/openapi-ts-angular-common/src/index.html
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/index.html
rename to examples/openapi-ts-angular-common/src/index.html
diff --git a/examples/openapi-ts-angular-resource/src/main.server.ts b/examples/openapi-ts-angular-common/src/main.server.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/main.server.ts
rename to examples/openapi-ts-angular-common/src/main.server.ts
diff --git a/examples/openapi-ts-angular-resource/src/main.ts b/examples/openapi-ts-angular-common/src/main.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/main.ts
rename to examples/openapi-ts-angular-common/src/main.ts
diff --git a/examples/openapi-ts-angular-resource/src/server.ts b/examples/openapi-ts-angular-common/src/server.ts
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/server.ts
rename to examples/openapi-ts-angular-common/src/server.ts
diff --git a/examples/openapi-ts-angular-resource/src/styles.css b/examples/openapi-ts-angular-common/src/styles.css
similarity index 100%
rename from examples/openapi-ts-angular-resource/src/styles.css
rename to examples/openapi-ts-angular-common/src/styles.css
diff --git a/examples/openapi-ts-angular-resource/tsconfig.app.json b/examples/openapi-ts-angular-common/tsconfig.app.json
similarity index 100%
rename from examples/openapi-ts-angular-resource/tsconfig.app.json
rename to examples/openapi-ts-angular-common/tsconfig.app.json
diff --git a/examples/openapi-ts-angular-resource/tsconfig.json b/examples/openapi-ts-angular-common/tsconfig.json
similarity index 100%
rename from examples/openapi-ts-angular-resource/tsconfig.json
rename to examples/openapi-ts-angular-common/tsconfig.json
diff --git a/examples/openapi-ts-angular-resource/tsconfig.spec.json b/examples/openapi-ts-angular-common/tsconfig.spec.json
similarity index 100%
rename from examples/openapi-ts-angular-resource/tsconfig.spec.json
rename to examples/openapi-ts-angular-common/tsconfig.spec.json
diff --git a/examples/openapi-ts-angular-resource/src/client/index.ts b/examples/openapi-ts-angular-resource/src/client/index.ts
deleted file mode 100644
index 39dbe8f294..0000000000
--- a/examples/openapi-ts-angular-resource/src/client/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
-// This file is auto-generated by @hey-api/openapi-ts
-export * from './@angular/common/http/httpRequests.gen';
-export * from './@angular/common/http/httpResource.gen';
-export * from './sdk.gen';
-export * from './types.gen';
diff --git a/examples/openapi-ts-angular/openapi-ts.config.ts b/examples/openapi-ts-angular/openapi-ts.config.ts
index 2fe9b2e141..0028606682 100644
--- a/examples/openapi-ts-angular/openapi-ts.config.ts
+++ b/examples/openapi-ts-angular/openapi-ts.config.ts
@@ -9,9 +9,7 @@ export default defineConfig({
path: './src/client',
},
plugins: [
- {
- name: '@hey-api/client-angular',
- },
+ '@hey-api/client-angular',
'@hey-api/schemas',
{
asClass: true,
diff --git a/examples/openapi-ts-angular/src/client/core/bodySerializer.gen.ts b/examples/openapi-ts-angular/src/client/core/bodySerializer.gen.ts
index 9c8e3ec6dc..49cd8925e3 100644
--- a/examples/openapi-ts-angular/src/client/core/bodySerializer.gen.ts
+++ b/examples/openapi-ts-angular/src/client/core/bodySerializer.gen.ts
@@ -23,6 +23,8 @@ const serializeFormDataPair = (
): void => {
if (typeof value === 'string' || value instanceof Blob) {
data.append(key, value);
+ } else if (value instanceof Date) {
+ data.append(key, value.toISOString());
} else {
data.append(key, JSON.stringify(value));
}
diff --git a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts
index 14a7bfd57a..d934dbf196 100644
--- a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts
+++ b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts
@@ -40,8 +40,8 @@ export default defineConfig(() => {
path: path.resolve(
getSpecsPath(),
'3.1.x',
- // 'full.yaml',
- 'validators-circular-ref.json',
+ 'full.yaml',
+ // 'validators-circular-ref.json',
),
// path: 'http://localhost:4000/',
// path: 'https://get.heyapi.dev/',
@@ -127,7 +127,8 @@ export default defineConfig(() => {
{
// baseUrl: false,
// exportFromIndex: true,
- name: '@hey-api/client-fetch',
+ // name: '@hey-api/client-fetch',
+ name: '@hey-api/client-angular',
// name: 'legacy/angular',
// strictBaseUrl: true,
throwOnError: true,
@@ -231,7 +232,7 @@ export default defineConfig(() => {
// infer: 'D{{name}}ZodType',
// },
},
- // exportFromIndex: true,
+ exportFromIndex: true,
metadata: true,
name: 'zod',
// requests: {
@@ -259,6 +260,12 @@ export default defineConfig(() => {
// name: '@hey-api/schemas',
// type: 'json',
},
+ {
+ // httpRequest
+ // httpResource
+ exportFromIndex: true,
+ name: '@angular/common',
+ },
],
// useOptions: false,
// watch: 3_000,
diff --git a/packages/openapi-ts/README.md b/packages/openapi-ts/README.md
index 90dcc2410e..9756983589 100644
--- a/packages/openapi-ts/README.md
+++ b/packages/openapi-ts/README.md
@@ -282,6 +282,7 @@ Clients are responsible for sending the actual HTTP requests. Using clients is n
### Native Clients
- [`@hey-api/client-fetch`](https://heyapi.dev/openapi-ts/clients/fetch)
+- [`@hey-api/client-angular`](https://heyapi.dev/openapi-ts/clients/angular)
- [`@hey-api/client-axios`](https://heyapi.dev/openapi-ts/clients/axios)
- [`@hey-api/client-next`](https://heyapi.dev/openapi-ts/clients/next-js)
- [`@hey-api/client-nuxt`](https://heyapi.dev/openapi-ts/clients/nuxt)
@@ -290,7 +291,6 @@ Clients are responsible for sending the actual HTTP requests. Using clients is n
The following clients are planned but not in development yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/openapi-ts/labels/RSVP%20%F0%9F%91%8D%F0%9F%91%8E).
-- [`@hey-api/client-angular`](https://heyapi.dev/openapi-ts/clients/angular)
- [`@hey-api/client-effect`](https://heyapi.dev/openapi-ts/clients/effect)
Don't see your client? [Build your own](https://heyapi.dev/openapi-ts/clients/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues).
@@ -308,6 +308,7 @@ These plugins help reduce boilerplate associated with third-party dependencies.
- [`@tanstack/solid-query`](https://heyapi.dev/openapi-ts/plugins/tanstack-query)
- [`@tanstack/svelte-query`](https://heyapi.dev/openapi-ts/plugins/tanstack-query)
- [`@tanstack/vue-query`](https://heyapi.dev/openapi-ts/plugins/tanstack-query)
+- [`@angular/common`](https://heyapi.dev/openapi-ts/plugins/angular)
- [`fastify`](https://heyapi.dev/openapi-ts/plugins/fastify)
- [`valibot`](https://heyapi.dev/openapi-ts/plugins/valibot)
- [`zod`](https://heyapi.dev/openapi-ts/plugins/zod)
diff --git a/packages/openapi-ts/src/plugins/@angular/common/config.ts b/packages/openapi-ts/src/plugins/@angular/common/config.ts
index a3edf8b3d5..3eee37dc1e 100644
--- a/packages/openapi-ts/src/plugins/@angular/common/config.ts
+++ b/packages/openapi-ts/src/plugins/@angular/common/config.ts
@@ -3,42 +3,49 @@ import { handler } from './plugin';
import type { AngularCommonPlugin } from './types';
export const defaultConfig: AngularCommonPlugin['Config'] = {
- config: {},
+ config: {
+ exportFromIndex: false,
+ },
dependencies: ['@hey-api/client-angular', '@hey-api/sdk'],
handler,
name: '@angular/common',
output: '@angular/common',
- resolveConfig(plugin) {
- plugin.config.httpResource = {
- asClass: false,
- classNameBuilder(className) {
- return className + 'Resources';
+ resolveConfig: (plugin, context) => {
+ plugin.config.httpRequests = context.valueToObject({
+ defaultValue: {
+ asClass: false,
+ classNameBuilder: '{{name}}Requests',
+ enabled: true,
},
- enabled: false,
- methodNameBuilder(operation) {
- if (plugin.config.httpResource?.asClass) {
- return String(operation.id);
- }
-
- return String(operation.id) + 'Resource';
+ mappers: {
+ boolean: (enabled) => ({ enabled }),
},
- ...plugin.config.httpResource,
- };
+ value: plugin.config.httpRequests,
+ });
- plugin.config.httpRequest = {
- asClass: false,
- classNameBuilder(className) {
- return className + 'Requests';
- },
- methodNameBuilder(operation) {
- if (plugin.config.httpRequest?.asClass) {
- return String(operation.id);
- }
+ if (!plugin.config.httpRequests.methodNameBuilder) {
+ const { asClass } = plugin.config.httpRequests;
+ plugin.config.httpRequests.methodNameBuilder = (operation) =>
+ asClass ? String(operation.id) : `${String(operation.id)}Request`;
+ }
- return String(operation.id) + 'Request';
+ plugin.config.httpResources = context.valueToObject({
+ defaultValue: {
+ asClass: false,
+ classNameBuilder: '{{name}}Resources',
+ enabled: true,
},
- ...plugin.config.httpRequest,
- };
+ mappers: {
+ boolean: (enabled) => ({ enabled }),
+ },
+ value: plugin.config.httpResources,
+ });
+
+ if (!plugin.config.httpResources.methodNameBuilder) {
+ const { asClass } = plugin.config.httpResources;
+ plugin.config.httpResources.methodNameBuilder = (operation) =>
+ asClass ? String(operation.id) : `${String(operation.id)}Resource`;
+ }
},
};
diff --git a/packages/openapi-ts/src/plugins/@angular/common/constants.ts b/packages/openapi-ts/src/plugins/@angular/common/constants.ts
new file mode 100644
index 0000000000..1d421d0a1d
--- /dev/null
+++ b/packages/openapi-ts/src/plugins/@angular/common/constants.ts
@@ -0,0 +1,2 @@
+export const REQUEST_APIS_SUFFIX = '/http/requests';
+export const RESOURCE_APIS_SUFFIX = '/http/resources';
diff --git a/packages/openapi-ts/src/plugins/@angular/common/companions/angularHttpRequestsCompanionPluginHandler.ts b/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts
similarity index 73%
rename from packages/openapi-ts/src/plugins/@angular/common/companions/angularHttpRequestsCompanionPluginHandler.ts
rename to packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts
index 623180f845..7ea9b24876 100644
--- a/packages/openapi-ts/src/plugins/@angular/common/companions/angularHttpRequestsCompanionPluginHandler.ts
+++ b/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts
@@ -1,74 +1,41 @@
-import { tsc } from '../../../../tsc';
-import { stringCase } from '../../../../utils/stringCase';
-import { clientId } from '../../../@hey-api/client-core/utils';
-import { sdkId } from '../../../@hey-api/sdk/constants';
-import { operationClasses } from '../../../@hey-api/sdk/operation';
-import { typesId } from '../../../@hey-api/typescript/ref';
+import type ts from 'typescript';
+
+import type { GeneratedFile } from '../../../generate/file';
+import type { IR } from '../../../ir/types';
+import { buildName } from '../../../openApi/shared/utils/name';
+import { tsc } from '../../../tsc';
+import { stringCase } from '../../../utils/stringCase';
+import { clientId } from '../../@hey-api/client-core/utils';
+import { sdkId } from '../../@hey-api/sdk/constants';
+import { operationClasses } from '../../@hey-api/sdk/operation';
+import { typesId } from '../../@hey-api/typescript/ref';
import {
createOperationComment,
isOperationOptionsRequired,
-} from '../../../shared/utils/operation';
-import type { AngularCommonPlugin } from '../types';
-
-export const REQUEST_APIS_SUFFIX = '/http/httpRequests';
-
-export const angularHttpRequestsCompanionPluginHandler: AngularCommonPlugin['Handler'] =
- ({ plugin }) => {
- const sdkPlugin = plugin.getPlugin('@hey-api/sdk');
-
- const file = plugin.createFile({
- exportFromIndex: true,
- id: plugin.name + REQUEST_APIS_SUFFIX,
- path: plugin.output + REQUEST_APIS_SUFFIX,
- });
-
- if (plugin.config.httpRequest?.asClass) {
- file.import({
- module: '@angular/core',
- name: 'Injectable',
- });
- }
-
- file.import({
- module: '@angular/common/http',
- name: 'HttpRequest',
- });
-
- file.import({
- module: file.relativePathToFile({
- context: plugin.context,
- id: sdkId,
- }),
- name: 'Options',
- });
-
- if (plugin.config.httpRequest?.asClass) {
- generateAngularClassRequests({ file, plugin, sdkPlugin });
- } else {
- generateAngularFunctionRequests({ file, plugin });
- }
- };
+} from '../../shared/utils/operation';
+import { REQUEST_APIS_SUFFIX } from './constants';
+import type { AngularCommonPlugin } from './types';
interface AngularRequestClassEntry {
className: string;
classes: Set;
methods: Set;
- nodes: Array;
+ nodes: Array;
root: boolean;
}
const generateAngularClassRequests = ({
file,
plugin,
- sdkPlugin,
}: {
- file: any;
+ file: GeneratedFile;
plugin: AngularCommonPlugin['Instance'];
- sdkPlugin: any;
}) => {
const requestClasses = new Map();
const generatedClasses = new Set();
+ const sdkPlugin = plugin.getPlugin('@hey-api/sdk')!;
+
// Iterate through operations to build class structure
plugin.forEach('operation', ({ operation }) => {
const isRequiredOptions = isOperationOptionsRequired({
@@ -110,7 +77,7 @@ const generateAngularClassRequests = ({
// Generate the request method name with "Request" suffix
const requestMethodName =
- plugin.config.httpRequest!.methodNameBuilder!(operation);
+ plugin.config.httpRequests.methodNameBuilder(operation);
// Avoid duplicate methods
if (currentClass.methods.has(requestMethodName)) {
@@ -129,6 +96,7 @@ const generateAngularClassRequests = ({
if (!currentClass.nodes.length) {
currentClass.nodes.push(methodNode);
} else {
+ // @ts-expect-error
currentClass.nodes.push(tsc.identifier({ text: '\n' }), methodNode);
}
@@ -155,9 +123,13 @@ const generateAngularClassRequests = ({
initializer: tsc.newExpression({
argumentsArray: [],
expression: tsc.identifier({
- text: plugin.config.httpRequest!.classNameBuilder!(
- childClass.className,
- ),
+ text: buildName({
+ config: {
+ case: 'preserve',
+ name: plugin.config.httpRequests.classNameBuilder,
+ },
+ name: childClass.className,
+ }),
}),
}),
name: stringCase({
@@ -181,9 +153,13 @@ const generateAngularClassRequests = ({
}
: undefined,
exportClass: currentClass.root,
- name: plugin.config.httpRequest!.classNameBuilder!(
- currentClass.className,
- ),
+ name: buildName({
+ config: {
+ case: 'preserve',
+ name: plugin.config.httpRequests.classNameBuilder,
+ },
+ name: currentClass.className,
+ }),
nodes: currentClass.nodes,
});
@@ -200,7 +176,7 @@ const generateAngularFunctionRequests = ({
file,
plugin,
}: {
- file: any;
+ file: GeneratedFile;
plugin: AngularCommonPlugin['Instance'];
}) => {
plugin.forEach('operation', ({ operation }) => {
@@ -211,7 +187,7 @@ const generateAngularFunctionRequests = ({
// Generate function name with "Request" suffix
const functionName =
- plugin.config.httpRequest!.methodNameBuilder!(operation);
+ plugin.config.httpRequests.methodNameBuilder(operation);
const node = generateAngularRequestFunction({
file,
@@ -230,12 +206,12 @@ const generateRequestCallExpression = ({
operation,
plugin,
}: {
- file: any;
- operation: any;
- plugin: any;
+ file: GeneratedFile;
+ operation: IR.OperationObject;
+ plugin: AngularCommonPlugin['Instance'];
}) => {
- // Import the client and use requestOptions instead of HTTP methods
- const clientImport = file.import({
+ // TODO: client might not be always defined
+ const heyApiClient = file.import({
alias: '_heyApiClient',
module: file.relativePathToFile({
context: plugin.context,
@@ -244,19 +220,18 @@ const generateRequestCallExpression = ({
name: 'client',
});
+ const optionsClient = tsc.propertyAccessExpression({
+ expression: tsc.identifier({ text: 'options' }),
+ isOptional: true,
+ name: 'client',
+ });
+
return tsc.callExpression({
functionName: tsc.propertyAccessExpression({
- expression: tsc.conditionalExpression({
- condition: tsc.propertyAccessExpression({
- expression: tsc.identifier({ text: 'options' }),
- isOptional: true,
- name: 'client',
- }),
- whenFalse: tsc.identifier({ text: clientImport.name }),
- whenTrue: tsc.propertyAccessExpression({
- expression: tsc.identifier({ text: 'options' }),
- name: 'client',
- }),
+ expression: tsc.binaryExpression({
+ left: optionsClient,
+ operator: '??',
+ right: tsc.identifier({ text: heyApiClient.name }),
}),
name: 'requestOptions',
}),
@@ -293,11 +268,11 @@ const generateAngularRequestMethod = ({
operation,
plugin,
}: {
- file: any;
+ file: GeneratedFile;
isRequiredOptions: boolean;
methodName: string;
- operation: any;
- plugin: any;
+ operation: IR.OperationObject;
+ plugin: AngularCommonPlugin['Instance'];
}) => {
// Import operation data type
const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!;
@@ -348,11 +323,11 @@ const generateAngularRequestFunction = ({
operation,
plugin,
}: {
- file: any;
+ file: GeneratedFile;
functionName: string;
isRequiredOptions: boolean;
- operation: any;
- plugin: any;
+ operation: IR.OperationObject;
+ plugin: AngularCommonPlugin['Instance'];
}) => {
const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!;
const fileTypeScript = plugin.context.file({ id: typesId })!;
@@ -396,3 +371,38 @@ const generateAngularRequestFunction = ({
name: functionName,
});
};
+
+export const createHttpRequests: AngularCommonPlugin['Handler'] = ({
+ plugin,
+}) => {
+ const file = plugin.createFile({
+ id: `${plugin.name}${REQUEST_APIS_SUFFIX}`,
+ path: `${plugin.output}${REQUEST_APIS_SUFFIX}`,
+ });
+
+ if (plugin.config.httpRequests.asClass) {
+ file.import({
+ module: '@angular/core',
+ name: 'Injectable',
+ });
+ }
+
+ file.import({
+ module: '@angular/common/http',
+ name: 'HttpRequest',
+ });
+
+ file.import({
+ module: file.relativePathToFile({
+ context: plugin.context,
+ id: sdkId,
+ }),
+ name: 'Options',
+ });
+
+ if (plugin.config.httpRequests.asClass) {
+ generateAngularClassRequests({ file, plugin });
+ } else {
+ generateAngularFunctionRequests({ file, plugin });
+ }
+};
diff --git a/packages/openapi-ts/src/plugins/@angular/common/companions/angularHttpResourceCompanionPluginHandler.ts b/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts
similarity index 76%
rename from packages/openapi-ts/src/plugins/@angular/common/companions/angularHttpResourceCompanionPluginHandler.ts
rename to packages/openapi-ts/src/plugins/@angular/common/httpResources.ts
index ab3d16d684..132c62569c 100644
--- a/packages/openapi-ts/src/plugins/@angular/common/companions/angularHttpResourceCompanionPluginHandler.ts
+++ b/packages/openapi-ts/src/plugins/@angular/common/httpResources.ts
@@ -1,81 +1,40 @@
-import { tsc } from '../../../../tsc';
-import { stringCase } from '../../../../utils/stringCase';
-import { sdkId } from '../../../@hey-api/sdk/constants';
-import { operationClasses } from '../../../@hey-api/sdk/operation';
-import { typesId } from '../../../@hey-api/typescript/ref';
+import type ts from 'typescript';
+
+import type { GeneratedFile } from '../../../generate/file';
+import type { IR } from '../../../ir/types';
+import { buildName } from '../../../openApi/shared/utils/name';
+import { tsc } from '../../../tsc';
+import { stringCase } from '../../../utils/stringCase';
+import { sdkId } from '../../@hey-api/sdk/constants';
+import { operationClasses } from '../../@hey-api/sdk/operation';
+import { typesId } from '../../@hey-api/typescript/ref';
import {
createOperationComment,
isOperationOptionsRequired,
-} from '../../../shared/utils/operation';
-import type { AngularCommonPlugin } from '../types';
-import { REQUEST_APIS_SUFFIX } from './angularHttpRequestsCompanionPluginHandler';
-
-export const RESOURCE_APIS_SUFFIX = '/http/httpResource';
-
-export const angularHttpResourceCompanionPluginHandler: AngularCommonPlugin['Handler'] =
- ({ plugin }) => {
- const sdkPlugin = plugin.getPlugin('@hey-api/sdk');
-
- const file = plugin.createFile({
- exportFromIndex: true,
- id: plugin.name + RESOURCE_APIS_SUFFIX,
- path: plugin.output + RESOURCE_APIS_SUFFIX,
- });
-
- if (plugin.config.httpResource?.asClass) {
- file.import({
- module: '@angular/core',
- name: 'Injectable',
- });
- }
-
- if (plugin.config.httpRequest?.asClass) {
- file.import({
- module: '@angular/core',
- name: 'inject',
- });
- }
-
- file.import({
- module: '@angular/common/http',
- name: 'httpResource',
- });
-
- file.import({
- module: file.relativePathToFile({
- context: plugin.context,
- id: sdkId,
- }),
- name: 'Options',
- });
-
- if (plugin.config.httpResource!.asClass) {
- generateAngularClassServices({ file, plugin, sdkPlugin });
- } else {
- generateAngularFunctionServices({ file, plugin, sdkPlugin });
- }
- };
+} from '../../shared/utils/operation';
+import { REQUEST_APIS_SUFFIX, RESOURCE_APIS_SUFFIX } from './constants';
+import type { AngularCommonPlugin } from './types';
interface AngularServiceClassEntry {
className: string;
classes: Set;
methods: Set;
- nodes: Array;
+ nodes: Array;
root: boolean;
}
const generateAngularClassServices = ({
file,
plugin,
- sdkPlugin,
}: {
- file: any;
+ file: GeneratedFile;
plugin: AngularCommonPlugin['Instance'];
- sdkPlugin: any;
}) => {
const serviceClasses = new Map();
const generatedClasses = new Set();
+ const sdkPlugin = plugin.getPlugin('@hey-api/sdk')!;
+
// Iterate through operations to build class structure
plugin.forEach('operation', ({ operation }) => {
const isRequiredOptions = isOperationOptionsRequired({
@@ -117,7 +76,7 @@ const generateAngularClassServices = ({
// Generate the resource method name
const resourceMethodName =
- plugin.config.httpResource!.methodNameBuilder!(operation);
+ plugin.config.httpResources.methodNameBuilder(operation);
// Avoid duplicate methods
if (currentClass.methods.has(resourceMethodName)) {
@@ -131,12 +90,12 @@ const generateAngularClassServices = ({
methodName: resourceMethodName,
operation,
plugin,
- sdkPlugin,
});
if (!currentClass.nodes.length) {
currentClass.nodes.push(methodNode);
} else {
+ // @ts-expect-error
currentClass.nodes.push(tsc.identifier({ text: '\n' }), methodNode);
}
@@ -163,9 +122,13 @@ const generateAngularClassServices = ({
initializer: tsc.newExpression({
argumentsArray: [],
expression: tsc.identifier({
- text: plugin.config.httpResource!.classNameBuilder!(
- childClass.className,
- ),
+ text: buildName({
+ config: {
+ case: 'preserve',
+ name: plugin.config.httpResources.classNameBuilder,
+ },
+ name: childClass.className,
+ }),
}),
}),
name: stringCase({
@@ -189,9 +152,13 @@ const generateAngularClassServices = ({
}
: undefined,
exportClass: currentClass.root,
- name: plugin.config.httpResource!.classNameBuilder!(
- currentClass.className,
- ),
+ name: buildName({
+ config: {
+ case: 'preserve',
+ name: plugin.config.httpResources.classNameBuilder,
+ },
+ name: currentClass.className,
+ }),
nodes: currentClass.nodes,
});
@@ -207,11 +174,9 @@ const generateAngularClassServices = ({
const generateAngularFunctionServices = ({
file,
plugin,
- sdkPlugin,
}: {
- file: any;
+ file: GeneratedFile;
plugin: AngularCommonPlugin['Instance'];
- sdkPlugin: any;
}) => {
plugin.forEach('operation', ({ operation }) => {
const isRequiredOptions = isOperationOptionsRequired({
@@ -221,11 +186,10 @@ const generateAngularFunctionServices = ({
const node = generateAngularResourceFunction({
file,
- functionName: plugin.config.httpResource!.methodNameBuilder!(operation),
+ functionName: plugin.config.httpResources.methodNameBuilder(operation),
isRequiredOptions,
operation,
plugin,
- sdkPlugin,
});
file.add(node);
@@ -238,17 +202,17 @@ const generateResourceCallExpression = ({
operation,
plugin,
responseTypeName,
- sdkPlugin,
}: {
- file: any;
+ file: GeneratedFile;
isRequiredOptions: boolean;
- operation: any;
- plugin: any;
+ operation: IR.OperationObject;
+ plugin: AngularCommonPlugin['Instance'];
responseTypeName: string;
- sdkPlugin: any;
}) => {
+ const sdkPlugin = plugin.getPlugin('@hey-api/sdk')!;
+
// Check if httpRequest is configured to use classes
- const useRequestClasses = plugin.config.httpRequest?.asClass;
+ const useRequestClasses = plugin.config.httpRequests.asClass;
let requestFunctionCall;
// Create the options call expression based on whether options are required
@@ -277,12 +241,17 @@ const generateResourceCallExpression = ({
const firstEntry = Array.from(classes.values())[0];
if (firstEntry) {
// Import the root class from HTTP requests
- const rootClassName = firstEntry.path[0];
- const requestClassName =
- plugin.config.httpRequest!.classNameBuilder!(rootClassName);
+ const rootClassName = firstEntry.path[0]!;
+ const requestClassName = buildName({
+ config: {
+ case: 'preserve',
+ name: plugin.config.httpRequests.classNameBuilder,
+ },
+ name: rootClassName,
+ });
// Build the method access path using inject
- let methodAccess: any = tsc.callExpression({
+ let methodAccess: ts.Expression = tsc.callExpression({
functionName: 'inject',
parameters: [tsc.identifier({ text: requestClassName })],
});
@@ -303,7 +272,7 @@ const generateResourceCallExpression = ({
// Add the final method name with "Request" suffix
const requestMethodName =
- plugin.config.httpRequest!.methodNameBuilder!(operation);
+ plugin.config.httpRequests.methodNameBuilder(operation);
methodAccess = tsc.propertyAccessExpression({
expression: methodAccess,
name: requestMethodName,
@@ -317,12 +286,12 @@ const generateResourceCallExpression = ({
} else {
// For function-based request methods, import and call the function directly
const requestFunctionName =
- plugin.config.httpRequest!.methodNameBuilder!(operation);
+ plugin.config.httpRequests.methodNameBuilder(operation);
const requestImport = file.import({
module: file.relativePathToFile({
context: plugin.context,
- id: plugin.name + REQUEST_APIS_SUFFIX,
+ id: `${plugin.name}${REQUEST_APIS_SUFFIX}`,
}),
name: requestFunctionName,
});
@@ -355,14 +324,12 @@ const generateAngularResourceMethod = ({
methodName,
operation,
plugin,
- sdkPlugin,
}: {
- file: any;
+ file: GeneratedFile;
isRequiredOptions: boolean;
methodName: string;
- operation: any;
- plugin: any;
- sdkPlugin: any;
+ operation: IR.OperationObject;
+ plugin: AngularCommonPlugin['Instance'];
}) => {
// Import operation data type
const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!;
@@ -405,7 +372,6 @@ const generateAngularResourceMethod = ({
operation,
plugin,
responseTypeName: responseType.name || 'unknown',
- sdkPlugin,
}),
}),
],
@@ -425,14 +391,12 @@ const generateAngularResourceFunction = ({
isRequiredOptions,
operation,
plugin,
- sdkPlugin,
}: {
- file: any;
+ file: GeneratedFile;
functionName: string;
isRequiredOptions: boolean;
- operation: any;
- plugin: any;
- sdkPlugin: any;
+ operation: IR.OperationObject;
+ plugin: AngularCommonPlugin['Instance'];
}) => {
const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!;
const fileTypeScript = plugin.context.file({ id: typesId })!;
@@ -472,7 +436,6 @@ const generateAngularResourceFunction = ({
operation,
plugin,
responseTypeName: responseType.name || 'unknown',
- sdkPlugin,
}),
}),
],
@@ -487,3 +450,45 @@ const generateAngularResourceFunction = ({
name: functionName,
});
};
+
+export const createHttpResources: AngularCommonPlugin['Handler'] = ({
+ plugin,
+}) => {
+ const file = plugin.createFile({
+ id: `${plugin.name}${RESOURCE_APIS_SUFFIX}`,
+ path: `${plugin.output}${RESOURCE_APIS_SUFFIX}`,
+ });
+
+ if (plugin.config.httpResources.asClass) {
+ file.import({
+ module: '@angular/core',
+ name: 'Injectable',
+ });
+ }
+
+ if (plugin.config.httpRequests.asClass) {
+ file.import({
+ module: '@angular/core',
+ name: 'inject',
+ });
+ }
+
+ file.import({
+ module: '@angular/common/http',
+ name: 'httpResource',
+ });
+
+ file.import({
+ module: file.relativePathToFile({
+ context: plugin.context,
+ id: sdkId,
+ }),
+ name: 'Options',
+ });
+
+ if (plugin.config.httpResources.asClass) {
+ generateAngularClassServices({ file, plugin });
+ } else {
+ generateAngularFunctionServices({ file, plugin });
+ }
+};
diff --git a/packages/openapi-ts/src/plugins/@angular/common/plugin.ts b/packages/openapi-ts/src/plugins/@angular/common/plugin.ts
index 4fa53ade8f..477bb1a302 100644
--- a/packages/openapi-ts/src/plugins/@angular/common/plugin.ts
+++ b/packages/openapi-ts/src/plugins/@angular/common/plugin.ts
@@ -1,11 +1,13 @@
-import { angularHttpRequestsCompanionPluginHandler } from './companions/angularHttpRequestsCompanionPluginHandler';
-import { angularHttpResourceCompanionPluginHandler } from './companions/angularHttpResourceCompanionPluginHandler';
+import { createHttpRequests } from './httpRequests';
+import { createHttpResources } from './httpResources';
import type { AngularCommonPlugin } from './types';
-export const handler: AngularCommonPlugin['Handler'] = (args) => {
- angularHttpRequestsCompanionPluginHandler(args);
+export const handler: AngularCommonPlugin['Handler'] = ({ plugin }) => {
+ if (plugin.config.httpRequests.enabled) {
+ createHttpRequests({ plugin });
+ }
- if (args.plugin.config.httpResource?.enabled) {
- angularHttpResourceCompanionPluginHandler(args);
+ if (plugin.config.httpResources.enabled) {
+ createHttpResources({ plugin });
}
};
diff --git a/packages/openapi-ts/src/plugins/@angular/common/types.d.ts b/packages/openapi-ts/src/plugins/@angular/common/types.d.ts
index 370d8074c2..3c9f4ccc4f 100644
--- a/packages/openapi-ts/src/plugins/@angular/common/types.d.ts
+++ b/packages/openapi-ts/src/plugins/@angular/common/types.d.ts
@@ -1,68 +1,153 @@
-import type { Operation } from '../../../types/client';
+import type { StringName } from '../../../types/case';
import type { DefinePlugin, Plugin } from '../../types';
-export type AngularHttpResourceOptions = {
+export type UserConfig = Plugin.Name<'@angular/common'> & {
/**
- * Whether to generate the resource as a class.
+ * Should the exports from the generated files be re-exported in the index
+ * barrel file?
+ *
* @default false
*/
- asClass?: boolean;
-
+ exportFromIndex?: boolean;
/**
- * Builds the class name for the generated resource.
- * By default, the class name is suffixed with "Resources".
+ * Options for generating HTTP Request instances.
+ *
+ * @default true
*/
- classNameBuilder?: (className: string) => string;
-
+ httpRequests?:
+ | boolean
+ | {
+ /**
+ * Whether to generate the resource as a class.
+ *
+ * @default false
+ */
+ asClass?: boolean;
+ /**
+ * Builds the class name for the generated resource.
+ * By default, the class name is suffixed with "Resources".
+ */
+ classNameBuilder?: StringName;
+ /**
+ * Whether or not to create HTTP Request instances.
+ *
+ * @default true
+ */
+ enabled?: boolean;
+ /**
+ * Builds the method name for the generated resource.
+ *
+ * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource".
+ */
+ methodNameBuilder?: (operation: IR.OperationObject) => string;
+ };
/**
- * Wether or not to create http resource APIs.
+ * Options for generating HTTP resource APIs.
+ *
+ * @default true
*/
- enabled: boolean;
-
+ httpResources?:
+ | boolean
+ | {
+ /**
+ * Whether to generate the resource as a class.
+ * @default false
+ */
+ asClass?: boolean;
+ /**
+ * Builds the class name for the generated resource.
+ * By default, the class name is suffixed with "Resources".
+ */
+ classNameBuilder?: StringName;
+ /**
+ * Whether or not to create HTTP resource APIs.
+ *
+ * @default true
+ */
+ enabled?: boolean;
+ /**
+ * Builds the method name for the generated resource.
+ *
+ * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource".
+ */
+ methodNameBuilder?: (operation: IR.OperationObject) => string;
+ };
/**
- * Builds the method name for the generated resource.
- * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource".
+ * Name of the generated file.
+ *
+ * @default '@angular/common'
*/
- methodNameBuilder?: (operation: IR.OperationObject | Operation) => string;
+ output?: string;
};
-export type AngularHttpRequestOptions = {
+export type Config = Plugin.Name<'@angular/common'> & {
/**
- * Whether to generate the resource as a class.
+ * Should the exports from the generated files be re-exported in the index
+ * barrel file?
+ *
* @default false
*/
- asClass?: boolean;
-
- /**
- * Builds the class name for the generated resource.
- * By default, the class name is suffixed with "Resources".
- */
- classNameBuilder?: (className: string) => string;
-
- /**
- * Builds the method name for the generated resource.
- * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource".
- */
- methodNameBuilder?: (operation: IR.OperationObject | Operation) => string;
-};
-
-export type UserConfig = Plugin.Name<'@angular/common'> & {
+ exportFromIndex: boolean;
/**
* Options for generating HTTP Request instances.
*/
- httpRequest?: AngularHttpRequestOptions;
-
+ httpRequests: {
+ /**
+ * Whether to generate the resource as a class.
+ *
+ * @default false
+ */
+ asClass: boolean;
+ /**
+ * Builds the class name for the generated resource.
+ * By default, the class name is suffixed with "Resources".
+ */
+ classNameBuilder: StringName;
+ /**
+ * Whether or not to create HTTP Request instances.
+ *
+ * @default true
+ */
+ enabled: boolean;
+ /**
+ * Builds the method name for the generated resource.
+ * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource".
+ */
+ methodNameBuilder: (operation: IR.OperationObject) => string;
+ };
/**
* Options for generating HTTP resource APIs.
*/
- httpResource?: AngularHttpResourceOptions;
-
+ httpResources: {
+ /**
+ * Whether to generate the resource as a class.
+ *
+ * @default false
+ */
+ asClass: boolean;
+ /**
+ * Builds the class name for the generated resource.
+ * By default, the class name is suffixed with "Resources".
+ */
+ classNameBuilder: StringName;
+ /**
+ * Whether or not to create HTTP resource APIs.
+ *
+ * @default true
+ */
+ enabled: boolean;
+ /**
+ * Builds the method name for the generated resource.
+ * By default, the operation id is used, if `asClass` is false, the method is also suffixed with "Resource".
+ */
+ methodNameBuilder: (operation: IR.OperationObject) => string;
+ };
/**
* Name of the generated file.
*
* @default '@angular/common'
*/
- output?: string;
+ output: string;
};
-export type AngularCommonPlugin = DefinePlugin;
+export type AngularCommonPlugin = DefinePlugin;
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 481d947017..3ea9308883 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -203,7 +203,7 @@ importers:
specifier: 5.8.3
version: 5.8.3
- examples/openapi-ts-angular-resource:
+ examples/openapi-ts-angular-common:
dependencies:
'@angular/common':
specifier: 19.2.0