Skip to content

[BUG][nodejs-express-server] npm start Error: openapi.validator: args.apiDoc was invalid. #7992

Open
@lidel

Description

@lidel

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
openapi-generator version

4.3.1

OpenAPI declaration file content or url
Generation Details

nodejs-express-server generates code fine, but npm start prints error:

Error: openapi.validator: args.apiDoc was invalid.  See the output.
    at OpenAPIFramework.initialize (/media/databank/tmp/scratch-2020-11-20-15:17:57/node_modules/express-openapi-validator/dist/framework/index.js:32:23)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async OpenApiSpecLoader.discoverRoutes (/media/databank/tmp/scratch-2020-11-20-15:17:57/node_modules/express-openapi-validator/dist/framework/openapi.spec.loader.js:47:39)
Listening on port 3000

Note that mentioned YAML passes validation done with github/super-linter

Steps to reproduce
$ openapi-generator-cli version
4.3.1
$ openapi-generator-cli generate -g nodejs-express-server -i https://raw.githubusercontent.com/ipfs/pinning-services-api-spec/v0.1.2/ipfs-pinning-service.yaml
$ npm start

> ipfs-pinning-service-api@0.1.2 prestart /media/databank/tmp/scratch-2020-11-20-15:17:57
> npm install


> deasync@0.1.21 install /media/databank/tmp/scratch-2020-11-20-15:17:57/node_modules/deasync
> node ./build.js

`linux-x64-node-12` exists; testing
Binary is fine; exiting
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.1 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 375 packages from 284 contributors and audited 377 packages in 10.4s

26 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


> ipfs-pinning-service-api@0.1.2 start /media/databank/tmp/scratch-2020-11-20-15:17:57
> node index.js

{"message":"Express server running","level":"info","service":"user-service","timestamp":"2020-11-20T14:22:34.253Z"}
info: Express server running {"service":"user-service","timestamp":"2020-11-20T14:22:34.253Z"}
openapi.validator: Validating schema
openapi.validator: validation errors [
  {
    "keyword": "required",
    "dataPath": ".paths['/pins']['get'].parameters[7]",
    "schemaPath": "#/definitions/SchemaXORContent/oneOf/0/required",
    "params": {
      "missingProperty": "schema"
    },
    "message": "should have required property 'schema'"
  },
  {
    "keyword": "not",
    "dataPath": ".paths['/pins']['get'].parameters[7]",
    "schemaPath": "#/definitions/SchemaXORContent/oneOf/1/allOf/0/not",
    "params": {},
    "message": "should NOT be valid"
  },
  {
    "keyword": "not",
    "dataPath": ".paths['/pins']['get'].parameters[7]",
    "schemaPath": "#/definitions/SchemaXORContent/oneOf/1/allOf/1/not",
    "params": {},
    "message": "should NOT be valid"
  },
  {
    "keyword": "oneOf",
    "dataPath": ".paths['/pins']['get'].parameters[7]",
    "schemaPath": "#/definitions/SchemaXORContent/oneOf",
    "params": {
      "passingSchemas": null
    },
    "message": "should match exactly one schema in oneOf"
  },
  {
    "keyword": "required",
    "dataPath": ".paths['/pins']['get'].parameters[7]",
    "schemaPath": "#/definitions/Reference/required",
    "params": {
      "missingProperty": "$ref"
    },
    "message": "should have required property '$ref'"
  },
  {
    "keyword": "oneOf",
    "dataPath": ".paths['/pins']['get'].parameters[7]",
    "schemaPath": "#/properties/parameters/items/oneOf",
    "params": {
      "passingSchemas": null
    },
    "message": "should match exactly one schema in oneOf"
  },
  {
    "keyword": "required",
    "dataPath": ".components.parameters['meta']",
    "schemaPath": "#/definitions/Reference/required",
    "params": {
      "missingProperty": "$ref"
    },
    "message": "should have required property '$ref'"
  },
  {
    "keyword": "required",
    "dataPath": ".components.parameters['meta']",
    "schemaPath": "#/definitions/SchemaXORContent/oneOf/0/required",
    "params": {
      "missingProperty": "schema"
    },
    "message": "should have required property 'schema'"
  },
  {
    "keyword": "not",
    "dataPath": ".components.parameters['meta']",
    "schemaPath": "#/definitions/SchemaXORContent/oneOf/1/allOf/0/not",
    "params": {},
    "message": "should NOT be valid"
  },
  {
    "keyword": "not",
    "dataPath": ".components.parameters['meta']",
    "schemaPath": "#/definitions/SchemaXORContent/oneOf/1/allOf/1/not",
    "params": {},
    "message": "should NOT be valid"
  },
  {
    "keyword": "oneOf",
    "dataPath": ".components.parameters['meta']",
    "schemaPath": "#/definitions/SchemaXORContent/oneOf",
    "params": {
      "passingSchemas": null
    },
    "message": "should match exactly one schema in oneOf"
  },
  {
    "keyword": "oneOf",
    "dataPath": ".components.parameters['meta']",
    "schemaPath": "#/properties/parameters/patternProperties/%5E%5Ba-zA-Z0-9%5C.%5C-_%5D%2B%24/oneOf",
    "params": {
      "passingSchemas": null
    },
    "message": "should match exactly one schema in oneOf"
  }
]
Error: openapi.validator: args.apiDoc was invalid.  See the output.
    at OpenAPIFramework.initialize (/media/databank/tmp/scratch-2020-11-20-15:17:57/node_modules/express-openapi-validator/dist/framework/index.js:32:23)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async OpenApiSpecLoader.discoverRoutes (/media/databank/tmp/scratch-2020-11-20-15:17:57/node_modules/express-openapi-validator/dist/framework/openapi.spec.loader.js:47:39)
Listening on port 3000
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions