mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 17:03:49 +01:00
42 lines
791 B
JavaScript
42 lines
791 B
JavaScript
|
const swaggerJSDoc = require('swagger-jsdoc');
|
||
|
const fs = require('fs');
|
||
|
|
||
|
const apiRoot = './src/api/endpoints';
|
||
|
const files = [
|
||
|
'auth/session/generate.js'
|
||
|
];
|
||
|
|
||
|
const errorDefinition = {
|
||
|
'type': 'object',
|
||
|
'properties':{
|
||
|
'error': {
|
||
|
'type': 'string',
|
||
|
'description': 'Error message'
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var options = {
|
||
|
swaggerDefinition: {
|
||
|
swagger: '2.0',
|
||
|
info: {
|
||
|
title: 'Misskey API',
|
||
|
version: 'aoi',
|
||
|
},
|
||
|
consumes: [
|
||
|
'application/x-www-form-urlencoded'
|
||
|
],
|
||
|
produces: [
|
||
|
'application/json'
|
||
|
]
|
||
|
},
|
||
|
apis: []
|
||
|
};
|
||
|
options.apis = files.map(c => {return `${apiRoot}/${c}`;});
|
||
|
|
||
|
var swaggerSpec = swaggerJSDoc(options);
|
||
|
swaggerSpec.definitions.Error = errorDefinition;
|
||
|
|
||
|
fs.writeFileSync('api-docs.json', JSON.stringify(swaggerSpec));
|
||
|
|