Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Surnet/swagger-jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
rockingrohit9639 committed Aug 3, 2022
2 parents 0be7573 + 47268d3 commit f26390e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ yarn add swagger-jsdoc
- Swagger 2
- AsyncAPI 2.0

## Validation of swagger docs

By default `swagger-jsdoc` tries to parse all docs to it's best capabilities. If you'd like to you can instruct an Error to be thrown instead if validation failed by setting the options flag `failOnErrors` to `true`. This is for instance useful if you want to verify that your swagger docs validate using a unit test.

```javascript
const swaggerJsdoc = require('swagger-jsdoc');

const options = {
failOnErrors: true, // Whether or not to throw when parsing errors. Defaults to false.
definition: {
openapi: '3.0.0',
info: {
title: 'Hello World',
version: '1.0.0',
},
},
apis: ['./src/routes*.js'],
};

const openapiSpecification = swaggerJsdoc(options);
```

## Documentation

Click on the version you are using for further details:
Expand Down

0 comments on commit f26390e

Please sign in to comment.