Comments (7)
Experiencing a similar issue - but with yarn as package manager. Oddly it works when I install orval
6.30.2 as the only package in an isolated environment.
In my working environment however where we have quite many dependencies (angular
, cdk
, etc.) orval
refuses to start - even npx orval --help
fails with the same error as above. We also have ajv
as a dependency in our package.json and I tried to update this to the latest version but without any luck.
Can confirm that it worked quite well five days ago.
The stack trace refers to the @stoplight/spectral-core
module. When I do a yarn why
on this module it shows me some dependency to @ibm-cloud
:
info Reasons this module exists
- "orval#@orval#core#@ibm-cloud#openapi-ruleset#@stoplight#spectral-functions" depends on it
- Hoisted from "orval#@orval#core#@ibm-cloud#openapi-ruleset#@stoplight#spectral-functions#@stoplight#spectral-core"
- Hoisted from "orval#@orval#core#@ibm-cloud#openapi-ruleset#@stoplight#spectral-formats#@stoplight#spectral-core"
- Hoisted from "orval#@orval#core#@ibm-cloud#openapi-ruleset#@stoplight#spectral-rulesets#@stoplight#spectral-core"
not sure if this helps.
from orval.
Investigated a little further and was able to reproduce the issue with the following Dockerfile
FROM node:20
RUN echo '{\
"dependencies": {\
"@middy/validator": "5.4.0",\
"orval": "6.30.2"\
}\
}' > package.json
RUN yarn install
CMD ["npx", "orval", "--help"]
My guess is that it has something to do with the versions of ajv
. In my node_modules
folder the package.json
of orval
states ajv
as a dependency with the version ^8.12.0
, while the @middy/validator
package lists ajv
with version 8.14.0
.
The also somehow related @stoplight/spectral-core
package uses ^8.6.0
for ajv
.
from orval.
Is possibly related to:
Installing ajv
as a dev dependency did not resolve the error. Although, I did not call the bun equivalent of npm dedupe
after retrieving the package.
from orval.
yeah @cassis163 i think its definitely related to those.
from orval.
Hi, @cassis163
Hmm, what happens if you explicitly install "ajv"?
bun add -D ajv
bun run gen:api
from orval.
Hello @soartec-lab , still the same exact issue after bun add --dev ajv
.
➜ bun run gen:api
$ orval --config orval.config.ts
Error compiling schema, function code: const schema16 = scope.schema[10];return function validate14(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;if((!(data && typeof data == "object" && !Array.isArray(data))) && (data !== null)){const err0 = {instancePath,schemaPath:"#/type",keyword:"type",params:{type: schema16.type},message:"must be object,null"};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}if(data && typeof data == "object" && !Array.isArray(data)){for(const key0 in data){if(!(key0 === "keyedBy")){const err1 = {instancePath,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty: key0},message:"must NOT have additional properties"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}}if(data.keyedBy !== undefined){if(typeof data.keyedBy !== "string"){const err2 = {instancePath:instancePath+"/keyedBy",schemaPath:"#/properties/keyedBy/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}}if(errors > 0){const emErrors0 = {"type":[]};for(const err3 of vErrors){if(((((({"str":"err3"}.keyword !== "errorMessage") && (!{"str":"err3"}.emUsed)) && ({"str":"err3"}.instancePath === instancePath)) && ({"str":"err3"}.keyword in {"str":"emErrors0"})) && ({"str":"err3"}.schemaPath.indexOf("#") === 0)) && (/^\/[^\/]*$/.test({"str":"err3"}.schemaPath.slice(1)))){{"str":"emErrors0"}[{"str":"err3"}.keyword].push({"str":"err3"});{"str":"err3"}.emUsed = true;}}for(const key1 in emErrors0){if({"str":"emErrors0"}[{"str":"key1"}].length){if(vErrors === null){vErrors = [{"str":"err4"}];}else {vErrors.push({"str":"err4"});}errors++;}}const emErrs0 = [];for(const err5 of vErrors){if(!{"str":"err5"}.emUsed){{"str":"emErrs0"}.push({"str":"err5"});}}vErrors = emErrs0;errors = {"str":"emErrs0"}.length;}validate14.errors = vErrors;return errors === 0;}
/Users/me/Projects/project-x/frontend/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/index.js:120
throw e;
^
SyntaxError: Unexpected token ':'
at new Function (<anonymous>)
at Ajv.compileSchema (/Users/project/frontend/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/index.js:89:30)
at Ajv._compileSchemaEnv (/frontend/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/core.js:473:37)
at Ajv.compile (/project/frontend/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/core.js:160:38)
at createRulesetFunction (project-/node_modules/@stoplight/spectral-core/dist/ruleset/function.js:68:80)
at Object.<anonymous> (node_modules/@stoplight/spectral-functions/dist/alphabetical.js:30:61)
at Module._compile (node:internal/modules/cjs/loader:1434:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1518:10)
at Module.load (node:internal/modules/cjs/loader:1249:32)
at Module._load (node:internal/modules/cjs/loader:1065:12)
Node.js v22.2.0
error: script "gen:api" exited with code 1
from orval.
Oh...thanks for trying. Actually, I had the same problem and I solved it by explicitly installing ajv
. The problem has been resolved since v1.1.11
.
https://bun.sh/blog/bun-v1.1.11#fixed-bun-install-peer-dependencies-resolution
I haven't reproduced it in my project using Bun
v1.1.13 and orval
6.30.2.
from orval.
Related Issues (20)
- React Query keys no longer exported? HOT 3
- Setting delay to false generates invalid function
- Polymorphic mocks are not split when subclass is allOf instead of type: object
- Transformer function not outputting the desired type name HOT 4
- 'vue-query' generated query key getter code is inaccurate
- [Regression in 0.30] Using useQuery: true for POST request generates code that does not compile HOT 2
- Duplicate mock and MSW handler for status 200 when using generateEachHttpStatus=true HOT 2
- Missing import for enum with MSW mock generation
- Can not create examples with ref for mock HOT 1
- A better way to manage dynamic API url for Angular HTTP Client HOT 3
- File extension not applied to schemas generated files HOT 9
- Add the ability to import query hooks from a custom path HOT 1
- Use unknown instead of any for additional properties type HOT 3
- How to handle error response codes with fetch? HOT 4
- Vue Query: generates code that doesn't compile for vue-query HOT 4
- Docs incorrect for suppressReadonlyModifier
- mock does not generate correct bigint type HOT 3
- Provide mutator an option to get the original path or operation id
- Zod generate big files HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orval.