question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upgrade from 6.5.3 to 6.6.0 breaks generation

See original GitHub issue

Just run Orval generation

Error compiling schema, function code: const schema19 = scope.schema[13];const schema20 = scope.schema[14];const pattern0 = scope.pattern[0];return function validate17(data, {instancePath="", parentData, parentDataProperty, rootData=data}={}){let vErrors = null;let errors = 0;const _errs0 = errors;let valid0 = true;const _errs1 = errors;if(!(Array.isArray(data))){const err0 = {};if(vErrors === null){vErrors = [err0];}else {vErrors.push(err0);}errors++;}var _valid0 = _errs1 === errors;errors = _errs0;if(vErrors !== null){if(_errs0){vErrors.length = _errs0;}else {vErrors = null;}}let ifClause0;if(_valid0){const _errs3 = errors;if(Array.isArray(data)){if(data.length < 1){const err1 = {instancePath,schemaPath:"#/then/minItems",keyword:"minItems",params:{limit: 1},message:"must NOT have fewer than 1 items"};if(vErrors === null){vErrors = [err1];}else {vErrors.push(err1);}errors++;}const len0 = data.length;for(let i0=0; i0<len0; i0++){let data0 = data[i0];if(typeof data0 === "string"){if(!pattern0.test(data0)){const err2 = {instancePath:instancePath+"/" + i0,schemaPath:"path-expression/pattern",keyword:"pattern",params:{pattern: "^[$#]"},message:"must match pattern \""+"^[$#]"+"\""};if(vErrors === null){vErrors = [err2];}else {vErrors.push(err2);}errors++;}}else {const err3 = {instancePath:instancePath+"/" + i0,schemaPath:"path-expression/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err3];}else {vErrors.push(err3);}errors++;}if(errors > 0){for(const err4 of vErrors){if((((({"str":"err4"}.keyword !== "errorMessage") && (!{"str":"err4"}.emUsed)) && (({"str":"err4"}.instancePath === instancePath+{"_items":["\"/\" + ",{"str":"i0"},""]}) || (({"str":"err4"}.instancePath.indexOf(instancePath+{"_items":["\"/\" + ",{"str":"i0"},""]}) === 0) && ({"str":"err4"}.instancePath[instancePath+{"_items":["\"/\" + ",{"str":"i0"},""]}.length] === "/")))) && ({"str":"err4"}.schemaPath.indexOf("path-expression") === 0)) && ({"str":"err4"}.schemaPath["path-expression".length] === "/")){{"str":"emErrs0"}.push({"str":"err4"});{"str":"err4"}.emUsed = true;}}if({"str":"emErrs0"}.length){if(vErrors === null){vErrors = [{"str":"err5"}];}else {vErrors.push({"str":"err5"});}errors++;}const emErrs1 = [];for(const err6 of vErrors){if(!{"str":"err6"}.emUsed){{"str":"emErrs1"}.push({"str":"err6"});}}vErrors = emErrs1;errors = {"str":"emErrs1"}.length;}}}else {const err7 = {instancePath,schemaPath:"#/then/type",keyword:"type",params:{type: "array"},message:"must be array"};if(vErrors === null){vErrors = [err7];}else {vErrors.push(err7);}errors++;}if(errors > 0){const emErrors0 = {"minItems":[]};for(const err8 of vErrors){if(((((({"str":"err8"}.keyword !== "errorMessage") && (!{"str":"err8"}.emUsed)) && ({"str":"err8"}.instancePath === instancePath)) && ({"str":"err8"}.keyword in {"str":"emErrors0"})) && ({"str":"err8"}.schemaPath.indexOf("#/then") === 0)) && (/^\/[^\/]*$/.test({"str":"err8"}.schemaPath.slice(6)))){{"str":"emErrors0"}[{"str":"err8"}.keyword].push({"str":"err8"});{"str":"err8"}.emUsed = true;}}for(const key0 in emErrors0){if({"str":"emErrors0"}[{"str":"key0"}].length){if(vErrors === null){vErrors = [{"str":"err9"}];}else {vErrors.push({"str":"err9"});}errors++;}}const emErrs2 = [];for(const err10 of vErrors){if(!{"str":"err10"}.emUsed){{"str":"emErrs2"}.push({"str":"err10"});}}vErrors = emErrs2;errors = {"str":"emErrs2"}.length;}var _valid0 = _errs3 === errors;valid0 = _valid0;ifClause0 = "then";}else {const _errs8 = errors;if(typeof data === "string"){if(!pattern0.test(data)){const err11 = {instancePath,schemaPath:"path-expression/pattern",keyword:"pattern",params:{pattern: "^[$#]"},message:"must match pattern \""+"^[$#]"+"\""};if(vErrors === null){vErrors = [err11];}else {vErrors.push(err11);}errors++;}}else {const err12 = {instancePath,schemaPath:"path-expression/type",keyword:"type",params:{type: "string"},message:"must be string"};if(vErrors === null){vErrors = [err12];}else {vErrors.push(err12);}errors++;}if(errors > 0){for(const err13 of vErrors){if((((({"str":"err13"}.keyword !== "errorMessage") && (!{"str":"err13"}.emUsed)) && (({"str":"err13"}.instancePath === instancePath) || (({"str":"err13"}.instancePath.indexOf(instancePath) === 0) && ({"str":"err13"}.instancePath[instancePath.length] === "/")))) && ({"str":"err13"}.schemaPath.indexOf("path-expression") === 0)) && ({"str":"err13"}.schemaPath["path-expression".length] === "/")){{"str":"emErrs3"}.push({"str":"err13"});{"str":"err13"}.emUsed = true;}}if({"str":"emErrs3"}.length){if(vErrors === null){vErrors = [{"str":"err14"}];}else {vErrors.push({"str":"err14"});}errors++;}const emErrs4 = [];for(const err15 of vErrors){if(!{"str":"err15"}.emUsed){{"str":"emErrs4"}.push({"str":"err15"});}}vErrors = emErrs4;errors = {"str":"emErrs4"}.length;}var _valid0 = _errs8 === errors;valid0 = _valid0;ifClause0 = "else";}if(!valid0){const err16 = {instancePath,schemaPath:"#/if",keyword:"if",params:{failingKeyword: ifClause0},message:"must match \""+ifClause0+"\" schema"};if(vErrors === null){vErrors = [err16];}else {vErrors.push(err16);}errors++;}validate17.errors = vErrors;return errors === 0;}
/Users/user/dev/project/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/user/dev/project/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/index.js:89:30)
    at Ajv.inlineOrCompile (/Users/user/dev/project/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/index.js:148:47)
    at Ajv.resolveRef (/Users/user/dev/project/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/index.js:142:46)
    at Object.code (/Users/user/dev/project/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/vocabularies/core/ref.js:19:47)
    at keywordCode (/Users/user/dev/project/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/validate/index.js:454:13)
    at /Users/user/dev/project/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/validate/index.js:185:25
    at CodeGen.code (/Users/user/dev/project/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/codegen/index.js:439:13)
    at CodeGen.block (/Users/user/dev/project/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/codegen/index.js:568:18)
    at schemaKeywords (/Users/user/dev/project/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/validate/index.js:185:13)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jvandenaardwegcommented, Aug 31, 2022

