Git Product home page Git Product logo

Comments (7)

mmakulla-ci avatar mmakulla-ci commented on September 28, 2024 1

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.

mmakulla-ci avatar mmakulla-ci commented on September 28, 2024 1

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.

cassis163 avatar cassis163 commented on September 28, 2024

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.

melloware avatar melloware commented on September 28, 2024

yeah @cassis163 i think its definitely related to those.

from orval.

soartec-lab avatar soartec-lab commented on September 28, 2024

Hi, @cassis163
Hmm, what happens if you explicitly install "ajv"?

bun add -D ajv
bun run gen:api

from orval.

cassis163 avatar cassis163 commented on September 28, 2024

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.

soartec-lab avatar soartec-lab commented on September 28, 2024

@cassis163

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.