orval
orval copied to clipboard
OpenAPI spec parsing bug
What are the steps to reproduce this issue?
- Run Orval using an OpenAPI spec containing the following (sanitised) section. Only provide the input and output parameters on CLI.
{
"openapi": "3.0.1",
"info": {
"title": "API",
"description": "An API",
"termsOfService": "https://example.com",
"license": {
"name": "company",
"url": "https://www.example.com"
},
"version": "1.0.0"
},
"servers": [
{
"url": "https://dev.dev",
"description": "Generated server url"
}
],
"paths": {
"/api/v1/path/{additional}" : {
"get": {
"tags": [],
"summary": "Fetches",
"operationId": "getHierarchy_1",
"parameters": [
{
"name": "hierarchy",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "requestParameters",
"in": "query",
"required": true,
"schema": {
"$ref": "#/components/schemas/HierarchyRequestParams"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/ResponseWrapperHierarchyBean"
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/ResponseWrapperHierarchyBean"
}
}
}
}
}
}
},
"/api/v1/path1/{otherAdditional}" : {
"get": {
"tags": [],
"summary": "Fetches",
"operationId": "getHierarchy_2",
"parameters": [
{
"name": "requestParameters",
"in": "query",
"required": true,
"schema": {
"$ref": "#/components/schemas/HierarchyRequestParams"
}
}
],
"responses": {
"200": {
"description": "Success",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/ResponseWrapperHierarchyBean"
}
}
}
},
"404": {
"description": "Not Found",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/ResponseWrapperHierarchyBean"
}
}
}
}
},
"deprecated": true
}
}
}
}
What happens?
Orval fails to complete the generation process.
What were you expecting to happen?
Orval should have completed the generation process successfully.
Any logs, error output, etc?
api - Error: The path params level can't be found in parameters (getHierarchy_2)
at /users/dev/app/node_modules/@orval/core/dist/index.js:49180:13
at Array.map (<anonymous>)
at getParams (/users/dev/app/node_modules/@orval/core/dist/index.js:49171:17)
at generateVerbOptions (/users/dev/app/node_modules/@orval/core/dist/index.js:50418:18)
at /users/dev/app/node_modules/@orval/core/dist/index.js:50502:33
at asyncReduce (/users/dev/app/node_modules/@orval/core/dist/index.js:47318:24)
at generateVerbsOptions (/users/dev/app/node_modules/@orval/core/dist/index.js:50498:7)
at api.operations (/users/dev/app/node_modules/orval/dist/bin/orval.js:3429:70)
at asyncReduce (/users/dev/app/node_modules/@orval/core/dist/index.js:47318:24)
at async getApiBuilder (/users/dev/app/node_modules/orval/dist/bin/orval.js:3413:15)
Any other comments?
I had a conversation about this on the Orval DIscord on August 23 2024 (username: helveticDev).
The OpenAPI spec validates and works without issues with npx openapi-typescript
.
What versions are you using?
System:
OS: macOS 14.6.1
CPU: (8) arm64 Apple M2
Memory: 44.64 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
npmPackages:
msw: ^2.3.1 => 2.3.1
orval: ^7.0.1 => 7.0.1
react: ^18.3.1 => 18.3.1