Unfortunately, deleting the yarn.lock file does not work in my case with the latest version of Orval (6.9.6) using a OpenAPI spec that is validated correctly.

The only way to fix it is yarn add ajv, which should not be needed imo. Can this issue be re-opened @anymaniax ?

Using: node 16.17.0 npm 8.15.0 yarn 1.22.19 orval 6.9.6 (latest version as of writing this comment)

Error:

❯ yarn generate-api
yarn run v1.22.19
$ orval
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/jordy/Projects/X/X/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/jordy/Projects/X/X/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/compile/index.js:89:30)
    at Ajv._compileSchemaEnv (/Users/jordy/Projects/X/X/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/core.js:472:37)
    at Ajv.compile (/Users/jordy/Projects/X/X/node_modules/@stoplight/spectral-core/node_modules/ajv/dist/core.js:159:38)
    at createRulesetFunction (/Users/jordy/Projects/X/X/node_modules/@stoplight/spectral-core/dist/ruleset/function.js:54:80)
    at Object.<anonymous> (/Users/jordy/Projects/X/X/node_modules/@stoplight/spectral-functions/dist/alphabetical.js:30:61)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
1reaction
jogelincommented, Feb 15, 2022

I deleted the yarn.lock and recreate it and it works now. I think I had a previous version still locked

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade from older OCCT versions - Open CASCADE ...
Upgrade to OCCT 6.5.3. Porting of user applications from an earlier OCCT version to version 6.5.3 requires taking into account the following major...
Read more >
VMware ESXi 6.5 Update 3 Release Notes
This issue is resolved in this release. The fix restores the network connectivity after the filter creation. PR 2260907: vSphere Web Client becomes...
Read more >
Cisco Firepower Release Notes, Version 6.6 - Upgrade the ...
You can upgrade directly to Version 6.6 as follows. If you are patching Version 6.6, note that patches change the fourth digit only....
Read more >
How to easily update your VMware vCenter Server Appliance ...
At a minimum, do a snapshot (or backup) of this VCSA VM before upgrading, then make sure everything works alright after the upgrade,...
Read more >
About upgrading to 9.0 READ THIS FIRST
Follow the guidance for these critical items to avoid breaking your existing installation during an upgrade. Splunk Enterprise 9.0.2 changes the default value ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found