mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 01:53:08 +02:00
Add host and schemes to swaggerJSON
This commit is contained in:
parent
e62b008c71
commit
972f0e7f41
1 changed files with 11 additions and 0 deletions
11
swagger.js
11
swagger.js
|
@ -1,5 +1,8 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
const swaggerJSDoc = require('swagger-jsdoc');
|
const swaggerJSDoc = require('swagger-jsdoc');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const yaml = require('js-yaml');
|
||||||
|
|
||||||
const apiRoot = './src/api/endpoints';
|
const apiRoot = './src/api/endpoints';
|
||||||
const files = [
|
const files = [
|
||||||
|
@ -23,6 +26,8 @@ var options = {
|
||||||
title: 'Misskey API',
|
title: 'Misskey API',
|
||||||
version: 'aoi',
|
version: 'aoi',
|
||||||
},
|
},
|
||||||
|
host: 'api.misskey.xyz',
|
||||||
|
schemes: ['https'],
|
||||||
consumes: [
|
consumes: [
|
||||||
'application/x-www-form-urlencoded'
|
'application/x-www-form-urlencoded'
|
||||||
],
|
],
|
||||||
|
@ -34,6 +39,12 @@ var options = {
|
||||||
};
|
};
|
||||||
options.apis = files.map(c => {return `${apiRoot}/${c}`;});
|
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);
|
var swaggerSpec = swaggerJSDoc(options);
|
||||||
swaggerSpec.definitions.Error = errorDefinition;
|
swaggerSpec.definitions.Error = errorDefinition;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue