Skip to content

Commit 031696d

Browse files
committed
🎉 feat: 1.4.3
1 parent 480f7f7 commit 031696d

File tree

7 files changed

+189
-30
lines changed

7 files changed

+189
-30
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# 1.4.3 - 18 Sep 2025
2+
Improvement:
3+
- unwrap model reference into parameter schema
4+
- add warning for standard schema without `toJSONSchema` method
5+
- remove `Provider` from generic type to allow auto-completion
6+
- auto-completion for `mapJSONSchema`
7+
- log error when failed to OpenAPI JSON
8+
19
# 1.4.2 - 14 Sep 2025
210
Bug fix:
311
- remove xsschema from dependencies

bun.lock

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@
88
"@scalar/types": "^0.2.13",
99
"@sinclair/typemap": "^0.10.1",
1010
"@types/bun": "1.2.20",
11-
"elysia": "1.4.0",
11+
"effect": "^3.17.13",
12+
"elysia": "1.4.6",
1213
"eslint": "9.6.0",
1314
"openapi-types": "^12.1.3",
1415
"tsup": "^8.5.0",
1516
"typescript": "^5.9.2",
16-
"xsschema": "^0.4.0-beta.3",
1717
"zod": "^4.1.5",
1818
},
1919
"peerDependencies": {
2020
"elysia": ">= 1.4.0",
21-
"xsschema": ">= 0.4.0-beta.0",
2221
},
2322
},
2423
},
@@ -169,6 +168,8 @@
169168

170169
"@sinclair/typemap": ["@sinclair/[email protected]", "", { "peerDependencies": { "@sinclair/typebox": "^0.34.30", "valibot": "^1.0.0", "zod": "^3.24.1" } }, "sha512-UXR0fhu/n3c9B6lB+SLI5t1eVpt9i9CdDrp2TajRe3LbKiUhCTZN2kSfJhjPnpc3I59jMRIhgew7+0HlMi08mg=="],
171170

171+
"@standard-schema/spec": ["@standard-schema/[email protected]", "", {}, "sha512-m2bOd0f2RT9k8QJx1JN85cZYyH1RqFBdlwtkSlf4tBDYLCiiZnv1fIIwacK6cqwXavOydf0NPToMQgpKq+dVlA=="],
172+
172173
"@tokenizer/inflate": ["@tokenizer/[email protected]", "", { "dependencies": { "debug": "^4.4.0", "fflate": "^0.8.2", "token-types": "^6.0.0" } }, "sha512-MADQgmZT1eKjp06jpI2yozxaU9uVs4GzzgSL+uEq7bVcJ9V1ZXQkeGNql1fsSI0gMy1vhvNTNbUqrx+pZfJVmg=="],
173174

174175
"@tokenizer/token": ["@tokenizer/[email protected]", "", {}, "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A=="],
@@ -241,7 +242,9 @@
241242

242243
"eastasianwidth": ["[email protected]", "", {}, "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA=="],
243244

244-
"elysia": ["[email protected]", "", { "dependencies": { "cookie": "^1.0.2", "exact-mirror": "0.2.2", "fast-decode-uri-component": "^1.0.1" }, "optionalDependencies": { "@sinclair/typebox": ">= 0.34.0 < 1", "openapi-types": ">= 12.0.0" }, "peerDependencies": { "file-type": ">= 20.0.0", "typescript": ">= 5.0.0" } }, "sha512-AVEq8cWo7+fdkbUtqVXDZ7uhjjv8K6NE6bt9oSzdocaawsW5VhJP2ArPoRYkWdJPYmS4f2FI5xWF+Tvs98yXVw=="],
245+
"effect": ["[email protected]", "", { "dependencies": { "@standard-schema/spec": "^1.0.0", "fast-check": "^3.23.1" } }, "sha512-JMz5oBxs/6mu4FP9Csjub4jYMUwMLrp+IzUmSDVIzn2NoeoyOXMl7x1lghfr3dLKWffWrdnv/d8nFFdgrHXPqw=="],
246+
247+
"elysia": ["[email protected]", "", { "dependencies": { "cookie": "^1.0.2", "exact-mirror": "0.2.2", "fast-decode-uri-component": "^1.0.1" }, "optionalDependencies": { "@sinclair/typebox": ">= 0.34.0 < 1", "openapi-types": ">= 12.0.0" }, "peerDependencies": { "file-type": ">= 20.0.0", "typescript": ">= 5.0.0" } }, "sha512-u2CorXLPs5ZXyWP+tQR+bgka/lJA4vNpB8lDE2w/sTmdaIwoPQmHEL4J3ai6OAlluWR1kfG7T9gO3EYT9D8viQ=="],
245248

246249
"emoji-regex": ["[email protected]", "", {}, "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="],
247250

@@ -267,6 +270,8 @@
267270

268271
"exact-mirror": ["[email protected]", "", { "peerDependencies": { "@sinclair/typebox": "^0.34.15" }, "optionalPeers": ["@sinclair/typebox"] }, "sha512-CrGe+4QzHZlnrXZVlo/WbUZ4qQZq8C0uATQVGVgXIrNXgHDBBNFD1VRfssRA2C9t3RYvh3MadZSdg2Wy7HBoQA=="],
269272

273+
"fast-check": ["[email protected]", "", { "dependencies": { "pure-rand": "^6.1.0" } }, "sha512-h5+1OzzfCC3Ef7VbtKdcv7zsstUQwUDlYpUTvjeUsJAssPgLn7QzbboPtL5ro04Mq0rPOsMzl7q5hIbRs2wD1A=="],
274+
270275
"fast-decode-uri-component": ["[email protected]", "", {}, "sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg=="],
271276

