Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to run openapi-cop TypeError: Cannot read property 'constructor' of null #405

Open
walles opened this issue Dec 13, 2022 · 1 comment

Comments

@walles
Copy link

walles commented Dec 13, 2022

Starting revision 5cb4e9f (from PR #404) in Docker (compose) I get the below output.

Note also that it exited with code 0 which is weird considering it didn't work.

Environment

DEFAULT_FORBID_ADDITIONAL_PROPERTIES=true
VERBOSE=true
TARGET=http://xxxxxx:5058
FILE=/api.yaml

api.yaml

Proprietary, sorry, can't post it.

Output

Note how everything here is .js and the line numbers not matching the .ts source code.

pfcapi-openapi-cop-1            | Validating against api.yaml ("PFC API", version: 1.0.0)
pfcapi-openapi-cop-1            | Additional properties will be forbidden by default. Existing `additionalProperties` settings in the OpenAPI document will NOT be overwritten.
pfcapi-openapi-cop-1            | Failed to run openapi-cop TypeError: Cannot read property 'constructor' of null
pfcapi-openapi-cop-1            |     at mapWalkObject (/openapi-cop-docker/src/util.js:209:19)
pfcapi-openapi-cop-1            |     at mapWalkObject (/openapi-cop-docker/src/util.js:210:28)
pfcapi-openapi-cop-1            |     at mapWalkObject (/openapi-cop-docker/src/util.js:210:28)
pfcapi-openapi-cop-1            |     at mapWalkObject (/openapi-cop-docker/src/util.js:210:28)
pfcapi-openapi-cop-1            |     at mapWalkObject (/openapi-cop-docker/src/util.js:210:28)
pfcapi-openapi-cop-1            |     at Object.mapWalkObject (/openapi-cop-docker/src/util.js:210:28)
pfcapi-openapi-cop-1            |     at prepareApiDocument (/openapi-cop-docker/src/app.js:184:21)
pfcapi-openapi-cop-1            |     at process._tickCallback (internal/process/next_tick.js:68:7)
pfcapi-openapi-cop-1            |     at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
pfcapi-openapi-cop-1            |     at startup (internal/bootstrap/node.js:283:19)
pfcapi-openapi-cop-1            |     at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
pfcapi-openapi-cop-1 exited with code 0
@pemcampos
Copy link

That happens when you have examples with null values.
In the function mapWalkObject just replace:
const value = obj[key];
with:
const value = obj[key]; if(!value) continue;
for a quick fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants