From c65111f8bb32182f5956e09ecc53c8fdd4a49610 Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Sat, 25 May 2019 19:26:47 +0200 Subject: [PATCH 1/2] Expose swayOptions --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4752371..f331e8e 100644 --- a/index.js +++ b/index.js @@ -40,7 +40,13 @@ module.exports = { * @return {Promise} */ function generate(specPath, options) { - return sway.create({'definition': specPath}) + return sway.create({ + 'definition': specPath, + 'jsonRefs': options && options.jsonRefs, + 'customFormats': options && options.customFormats, + 'customFormatGenerators': options && options.customFormatGenerators, + 'customValidators': options && options.customValidators + }) .then(function (api) { if (options.customValues) { options.customValues = JSON.parse(options.customValues); @@ -75,4 +81,4 @@ function generate(specPath, options) { console.error(err.stack); return err }); -} \ No newline at end of file +} From 794bc2bbddab425d016619c7cee84966278a481f Mon Sep 17 00:00:00 2001 From: Aras Abbasi Date: Sat, 25 May 2019 19:39:12 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 96540d1..e9cdb7a 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,10 @@ The following options can be passed to the generation function, some/all are exp | `scheme` | `--scheme -m` | `spec.schemes[0]` | `false` | Override for multiple scheme present in a spec | | `templates` | `--templates -t` | `'./templates'` | `false` | Path to directory containing custom templates | | `statusCodes` |`--status-codes -S` | `operation.responses` | `false` | comma separated list of status codes to explicity generate tests for | +| `jsonRefs` | | n/a | `false` | *(See [JsonRefs~JsonRefsOptions](https://github.com/whitlockjc/json-refs/blob/master/docs/API.md#module_JsonRefs..JsonRefsOptions))* | +| `customFormats` | | n/a | `false` | The key/value pair of custom formats *(The keys are the format name and the values are async functions. See [ZSchema Custom Formats](https://github.com/zaggino/z-schema#register-a-custom-format))* | +| `customFormatGenerators` | | n/a | `false` | The key/value pair of custom format generators *(The keys are the format name and the values are functions. See [json-schema-mocker Custom Format](https://github.com/json-schema-faker/json-schema-faker#custom-formats))* | +| `customValidators` | | n/a | `false` | The custom validators. See [DocumentValidationFunction](https://github.com/apigee-127/sway/blob/master/docs/API.md#module_sway.DocumentValidationFunction) | ## Testing