Skip to content

Commit c3e497c

Browse files
authored
Merge pull request #3638 from hey-api/docs/plugin-orpc
docs: add orpc docs
2 parents 725101a + c510098 commit c3e497c

24 files changed

Lines changed: 763 additions & 280 deletions

File tree

.changeset/five-crabs-relate.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(orpc)**: remove `base` export

dev/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@hey-api/openapi-python": "workspace:*",
1414
"@hey-api/openapi-ts": "workspace:*",
1515
"@opencode-ai/sdk": "1.2.27",
16-
"@orpc/contract": "1.13.4",
16+
"@orpc/contract": "1.13.9",
1717
"@pinia/colada": "0.19.1",
1818
"@tanstack/angular-query-experimental": "5.90.25",
1919
"@tanstack/preact-query": "5.93.0",

docs/.vitepress/config/en.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ export default defineConfig({
231231
link: '/openapi-ts/plugins/nest',
232232
text: 'Nest',
233233
},
234+
{
235+
link: '/openapi-ts/plugins/orpc',
236+
text: 'oRPC',
237+
},
234238
{
235239
link: '/openapi-ts/plugins/adonis',
236240
text: 'Adonis <span data-soon>soon</span>',
@@ -330,7 +334,7 @@ export default defineConfig({
330334
text: 'License',
331335
},
332336
{
333-
link: 'https://github.com/orgs/hey-api/discussions/1495',
337+
link: 'https://github.com/orgs/hey-api/discussions/3159',
334338
text: 'Roadmap',
335339
},
336340
],

docs/.vitepress/theme/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ html.dark .sponsors-list li {
303303
display: none;
304304
}
305305

306+
.vp-doc img {
307+
margin: 0;
308+
}
309+
306310
.authors-list li > a:hover,
307311
.authors-list li > a:focus,
308312
.sponsors-list li:has(> a:hover),

docs/data/people.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export const sebastiaanWouters: Person = {
2828
name: 'Sebastiaan Wouters',
2929
};
3030

31+
export const stephenZhou: Person = {
32+
github: 'https://github.com/hyoban',
33+
name: 'Stephen Zhou',
34+
};
35+
3136
export const yuriMikhin: Person = {
3237
github: 'https://github.com/mikhin',
3338
name: 'Yuri Mikhin',

docs/openapi-ts/plugins/angular/v19.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,5 @@ export default {
118118

119119
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.ts) interface.
120120

121-
<!--@include: ../../partials/examples.md-->
122-
<!--@include: ../../partials/sponsors.md-->
121+
<!--@include: ../../../partials/examples.md-->
122+
<!--@include: ../../../partials/sponsors.md-->

docs/openapi-ts/plugins/fastify.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ export default {
8787
output: 'src/client',
8888
plugins: [
8989
// ...other plugins
90-
{
91-
name: 'fastify',
92-
},
90+
'fastify',
9391
],
9492
};
9593
```

docs/openapi-ts/plugins/orpc.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
---
2+
title: oRPC v1 Plugin
3+
description: Generate oRPC v1 contracts from OpenAPI with the oRPC plugin for openapi-ts. Fully compatible with validators, transformers, and all core features.
4+
---
5+
6+
<script setup lang="ts">
7+
import AuthorsList from '@components/AuthorsList.vue';
8+
import Heading from '@components/Heading.vue';
9+
import { stephenZhou } from '@data/people.js';
10+
import VersionLabel from '@components/VersionLabel.vue';
11+
</script>
12+
13+
<Heading>
14+
<h1>oRPC<span class="sr-only"> v1</span></h1>
15+
<VersionLabel value="v1" />
16+
</Heading>
17+
18+
::: warning
19+
oRPC plugin 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).
20+
:::
21+
22+
### About
23+
24+
[oRPC](https://orpc.dev) combines RPC with OpenAPI, allowing you to define and call remote or local procedures through a type-safe API while adhering to the OpenAPI specification.
25+
26+
The oRPC plugin for Hey API generates contracts from your OpenAPI spec, fully compatible with all core features.
27+
28+
### Collaborators
29+
30+
<AuthorsList :people="[stephenZhou]" />
31+
32+
## Features
33+
34+
- oRPC v1 support
35+
- seamless integration with `@hey-api/openapi-ts` ecosystem
36+
- generated contracts
37+
- minimal learning curve thanks to extending the underlying technology
38+
39+
## Installation
40+
41+
In your [configuration](/openapi-ts/get-started), add `orpc` to your plugins and you'll be ready to generate oRPC artifacts. :tada:
42+
43+
```js
44+
export default {
45+
input: 'hey-api/backend', // sign up at app.heyapi.dev
46+
output: 'src/client',
47+
plugins: [
48+
// ...other plugins
49+
'orpc', // [!code ++]
50+
],
51+
};
52+
```
53+
54+
## Output
55+
56+
The oRPC plugin will generate the following artifacts, depending on the input specification.
57+
58+
## Contracts
59+
60+
Contracts are generated from all endpoints.
61+
62+
::: code-group
63+
64+
```js [example]
65+
import { oc } from '@orpc/contract';
66+
67+
const addPet = oc.route({
68+
description: 'Add a new pet to the store.',
69+
inputStructure: 'detailed',
70+
method: 'POST',
71+
operationId: 'addPet',
72+
path: '/pet',
73+
summary: 'Add a new pet to the store.',
74+
tags: ['pet'],
75+
});
76+
```
77+
78+
```js [config]
79+
export default {
80+
input: 'hey-api/backend', // sign up at app.heyapi.dev
81+
output: 'src/client',
82+
plugins: [
83+
// ...other plugins
84+
'orpc',
85+
],
86+
};
87+
```
88+
89+
:::
90+
91+
### Validators
92+
93+
To enable schema validation, set `validator` to `zod` or one of the available [validator plugins](/openapi-ts/validators). This will implicitly add the selected plugin with default values.
94+
95+
For a more granular approach, manually add a validator plugin and set `validator` to the plugin name or `true` to automatically select a compatible plugin. Until you customize the validator plugin, both approaches will produce the same default output.
96+
97+
::: code-group
98+
99+
```js [example]
100+
import { oc } from '@orpc/contract';
101+
102+
import { vAddPetData, vAddPetResponse } from './valibot.gen';
103+
104+
const addPet = oc
105+
.route({
106+
description: 'Add a new pet to the store.',
107+
inputStructure: 'detailed',
108+
method: 'POST',
109+
operationId: 'addPet',
110+
path: '/pet',
111+
summary: 'Add a new pet to the store.',
112+
tags: ['pet'],
113+
})
114+
.input(vAddPetData) // [!code ++]
115+
.output(vAddPetResponse); // [!code ++]
116+
```
117+
118+
```js [config]
119+
export default {
120+
input: 'hey-api/backend', // sign up at app.heyapi.dev
121+
output: 'src/client',
122+
plugins: [
123+
// ...other plugins
124+
{
125+
name: 'orpc',
126+
validator: true, // or 'valibot' // [!code ++]
127+
},
128+
{
129+
name: 'valibot', // customize (optional) // [!code ++]
130+
// other options
131+
},
132+
],
133+
};
134+
```
135+
136+
:::
137+
138+
You can choose to validate only inputs or outputs.
139+
140+
::: code-group
141+
142+
```js [inputs]
143+
export default {
144+
input: 'hey-api/backend', // sign up at app.heyapi.dev
145+
output: 'src/client',
146+
plugins: [
147+
// ...other plugins
148+
{
149+
name: 'orpc',
150+
validator: {
151+
input: 'zod', // [!code ++]
152+
},
153+
},
154+
],
155+
};
156+
```
157+
158+
```js [outputs]
159+
export default {
160+
input: 'hey-api/backend', // sign up at app.heyapi.dev
161+
output: 'src/client',
162+
plugins: [
163+
// ...other plugins
164+
{
165+
name: 'orpc',
166+
validator: {
167+
output: 'zod', // [!code ++]
168+
},
169+
},
170+
],
171+
};
172+
```
173+
174+
:::
175+
176+
Learn more about available validators on the [Validators](/openapi-ts/validators) page.
177+
178+
## API
179+
180+
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/orpc/types.ts) interface.
181+
182+
<!--@include: ../../partials/examples.md-->
183+
<!--@include: ../../partials/sponsors.md-->

docs/openapi-ts/plugins/transformers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,4 @@ export type GetFooResponse = Baz;
153153

154154
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/transformers/types.ts) interface.
155155

156-
<!--@include: ../partials/sponsors.md-->
156+
<!--@include: ../../partials/sponsors.md-->

docs/openapi-ts/web-frameworks.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Hey API natively supports the following frameworks.
1414
- [Angular](/openapi-ts/plugins/angular)
1515
- [Fastify](/openapi-ts/plugins/fastify)
1616
- [Nest](/openapi-ts/plugins/nest)
17+
- [oRPC](/openapi-ts/plugins/orpc)
1718
- [Adonis](/openapi-ts/plugins/adonis) <span data-soon>Soon</span>
1819
- [Elysia](/openapi-ts/plugins/elysia) <span data-soon>Soon</span>
1920
- [Express](/openapi-ts/plugins/express) <span data-soon>Soon</span>

0 commit comments

Comments
 (0)