From eadf6fe67c03d18153a339eb9fbc1f001bf3a89b Mon Sep 17 00:00:00 2001 From: M0Bruno Date: Fri, 5 Jul 2019 15:25:57 +0200 Subject: [PATCH] add an exclude param --- index.js | 4 +++- readme.md | 1 + schema-to-swagger.js | 6 +++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 53d8792..19ffde3 100644 --- a/index.js +++ b/index.js @@ -32,8 +32,10 @@ ParseSwagger.prototype.renderSwaggerSpec = function (req, res) { headers: { "X-Parse-Application-Id": this.config.appId, "X-Parse-Master-Key": this.config.masterKey } }; + var excludes = this.config.excludes || []; + request(options).then((data) => { - var swagger = parseSchemaToSwagger(parseBaseSwaggerSpec, data.results); + var swagger = parseSchemaToSwagger(parseBaseSwaggerSpec, data.results, excludes); res.json(swagger); }).catch((error) => { res.send('Request failed with response code ' + error.status); diff --git a/readme.md b/readme.md index 708dcbd..39f1301 100644 --- a/readme.md +++ b/readme.md @@ -24,6 +24,7 @@ if (CONFIG.swagger) { parsePath: '/parse' appId: '', masterKey: '', + excludes: ['className'], }); app.use(parseSwagger); diff --git a/schema-to-swagger.js b/schema-to-swagger.js index d9b0812..b270284 100644 --- a/schema-to-swagger.js +++ b/schema-to-swagger.js @@ -1,8 +1,12 @@ /** * Transform Parse Server schema.json to swagger.json */ -exports.parseSchemaToSwagger = function (spec, schemas) { +exports.parseSchemaToSwagger = function (spec, schemas, excludes) { for (const classes of schemas) { + if (excludes.includes(classes.className)) { + continue; + } + spec.components.schemas[classes.className] = transformClasseToSchema(classes); spec.paths['/parse/classes/' + classes.className] = getPath(classes); spec.paths['/parse/classes/' + classes.className + '/{id}'] = getPathById(classes);