Skip to content

Commit d116eac

Browse files
committed
feat: examples plugin
1 parent e415f69 commit d116eac

File tree

25 files changed

+209
-64
lines changed

25 files changed

+209
-64
lines changed

.changeset/early-knives-kneel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
**client**: use `getBaseUrl()` function to determine default value

.changeset/five-pianos-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
**plugin(@hey-api/examples)**: initial release

.changeset/nasty-planes-cry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/shared": patch
3+
---
4+
5+
**utils**: export `getBaseUrl()` function

dev/inputs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ const specsPath = path.join(__dirname, '..', 'specs');
55
export const inputs = {
66
circular: path.resolve(specsPath, '3.0.x', 'circular.yaml'),
77
full: path.resolve(specsPath, '3.1.x', 'full.yaml'),
8+
heyapi: 'hey-api/backend',
89
local: 'http://localhost:8000/openapi.json',
10+
mockers: path.resolve(specsPath, '3.1.x', 'mockers.yaml'),
911
opencode: path.resolve(specsPath, '3.1.x', 'opencode.yaml'),
1012
petstore:
1113
'https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml',
1214
redfish:
1315
'https://raw.githubusercontent.com/DMTF/Redfish-Publications/refs/heads/main/openapi/openapi.yaml',
16+
rpc: path.resolve(specsPath, '3.1.x', 'rpc.yaml'),
1417
scalar: 'scalar:@scalar/access-service',
1518
transformers: path.resolve(specsPath, '3.1.x', 'transformers.json'),
1619
validators: path.resolve(specsPath, '3.1.x', 'validators.yaml'),

packages/openapi-python/src/plugins/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type PluginClientNames =
44
| '@hey-api/client-requests'
55
| '@hey-api/client-urllib3';
66

7-
export type PluginMockNames = 'factory_boy' | 'faker' | 'mimesis';
7+
export type PluginSourceNames = 'factory_boy' | 'faker' | 'mimesis';
88

99
export type PluginTransformerNames = never;
1010

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ import type { ClientOptions as ClientOptions2 } from './types.gen';
1313
*/
1414
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
1515

16-
export const client = createClient(createConfig<ClientOptions2>());
16+
export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'api.postmarkapp.com/' }));

packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ import type { ClientOptions as ClientOptions2 } from './types.gen';
1313
*/
1414
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
1515

16-
export const client = createClient(createConfig<ClientOptions2>());
16+
export const client = createClient(createConfig<ClientOptions2>({ baseUrl: 'foo.com' }));

packages/openapi-ts-tests/orpc/v1/test/3.0.x.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ describe(`OpenAPI ${version}`, () => {
1717
const scenarios = [
1818
{
1919
config: createConfig({
20-
input: 'orpc.yaml',
20+
input: 'rpc.yaml',
2121
output: 'default',
2222
plugins: ['orpc', 'zod'],
2323
}),
2424
description: 'generate oRPC contracts with Zod schemas',
2525
},
2626
{
2727
config: createConfig({
28-
input: 'orpc.yaml',
28+
input: 'rpc.yaml',
2929
output: 'custom-names',
3030
plugins: [
3131
'valibot',

packages/openapi-ts-tests/orpc/v1/test/3.1.x.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ describe(`OpenAPI ${version}`, () => {
1717
const scenarios = [
1818
{
1919
config: createConfig({
20-
input: 'orpc.yaml',
20+
input: 'rpc.yaml',
2121
output: 'default',
2222
plugins: ['orpc', 'zod'],
2323
}),
2424
description: 'generate oRPC contracts with Zod schemas',
2525
},
2626
{
2727
config: createConfig({
28-
input: 'orpc.yaml',
28+
input: 'rpc.yaml',
2929
output: 'custom-names',
3030
plugins: [
3131
'valibot',
@@ -42,7 +42,7 @@ describe(`OpenAPI ${version}`, () => {
4242
},
4343
{
4444
config: createConfig({
45-
input: 'orpc.yaml',
45+
input: 'rpc.yaml',
4646
output: 'contracts-strategy-by-tags',
4747
plugins: [
4848
'zod',
@@ -58,7 +58,7 @@ describe(`OpenAPI ${version}`, () => {
5858
},
5959
{
6060
config: createConfig({
61-
input: 'orpc.yaml',
61+
input: 'rpc.yaml',
6262
output: 'contracts-strategy-single',
6363
plugins: [
6464
'zod',
@@ -75,7 +75,7 @@ describe(`OpenAPI ${version}`, () => {
7575
},
7676
{
7777
config: createConfig({
78-
input: 'orpc.yaml',
78+
input: 'rpc.yaml',
7979
output: 'contracts-nesting-id',
8080
plugins: [
8181
'zod',
@@ -92,7 +92,7 @@ describe(`OpenAPI ${version}`, () => {
9292
},
9393
{
9494
config: createConfig({
95-
input: 'orpc.yaml',
95+
input: 'rpc.yaml',
9696
output: 'contracts-custom-naming',
9797
plugins: [
9898
'zod',

packages/openapi-ts/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ declare module '@hey-api/codegen-core' {
4747
| 'arktype'
4848
| 'fastify'
4949
| 'json-schema'
50+
| 'msw'
5051
| 'sdk'
5152
| 'typescript'
5253
| 'valibot'
@@ -67,6 +68,7 @@ declare module '@hey-api/shared' {
6768
'@hey-api/client-next': Plugins.HeyApiClientNext.Types['Types'];
6869
'@hey-api/client-nuxt': Plugins.HeyApiClientNuxt.Types['Types'];
6970
'@hey-api/client-ofetch': Plugins.HeyApiClientOfetch.Types['Types'];
71+
'@hey-api/examples': Plugins.HeyApiExamples.Types['Types'];
7072
'@hey-api/schemas': Plugins.HeyApiSchemas.Types['Types'];
7173
'@hey-api/sdk': Plugins.HeyApiSdk.Types['Types'];
7274
'@hey-api/transformers': Plugins.HeyApiTransformers.Types['Types'];
@@ -126,6 +128,7 @@ import type {
126128
HeyApiClientOfetchPlugin,
127129
OfetchClient as OfetchClientImp,
128130
} from './plugins/@hey-api/client-ofetch';
131+
import type { HeyApiExamplesPlugin } from './plugins/@hey-api/examples';
129132
import type { HeyApiSchemasPlugin } from './plugins/@hey-api/schemas';
130133
import type { HeyApiSdkPlugin } from './plugins/@hey-api/sdk';
131134
import type { HeyApiTransformersPlugin } from './plugins/@hey-api/transformers';
@@ -247,6 +250,10 @@ export namespace Plugins {
247250
export type Types = HeyApiClientOfetchPlugin;
248251
}
249252

253+
export namespace HeyApiExamples {
254+
export type Types = HeyApiExamplesPlugin;
255+
}
256+
250257
export namespace HeyApiSchemas {
251258
export type Types = HeyApiSchemasPlugin;
252259
}

0 commit comments

Comments
 (0)