audiobookshelf/swagger.js
2024-02-17 03:53:33 +00:00

25 lines
No EOL
640 B
JavaScript

const fs = require('fs')
const swaggerJSDoc = require('swagger-jsdoc')
const options = {
definition: {
openapi: '3.1.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!')
})