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.

express-openapi-validator and swagger-jsdoc?

See original GitHub issue

Is it possible to combine swagger-jsdoc with express-openapi-validator?

The following code:

var schema = swaggerJsdoc( {
    swaggerDefinition: {
      openapi: '3.0.0',
      info: {
        title: 'Title',
          description: 'API',
          version: '1.0.0',
       },
       servers: [{url: '/'}]
    },
    apis: ['./src/**/*.js']
})

// OpenApi validation
app.use(OpenApiValidator.middleware({
  apiSpec: schema,
  validateRequests: true,
  validateResponses: false
}))

Gives the error:

error: openapi.validator: args.apiDoc was invalid.  See the output.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
tamis-laancommented, Dec 31, 2021

Looks like it works now, turns out I had an error in my schema.

This indicates that the schema is invalid:

error: openapi.validator: args.apiDoc was invalid. See the output.

What I don’t understand is, if validation is done on the schema, why it does not tell me what is wrong with the schema.

This would be great for debugging.

0reactions
wparadcommented, Dec 31, 2021

error: openapi.validator: args.apiDoc was invalid. See the output.

What does the output say?

Read more comments on GitHub >

github_iconTop Results From Across the Web

express-openapi-validator VS swagger-jsdoc
The express-openapi-validator package addresses this issue by validating requests and responses based on a provided OpenAPI spec. Having our responses validated ...
Read more >
Adding request and response validation to your Express ...
The express-openapi-validator package addresses this issue by validating requests and responses based on a provided OpenAPI spec. Having our ...
Read more >
express-openapi-validator
Automatically validate API requests and responses with OpenAPI 3 and Express.. Latest version: 5.0.0, last published: a month ago.
Read more >
express-openapi-validator does not validates the request ...
When hitting endpoint, express-openapi-validator does not validate ... listen // Serve the OpenAPI spec const swaggerJsDocs = yaml.load('.
Read more >
express-jsdoc-swagger
express-jsdoc-swagger. With this library, you can document your express endpoints using swagger OpenAPI 3 Specification without writing YAML or JSON.
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