From 972f0e7f41fc133f1ae7ad2d9fdd87e5dd7cbac0 Mon Sep 17 00:00:00 2001 From: Tosuke Date: Wed, 4 Jan 2017 13:56:20 +0900 Subject: [PATCH] Add host and schemes to swaggerJSON --- swagger.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/swagger.js b/swagger.js index eb82a7251..a7046e3bd 100644 --- a/swagger.js +++ b/swagger.js @@ -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;