Add host and schemes to swaggerJSON

This commit is contained in:
Tosuke 2017-01-04 13:56:20 +09:00
parent 76854cf762
commit 0321c3239a

View File

@ -1,5 +1,8 @@
'use strict'
const swaggerJSDoc = require('swagger-jsdoc');
const fs = require('fs');
const yaml = require('js-yaml');
const apiRoot = './src/api/endpoints';
const files = [
@ -23,6 +26,8 @@ var options = {
title: 'Misskey API',
version: 'aoi',
},
host: 'api.misskey.xyz',
schemes: ['https'],
consumes: [
'application/x-www-form-urlencoded'
],
@ -34,6 +39,12 @@ var options = {
};
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;