Remco75 / openapi-test-generator

Uses some other known modules out there to generate a test suite with request-mock data for your openAPI spec (fka swagger)
9 stars 3 forks source link

TypeError: Cannot read property '$ref' of null #1

Open mccataldo opened 7 years ago

mccataldo commented 7 years ago

When trying to use this for the first time, I get the following. I can provide more info if necessary:

node index.js
/Users/mikecataldo/code/swaggerTT/node_modules/json-schema-faker/lib/jsf.js:76
      throw e;
      ^

TypeError: Cannot read property '$ref' of null
    at reduce (/Users/mikecataldo/code/swaggerTT/node_modules/json-schema-faker/lib/jsf.js:20:19)
    at reduce (/Users/mikecataldo/code/swaggerTT/node_modules/json-schema-faker/lib/jsf.js:66:23)
    at reduce (/Users/mikecataldo/code/swaggerTT/node_modules/json-schema-faker/lib/jsf.js:66:23)

    at reduce (/Users/mikecataldo/code/swaggerTT/node_modules/json-schema-faker/lib/jsf.js:66:23)
    at reduce (/Users/mikecataldo/code/swaggerTT/node_modules/json-schema-faker/lib/jsf.js:66:23)
    at traverse (/Users/mikecataldo/code/swaggerTT/node_modules/json-schema-faker/lib/util/traverse.js:10:3)
    at module.exports (/Users/mikecataldo/code/swaggerTT/node_modules/json-schema-faker/lib/util/traverse.js:61:19)
    at generate (/Users/mikecataldo/code/swaggerTT/node_modules/json-schema-faker/lib/jsf.js:19:12)
    at generate (/Users/mikecataldo/code/swaggerTT/node_modules/json-schema-test-data-generator/dist/index.js:439:20)
    at /Users/mikecataldo/code/swaggerTT/node_modules/open-api-test-generator/src/generateRequestMocks.js:37:61
    at Array.forEach (native)
    at generateRequestMock (/Users/mikecataldo/code/swaggerTT/node_modules/open-api-test-generator/src/generateRequestMocks.js:36:6
2)
    at /Users/mikecataldo/code/swaggerTT/node_modules/open-api-test-generator/src/index.js:25:82
    at Array.forEach (native)
    at Object.generate (/Users/mikecataldo/code/swaggerTT/node_modules/open-api-test-generator/src/index.js:23:19)
    at Object.<anonymous> (/Users/mikecataldo/code/swaggerTT/index.js:11:11)
Remco75 commented 7 years ago

hmm, it seems it doesn't deref your swagger spec. Can you post the swagger spec you are using?

mccataldo commented 7 years ago

It's a very big and complex spec. Let me try with a simpler spec with refs and see what happens.

Remco75 commented 7 years ago

ok, let me know how it goes. The issue you have with de-reffing your spec so that we have all the data we need at runtime. So check if your json -refs are complete -> if not it will fail. Also your spec needs to be valid: there's tools to check this online (but I don't think that is the issue you are having at this point)