Skip to content

Commit f445766

Browse files
authored
Merge pull request #160 from bufferings/work
Add std-schema-openapi-plugin and various improvements
2 parents 4edcd4b + 409ab96 commit f445766

File tree

145 files changed

+1466
-9965
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

145 files changed

+1466
-9965
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@korix/std-schema-openapi-plugin': minor
3+
'@korix/std-schema-adapter': minor
4+
---
5+
6+
Add Standard Schema packages
7+
8+
- Add std-schema-openapi-plugin for Standard JSON Schema support
9+
- Rename standard-schema-adapter to std-schema-adapter
10+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@korix/kori': patch
3+
---
4+
5+
Consolidate error classes into KoriError with KoriErrorCode
6+
7+
Replace individual error classes with unified KoriError and KoriErrorCode constants:
8+
9+
- Remove KoriCookieError, KoriResponseBuildError, KoriSetCookieHeaderError, KoriValidationConfigError
10+
- Add KoriErrorCode with predefined error codes
11+
- Make KoriError.code parameter required

.github/workflows/release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ jobs:
1515
timeout-minutes: 15
1616

1717
permissions:
18-
pull-requests: write
1918
contents: write
19+
pull-requests: write
20+
id-token: write
2021

2122
steps:
2223
- name: Checkout Repo
@@ -29,6 +30,9 @@ jobs:
2930
with:
3031
node-version: 20
3132

