mirror of https://gitee.com/bigwinds/arangodb
Allow overriding default swagger.json generator.
This commit is contained in:
parent
43bfbab267
commit
a24b5d7ac5
|
@ -68,7 +68,8 @@ function createSwaggerRouteHandler(appPath, opts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pathInfo === 'swagger.json') {
|
if (pathInfo === 'swagger.json') {
|
||||||
res.json(swaggerJson(req, result ? result.appPath : (opts.appPath || appPath)));
|
var swaggerJsonHandler = opts.swaggerJson || swaggerJson;
|
||||||
|
swaggerJsonHandler(req, res, {appPath: result ? result.appPath : (opts.appPath || appPath)});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var indexFile = result ? result.indexFile : opts.indexFile;
|
var indexFile = result ? result.indexFile : opts.indexFile;
|
||||||
|
@ -84,11 +85,11 @@ function createSwaggerRouteHandler(appPath, opts) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function swaggerJson(req, appPath) {
|
function swaggerJson(req, res, opts) {
|
||||||
var foxx = FoxxManager.routes(appPath);
|
var foxx = FoxxManager.routes(opts.appPath);
|
||||||
var app = foxx.appContext.app;
|
var app = foxx.appContext.app;
|
||||||
var swagger = parseRoutes(appPath, foxx.routes, foxx.models);
|
var swagger = parseRoutes(opts.appPath, foxx.routes, foxx.models);
|
||||||
return {
|
res.json({
|
||||||
swagger: '2.0',
|
swagger: '2.0',
|
||||||
info: {
|
info: {
|
||||||
description: app._manifest.description,
|
description: app._manifest.description,
|
||||||
|
@ -101,7 +102,7 @@ function swaggerJson(req, appPath) {
|
||||||
paths: swagger.paths,
|
paths: swagger.paths,
|
||||||
// securityDefinitions: {},
|
// securityDefinitions: {},
|
||||||
definitions: swagger.definitions
|
definitions: swagger.definitions
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function fixSchema(model) {
|
function fixSchema(model) {
|
||||||
|
|
Loading…
Reference in New Issue