Repository navigation
Closed
Labels
pending triageNot looked at by a maintainer yet
Description
Environment
- Node.js: 24.11.1
- Nuxt: 4.2.2
- nitropack: 2.12.9
Reproduction
- Enable OpenAPI feature (set
experimental.openAPItotrue) - Write OpenAPI meta within
defineRouteMetathat contains falsy value (ex.0,"") inenumdefineRouteMeta({ openAPI: { parameters: [ { in: 'query', name: 'val', schema: { type: 'integer', enum: [0, 1, 2, 3, 4] }, }, ], }, });
- Launch server and access to
/_openapi.json
Describe the bug
OpenAPI json does not contain falsy value in enum.
{
"openapi": "3.1.0",
"info": {
"title": "Nitro Server Routes"
},
"servers": [
{
"url": "http://localhost:3000",
"description": "Local Development Server",
"variables": {}
}
],
"paths": {
"/": {
"get": {
"tags": [
"App Routes"
],
"parameters": [
{
"in": "query",
"name": "val",
"schema": {
"type": "integer",
"enum": [
// missing 0!!!
1,
2,
3,
4
]
}
}
],
"responses": {
"200": {
"description": "OK"
}
}
}
}
// snipped...
}
}Additional context
This bug is caused by using filter(Boolean) for filtering in the astToObject function.
- https://github.com/nitrojs/nitro/blob/v2.12.9/src/rollup/plugins/handlers-meta.ts
- https://github.com/nitrojs/nitro/blob/main/src/build/plugins/route-meta.ts
function astToObject(node: Expression | Literal): any {
switch (node.type) {
case "ObjectExpression": {
const obj: Record<string, any> = {};
for (const prop of node.properties) {
if (prop.type === "Property") {
const key = (prop.key as any).name ?? (prop.key as any).value;
obj[key] = astToObject(prop.value as any);
}
}
return obj;
}
case "ArrayExpression": {
// filter(Boolean) rejects all falsy value (0, "", NaN...)
return node.elements.map((el) => astToObject(el as any)).filter(Boolean);
// To exclude null and undefined only, use:
return node.elements.map((el) => astToObject(el as any)).filter(o => o != null);
}
case "Literal": {
return node.value;
}
// No default
}
}Logs
Reacted by coderabbitai
Metadata
Metadata
Assignees
Labels
pending triageNot looked at by a maintainer yet
Activity
coderabbitai commentedon Dec 22, 2025
🔗 Similar Issues
Related Issues
typeFromproperty not used to generate declaration files #3669👤 Suggested Assignees
Enable issue planning
To enable issue planning, add the following to your
.coderabbit.yaml:You can then request a plan by commenting
@coderabbitai planon any issue.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord or schedule a call!
nogic1008 commentedon Jan 19, 2026
@pi0 Please reopen this issue because #3895 (PR for v2) has not merged yet