272277
"fast-deep-equal": ["[email protected]", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="],
@@ -407,6 +412,8 @@
407412

408413
"punycode": ["[email protected]", "", {}, "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="],
409414

415+
"pure-rand": ["[email protected]", "", {}, "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA=="],
416+
410417
"queue-microtask": ["[email protected]", "", {}, "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="],
411418

412419
"readdirp": ["[email protected]", "", {}, "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg=="],
@@ -491,8 +498,6 @@
491498

492499
"wrap-ansi-cjs": ["[email protected]", "", { "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } }, "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q=="],
493500

494-
"xsschema": ["[email protected]", "", { "peerDependencies": { "@valibot/to-json-schema": "^1.0.0", "arktype": "^2.1.20", "effect": "^3.16.0", "sury": "^10.0.0", "zod": "^3.25.0 || ^4.0.0", "zod-to-json-schema": "^3.24.5" }, "optionalPeers": ["@valibot/to-json-schema", "arktype", "effect", "sury", "zod", "zod-to-json-schema"] }, "sha512-+vKxPksAH0QDk2YXRT25LY+Cn/lGJHiwC88Hb9BNl76Gso7VZYoOsq0T6nSoeSxKjyWRYCGmS6anrOhDQknasw=="],
495-
496501
"yocto-queue": ["[email protected]", "", {}, "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q=="],
497502

498503
"zod": ["[email protected]", "", {}, "sha512-5R1P+WwQqmmMIEACyzSvo4JXHY5WiAFHRMg+zBZKgKS+Q1viRa0C1hmUKtHltoIFKtIdki3pRxkmpP74jnNYHQ=="],

example/index.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Elysia, t } from 'elysia'
22
import z from 'zod'
3+
import { JSONSchema, Schema } from 'effect'
34

45
import { openapi, withHeaders } from '../src/index'
56

@@ -21,6 +22,10 @@ export const app = new Elysia()
2122
.use(
2223
openapi({
2324
provider: 'scalar',
25+
mapJsonSchema: {
26+
zod: z.toJSONSchema,
27+
effect: JSONSchema.make
28+
},
2429
documentation: {
2530
info: {
2631
title: 'Elysia Scalar',
@@ -49,6 +54,28 @@ export const app = new Elysia()
4954
})
5055
)
5156
.model({ schema, schema2, user })
57+
.model({
58+
idParam: t.Object({
59+
id: t.Union([
60+
t.String({ format: 'uuid' }),
61+
t.Number({ minimum: 1, maximum: Number.MAX_SAFE_INTEGER })
62+
]),
63+
id2: t.String()
64+
}),
65+
response200: t.Object({
66+
message: t.String(),
67+
content: t.Array(t.Object({
68+
id: t.Union([t.String(), t.Number()])
69+
}))
70+
})
71+
})
72+
.get('/test/:id/:id2', ({ params: { id } }) => ({
73+
message: 'ok',
74+
content: [{ id }]
75+
}), {
76+
params: 'idParam',
77+
response: 'response200'
78+
})
5279
.get(
5380
'/',
5481
{ test: 'hello' as const },
@@ -72,17 +99,24 @@ export const app = new Elysia()
7299
.post(
73100
'/json',
74101
({ body }) => ({
75-
test: 'world'
102+
test: 'hello'
76103
}),
77104
{
78105
parse: ['json', 'formdata'],
79106
body: 'schema',
80107
response: {
81-
200: 'schema',
108+
200: t.Object({
109+
test: t.Literal('hello')
110+
}),
82111
400: z.object({
83112
a: z.string(),
84113
b: z.literal('a')
85-
})
114+
}),
115+
401: Schema.standardSchemaV1(
116+
Schema.Struct({
117+
a: Schema.Literal('hi')
118+
})
119+
)
86120
}
87121
}
88122
)

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@elysiajs/openapi",
3-
"version": "1.4.2",
3+
"version": "1.4.3",
44
"description": "Plugin for Elysia to auto-generate API documentation",
55
"author": {
66
"name": "saltyAom",
@@ -79,7 +79,8 @@
7979
"@scalar/types": "^0.2.13",
8080
"@sinclair/typemap": "^0.10.1",
8181
"@types/bun": "1.2.20",
82-
"elysia": "1.4.0",
82+
"effect": "^3.17.13",
83+
"elysia": "1.4.6",
8384
"eslint": "9.6.0",
8485
"openapi-types": "^12.1.3",
8586
"tsup": "^8.5.0",

src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,19 @@ import type { ElysiaOpenAPIConfig, OpenAPIProvider } from './types'
1616
*/
1717
export const openapi = <
1818
const Enabled extends boolean = true,
19-
const Path extends string = '/openapi',
20-
const Provider extends OpenAPIProvider = 'scalar'
19+
const Path extends string = '/openapi'
2120
>({
2221
enabled = true as Enabled,
2322
path = '/openapi' as Path,
24-
provider = 'scalar' as Provider,
23+
provider = 'scalar',
2524
specPath = `${path}/json`,
2625
documentation = {},
2726
exclude,
2827
swagger,
2928
scalar,
3029
references,
3130
mapJsonSchema
32-
}: ElysiaOpenAPIConfig<Enabled, Path, Provider> = {}) => {
31+
}: ElysiaOpenAPIConfig<Enabled, Path> = {}) => {
3332
if (!enabled) return new Elysia({ name: '@elysiajs/openapi' })
3433

3534
const info = {
@@ -119,6 +118,10 @@ export const openapi = <
119118
} satisfies OpenAPIV3.Document)
120119
},
121120
{
121+
error({ error }) {
122+
console.log('[@elysiajs/openapi] error at specPath')
123+
console.warn(error)
124+
},
122125
detail: {
123126
hide: true
124127
}

0 commit comments

Comments
 (0)