swagger-jsdoc
Advanced tools
Comparing version 6.0.3 to 6.0.4
{ | ||
"name": "swagger-jsdoc", | ||
"description": "Generates swagger doc based on JSDoc", | ||
"version": "6.0.3", | ||
"version": "6.0.4", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=12.0.0" |
@@ -8,2 +8,33 @@ # swagger-jsdoc | ||
``` | ||
Please be aware that 6.x of the library does not yet support ESM. | ||
Please use commonjs export style and rename your definition files with `.cjs`. | ||
``` | ||
## Getting started | ||
`swagger-jsdoc` returns the validated OpenAPI specification as JSON or YAML. | ||
```javascript | ||
const swaggerJsdoc = require('swagger-jsdoc'); | ||
const options = { | ||
swaggerDefinition: { | ||
openapi: '3.0.0', | ||
info: { | ||
title: 'Hello World', | ||
version: '1.0.0', | ||
}, | ||
}, | ||
apis: ['./src/routes*.js'], | ||
}; | ||
const swaggerSpecification = swaggerJsdoc(options); | ||
``` | ||
- `options.definition` is also acceptable. Pass an [oasObject](https://swagger.io/specification/#oasObject) | ||
- `options.apis` are resolved with [node-glob](https://github.com/isaacs/node-glob). Construct these patterns carefully in order to reduce the number of possible matches speeding up files' discovery. Values are relative to the current working directory. | ||
Use any of the [swagger tools](https://swagger.io/tools/) to get the benefits of your `swaggerSpecification`. | ||
## Installation | ||
@@ -28,3 +59,3 @@ | ||
It's available within [`/docs`](https://github.com/Surnet/swagger-jsdoc/tree/master/docs/README.md). | ||
Detailed documentation is available within [`/docs`](https://github.com/Surnet/swagger-jsdoc/tree/master/docs/README.md) folder. | ||
@@ -35,27 +66,1 @@ ### Webpack integrations | ||
- [swagger-jsdoc-sync-webpack-plugin](https://github.com/gautier-lefebvre/swagger-jsdoc-sync-webpack-plugin) - Rebuild the swagger definition based on the files imported in your app on each webpack build. | ||
## Reporting issues | ||
Before starting a new issue, please [check whether there is an existing one](https://github.com/Surnet/swagger-jsdoc/issues). It is quite possible that the topic you would like to bring up has been discussed already in the past. | ||
In case of an issue which hasn't been considered yet, please include as much information as possible. This will help maintainers and other users relate to your problem and possibly solve it. | ||
Guidelines: | ||
- Describe what you were doing when the issue appeared. | ||
- Add a set of steps to reproduce your issue. | ||
- Include screenshots. | ||
- Give examples on expected vs actual behavior. | ||
- Share your failed attempts: what you have tried and what you have considered. | ||
## Contributing | ||
The project exists thanks to the [many contributors](https://github.com/Surnet/swagger-jsdoc/graphs/contributors) who shared their use cases, questions, comments and suggestions for improvements. | ||
Here's how to jump in and contribute yourself: | ||
- Fork the project and clone it locally. | ||
- Create a branch for each separate topic. [Semantic commit messages](https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716) will be highly appreciated. | ||
- Comment your code as if you are going to maintain it in the future. | ||
- Use the rich set of unit tests as an example and add more for the new use cases. This will not only enable you to programatically reproduce your fix faster than setting up an application, but it will also make you super cool! :) | ||
- Push to your changes to the origin of your repository and create a new pull request towards the upstream master. (this repository) |
@@ -111,3 +111,3 @@ const fs = require('fs'); | ||
// eslint-disable-next-line | ||
const loadJs = () => require(resolvedPath); | ||
const loadCjs = () => require(resolvedPath); | ||
const loadJson = () => JSON.parse(swaggerDefinition); | ||
@@ -118,3 +118,3 @@ // eslint-disable-next-line | ||
const LOADERS = { | ||
'.js': loadJs, | ||
'.cjs': loadCjs, | ||
'.json': loadJson, | ||
@@ -128,3 +128,3 @@ '.yml': loadYaml, | ||
if (loader === undefined) { | ||
throw new Error('Definition file should be .js, .json, .yml or .yaml'); | ||
throw new Error('Definition file should be .cjs, .json, .yml or .yaml'); | ||
} | ||
@@ -131,0 +131,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64
68184
1