Added swagger-jsdoc

This commit is contained in:
Nicholas Wallace 2024-02-16 03:59:51 +00:00
parent a9e9808183
commit 4c11ca5a55
2 changed files with 26 additions and 0 deletions

View file

@ -58,6 +58,7 @@
"mocha": "^10.2.0",
"nodemon": "^2.0.20",
"nyc": "^15.1.0",
"swagger-jsdoc": "^6.2.8",
"sinon": "^17.0.1"
}
}

25
swagger.js Normal file
View file

@ -0,0 +1,25 @@
const fs = require('fs')
const swaggerJSDoc = require('swagger-jsdoc')
const options = {
definition: {
openapi: '3.0.0',
info: {
title: 'Audiobookshelf API',
version: '1.0.0',
description: 'Audiobookshelf API with autogenerated OpenAPI doc',
},
},
apis: ['./server/**/*.js'] // Path to the API docs
}
const openAPISpecification = swaggerJSDoc(options)
// Write the specification to a file
fs.writeFile('./build-docs/swagger-output.json', JSON.stringify(openAPISpecification, null, 2), (err) => {
if (err) {
console.log(err)
return
}
console.log('OpenAPI spec generated successfully!')
})