Skip to content

Commit 4026955

Browse files
committed
feat: examples plugin
1 parent 493ee7c commit 4026955

24 files changed

Lines changed: 206 additions & 85 deletions

File tree

‎.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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const inputs = {
99
full: path.resolve(specsPath, '3.1.x', 'full.yaml'),
1010
'hey-api': 'hey-api/backend',
1111
local: 'http://localhost:8000/openapi.json',
12+
mockers: path.resolve(specsPath, '3.1.x', 'mockers.yaml'),
1213
opencode: path.resolve(specsPath, '3.1.x', 'opencode.yaml'),
1314
petstore:
1415
'https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml',
@@ -30,6 +31,7 @@ export const inputs = {
3031
'readme-uuid': 'readme:nysezql0wwo236',
3132
redfish:
3233
'https://raw.githubusercontent.com/DMTF/Redfish-Publications/refs/heads/main/openapi/openapi.yaml',
34+
rpc: path.resolve(specsPath, '3.1.x', 'rpc.yaml'),
3335
scalar: 'scalar:@scalar/access-service',
3436
transformers: path.resolve(specsPath, '3.1.x', 'transformers.json'),
3537
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: 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: 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
@@ -22,6 +22,7 @@ declare module '@hey-api/codegen-core' {
2222
| 'arktype'
2323
| 'fastify'
2424
| 'json-schema'
25+
| 'msw'
2526
| 'sdk'
2627
| 'typescript'
2728
| 'valibot'
@@ -61,6 +62,7 @@ declare module '@hey-api/shared' {
6162
'@hey-api/client-next': Plugins.HeyApiClientNext.Types['Types'];
6263
'@hey-api/client-nuxt': Plugins.HeyApiClientNuxt.Types['Types'];
6364
'@hey-api/client-ofetch': Plugins.HeyApiClientOfetch.Types['Types'];
65+
'@hey-api/examples': Plugins.HeyApiExamples.Types['Types'];
6466
'@hey-api/schemas': Plugins.HeyApiSchemas.Types['Types'];
6567
'@hey-api/sdk': Plugins.HeyApiSdk.Types['Types'];
6668
'@hey-api/transformers': Plugins.HeyApiTransformers.Types['Types'];
@@ -120,6 +122,7 @@ import type {
120122
HeyApiClientOfetchPlugin,
121123
OfetchClient as OfetchClientImp,
122124
} from './plugins/@hey-api/client-ofetch';
125+
import type { HeyApiExamplesPlugin } from './plugins/@hey-api/examples';
123126
import type { HeyApiSchemasPlugin } from './plugins/@hey-api/schemas';
124127
import type { HeyApiSdkPlugin } from './plugins/@hey-api/sdk';
125128
import type { HeyApiTransformersPlugin } from './plugins/@hey-api/transformers';
@@ -253,6 +256,10 @@ export namespace Plugins {
253256
export type Types = HeyApiClientOfetchPlugin;
254257
}
255258

259+
export namespace HeyApiExamples {
260+
export type Types = HeyApiExamplesPlugin;
261+
}
262+
256263
export namespace HeyApiSchemas {
257264
export type Types = HeyApiSchemasPlugin;
258265
}

0 commit comments

Comments
 (0)