mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 18:46:43 -06:00
4dd5a443e5
- /auth/session/userkey - User entity
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
'use strict'
|
|
|
|
const swaggerJSDoc = require('swagger-jsdoc');
|
|
const fs = require('fs');
|
|
const yaml = require('js-yaml');
|
|
|
|
const apiRoot = './src/api/endpoints';
|
|
const files = [
|
|
'users.js',
|
|
'auth/session/generate.js',
|
|
'auth/session/userkey.js',
|
|
];
|
|
|
|
const errorDefinition = {
|
|
'type': 'object',
|
|
'properties':{
|
|
'error': {
|
|
'type': 'string',
|
|
'description': 'Error message'
|
|
}
|
|
}
|
|
}
|
|
|
|
var options = {
|
|
swaggerDefinition: {
|
|
swagger: '2.0',
|
|
info: {
|
|
title: 'Misskey API',
|
|
version: 'aoi',
|
|
},
|
|
host: 'api.misskey.xyz',
|
|
schemes: ['https'],
|
|
consumes: [
|
|
'application/x-www-form-urlencoded'
|
|
],
|
|
produces: [
|
|
'application/json'
|
|
]
|
|
},
|
|
apis: []
|
|
};
|
|
options.apis = files.map(c => {return `${apiRoot}/${c}`;});
|
|
|
|
if(fs.existsSync('.config/config.yml')){
|
|
var config = yaml.safeLoad(fs.readFileSync('./.config/config.yml', 'utf8'));
|
|
options.swaggerDefinition.host = config.url;
|
|
options.swaggerDefinition.schemes = config.https.enable ? ['https'] : ['http'];
|
|
}
|
|
|
|
var swaggerSpec = swaggerJSDoc(options);
|
|
swaggerSpec.definitions.Error = errorDefinition;
|
|
|
|
fs.writeFileSync('api-docs.json', JSON.stringify(swaggerSpec));
|
|
|