33+
- name: Update npm for OIDC
34+
run: npm install -g npm@latest
35+
3236
- name: Install pnpm
3337
uses: pnpm/action-setup@v4
3438
with:
@@ -69,4 +73,3 @@ jobs:
6973
publish: pnpm changeset:publish
7074
env:
7175
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ A modern, type-safe web framework for TypeScript, built on [Hono](https://hono.d
66

77
- Fast and lightweight routing powered by Hono's router
88
- TypeScript type inference throughout your application
9-
- Request and response validation with Zod schemas
10-
- OpenAPI specification generation from Zod schemas
9+
- Request and response validation with Standard Schema (Zod, Valibot, ArkType, etc.)
10+
- OpenAPI specification generation from Standard JSON Schema
1111
- Extensible plugin architecture
1212

1313
Kori also supports Standard Schema for validation with other schema libraries.
@@ -104,24 +104,30 @@ Server log output:
104104

105105
## With Request Validation
106106

107-
Let's create a user API with request validation:
107+
Let's create a user API with request validation.
108+
109+
Supported libraries ([Standard Schema](https://standardschema.dev/) compliant):
110+
111+
- Zod 4.0+
112+
- Valibot 1.0+
113+
- ArkType 2.0+
108114

109115
```bash
110-
npm install @korix/zod-schema-adapter zod
116+
npm install @korix/std-schema-adapter @standard-schema/spec zod
111117
```
112118

113119
```typescript
114120
import { createKori } from '@korix/kori';
115121
import { startNodejsServer } from '@korix/nodejs-server';
116-
import { zodRequestSchema, enableZodRequestValidation } from '@korix/zod-schema-adapter';
122+
import { stdRequestSchema, enableStdRequestValidation } from '@korix/std-schema-adapter';
117123
import { z } from 'zod';
118124

119125
const app = createKori({
120-
...enableZodRequestValidation(),
126+
...enableStdRequestValidation(),
121127
});
122128

123129
app.post('/users', {
124-
requestSchema: zodRequestSchema({
130+
requestSchema: stdRequestSchema({
125131
body: z.object({
126132
name: z.string(),
127133
age: z.number(),
@@ -166,21 +172,21 @@ You can also add response schema validation to catch unexpected responses. By de
166172
```typescript
167173
import { createKori } from '@korix/kori';
168174
import { startNodejsServer } from '@korix/nodejs-server';
169-
import { zodRequestSchema, zodResponseSchema, enableZodRequestAndResponseValidation } from '@korix/zod-schema-adapter';
175+
import { stdRequestSchema, stdResponseSchema, enableStdRequestAndResponseValidation } from '@korix/std-schema-adapter';
170176
import { z } from 'zod';
171177

172178
const app = createKori({
173-
...enableZodRequestAndResponseValidation(),
179+
...enableStdRequestAndResponseValidation(),
174180
});
175181

176182
app.post('/users', {
177-
requestSchema: zodRequestSchema({
183+
requestSchema: stdRequestSchema({
178184
body: z.object({
179185
name: z.string(),
180186
age: z.number(),
181187
}),
182188
}),
183-
responseSchema: zodResponseSchema({
189+
responseSchema: stdResponseSchema({
184190
'201': z.object({
185191
id: z.number(),
186192
name: z.string(),
@@ -233,7 +239,7 @@ Server log output:
233239
"body": {
234240
"stage": "validation",
235241
"reason": {
236-
"provider": "zod",
242+
"provider": "standard-schema",
237243
"type": "Validation",
238244
"message": "Validation error",
239245
"issues": [
@@ -252,34 +258,40 @@ Server log output:
252258

253259
## And OpenAPI
254260

255-
Generate OpenAPI documentation from your validation schemas:
261+
Generate OpenAPI 3.1.0 documentation from your validation schemas.
262+
263+
Supported libraries ([Standard JSON Schema](https://standardschema.dev/json-schema) compliant):
264+
265+
- Zod 4.2+
266+
- ArkType 2.1.28+
267+
- Valibot 1.2+ (requires `@valibot/to-json-schema` v1.5+)
256268

257269
```bash
258-
npm install @korix/zod-openapi-plugin @korix/openapi-swagger-ui-plugin
270+
npm install @korix/std-schema-openapi-plugin @korix/openapi-swagger-ui-plugin
259271
```
260272

261273
```typescript
262274
import { createKori } from '@korix/kori';
263275
import { startNodejsServer } from '@korix/nodejs-server';
264276
import { swaggerUiPlugin } from '@korix/openapi-swagger-ui-plugin';
265-
import { zodOpenApiPlugin } from '@korix/zod-openapi-plugin';
266-
import { zodRequestSchema, zodResponseSchema, enableZodRequestAndResponseValidation } from '@korix/zod-schema-adapter';
277+
import { stdRequestSchema, stdResponseSchema, enableStdRequestAndResponseValidation } from '@korix/std-schema-adapter';
278+
import { stdSchemaOpenApiPlugin } from '@korix/std-schema-openapi-plugin';
267279
import { z } from 'zod';
268280

269281
const app = createKori({
270-
...enableZodRequestAndResponseValidation(),
282+
...enableStdRequestAndResponseValidation(),
271283
})
272-
.applyPlugin(zodOpenApiPlugin({ info: { title: 'My API', version: '1.0.0' } }))
284+
.applyPlugin(stdSchemaOpenApiPlugin({ info: { title: 'My API', version: '1.0.0' } }))
273285
.applyPlugin(swaggerUiPlugin());
274286

275287
app.post('/users', {
276-
requestSchema: zodRequestSchema({
288+
requestSchema: stdRequestSchema({
277289
body: z.object({
278290
name: z.string(),
279291
age: z.number(),
280292
}),
281293
}),
282-
responseSchema: zodResponseSchema({
294+
responseSchema: stdResponseSchema({
283295
'201': z.object({
284296
id: z.number(),
285297
name: z.string(),
@@ -307,9 +319,8 @@ Now you can visit http://localhost:3000/docs for interactive API documentation.
307319

308320
- [`@korix/kori`](./packages/kori) - Core framework
309321
- [`@korix/nodejs-server`](./packages/nodejs-server) - Node.js HTTP server adapter
310-
- [`@korix/zod-schema-adapter`](./packages/zod-schema-adapter) - Zod schema adapter for request and response validation
311-
- [`@korix/standard-schema-adapter`](./packages/standard-schema-adapter) - Standard Schema adapter for validation with other schema libraries
312-
- [`@korix/zod-openapi-plugin`](./packages/zod-openapi-plugin) - OpenAPI document generation from Zod schemas
322+
- [`@korix/std-schema-adapter`](./packages/std-schema-adapter) - Standard Schema adapter for validation (Zod, Valibot, ArkType, etc.)
323+
- [`@korix/std-schema-openapi-plugin`](./packages/std-schema-openapi-plugin) - OpenAPI document generation from Standard JSON Schema
313324
- [`@korix/openapi-swagger-ui-plugin`](./packages/openapi-swagger-ui-plugin) - Interactive API documentation with Swagger UI
314325

315326
[View all packages →](./packages)

docs/.vitepress/config.js

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -53,40 +53,6 @@ export default defineConfig({
5353
{ text: 'OpenAPI Integration', link: '/en/guide/openapi' },
5454
],
5555
},
56-
// {
57-
// text: 'Core API',
58-
// collapsed: true,
59-
// items: [
60-
// { text: 'Kori', link: '/en/core/kori' },
61-
// { text: 'Instance Context', link: '/en/core/instance-context' },
62-
// { text: 'Handler Context', link: '/en/core/handler-context' },
63-
// { text: 'Request', link: '/en/core/request' },
64-
// { text: 'Response', link: '/en/core/response' },
65-
// ],
66-
// },
67-
// {
68-
// text: 'Extensions',
69-
// collapsed: true,
70-
// items: [
71-
// { text: 'Zod Schema', link: '/en/extensions/zod-schema' },
72-
// { text: 'Zod Validation', link: '/en/extensions/zod-validation' },
73-
// { text: 'Zod OpenAPI Plugin', link: '/en/extensions/zod-openapi-plugin' },
74-
// { text: 'CORS Plugin', link: '/en/extensions/cors-plugin' },
75-
// { text: 'Body Limit Plugin', link: '/en/extensions/body-limit-plugin' },
76-
// { text: 'Security Headers Plugin', link: '/en/extensions/security-headers-plugin' },
77-
// { text: 'File Plugin', link: '/en/extensions/file-plugin' },
78-
// ],
79-
// },
80-
// {
81-
// text: 'Examples',
82-
// collapsed: true,
83-
// items: [
84-
// { text: 'Basic Server', link: '/en/examples/basic-server' },
85-
// { text: 'REST API', link: '/en/examples/rest-api' },
86-
// { text: 'File Upload', link: '/en/examples/file-upload' },
87-
// { text: 'WebSocket', link: '/en/examples/websocket' },
88-
// ],
89-
// },
9056
],
9157
'/ja/': [
9258
{
@@ -115,40 +81,6 @@ export default defineConfig({
11581
{ text: 'OpenAPI統合', link: '/ja/guide/openapi' },
11682
],
11783
},
118-
// {
119-
// text: 'コアAPI',
120-
// collapsed: true,
121-
// items: [
122-
// { text: 'Kori', link: '/ja/core/kori' },
123-
// { text: 'インスタンスコンテキスト', link: '/ja/core/instance-context' },
124-
// { text: 'ハンドラーコンテキスト', link: '/ja/core/handler-context' },
125-
// { text: 'リクエスト', link: '/ja/core/request' },
126-
// { text: 'レスポンス', link: '/ja/core/response' },
127-
// ],
128-
// },
129-
// {
130-
// text: '拡張機能',
131-
// collapsed: true,
132-
// items: [
133-
// { text: 'Zodスキーマ', link: '/ja/extensions/zod-schema' },
134-
// { text: 'Zodバリデーション', link: '/ja/extensions/zod-validation' },
135-
// { text: 'Zod OpenAPIプラグイン', link: '/ja/extensions/zod-openapi-plugin' },
136-
// { text: 'CORSプラグイン', link: '/ja/extensions/cors-plugin' },
137-
// { text: 'ボディ制限プラグイン', link: '/ja/extensions/body-limit-plugin' },
138-
// { text: 'セキュリティヘッダープラグイン', link: '/ja/extensions/security-headers-plugin' },
139-
// { text: 'ファイルプラグイン', link: '/ja/extensions/file-plugin' },
140-
// ],
141-
// },
142-
// {
143-
// text: '例',
144-
// collapsed: true,
145-
// items: [
146-
// { text: '基本的なサーバー', link: '/ja/examples/basic-server' },
147-
// { text: 'REST API', link: '/ja/examples/rest-api' },
148-
// { text: 'ファイルアップロード', link: '/ja/examples/file-upload' },
149-
// { text: 'WebSocket', link: '/ja/examples/websocket' },
150-
// ],
151-
// },
15284
],
15385
},
15486

@@ -158,18 +90,12 @@ export default defineConfig({
15890
nav: [
15991
{ text: 'Home', link: '/en/' },
16092
{ text: 'Guide', link: '/en/guide/what-is-kori' },
161-
// { text: 'Core', link: '/en/core/' },
162-
// { text: 'Extensions', link: '/en/extensions/' },
163-
// { text: 'Examples', link: '/en/examples/' },
16493
],
16594
},
16695
ja: {
16796
nav: [
16897
{ text: 'ホーム', link: '/ja/' },
16998
{ text: 'ガイド', link: '/ja/guide/what-is-kori' },
170-
// { text: 'コア', link: '/ja/core/' },
171-
// { text: '拡張機能', link: '/ja/extensions/' },
172-
// { text: '例', link: '/ja/examples/' },
17399
],
174100
},
175101
},

0 commit comments

Comments
 (0)