You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: Update postProcess config to allow alternate save mechanism (#91)
Update `postProcess` configuration to run after tag clean-up phase
to allow an alternate mechanism for saving the generated Swagger to
be specified, rather than the standard writing a file to the filesystem.
Allow `swaggerJsonPath` to be empty/null/undefined, in which case
no file write attempted.
This supports deployment to environments that do not allow writing to the
filesystem e.g. store in memory or database.
*`disabled` attribute is used to disable the module (e.g you may want to disable it on production).
103
-
*`swaggerJsonPath` where to generate the `swagger.json` file to; defaults to `sails.config.appPath + '/swagger/swagger.json'`.
103
+
*`swaggerJsonPath` where to generate the `swagger.json` file to; defaults to `sails.config.appPath + '/swagger/swagger.json'`
104
+
and output file will not be written if empty/null/undefined (see `postProcess` below for alternate save mechanism).
104
105
*`swagger` object is template for the Swagger/OpenAPI output. It defaults to the minimal content above.
105
106
Check Swagger/OpenAPI specification for more, in case you want to extend it.
106
107
Generally, this hook provides sensible defaults for as much as possible but you may
@@ -111,7 +112,8 @@ Notes on the use of configuration:
111
112
routes be excluded from generated Swagger output; defaults to `true`.
112
113
*`includeRoute` function used to filter routes to be included in generated Swagger output; see advanced section below.
113
114
*`updateBlueprintActionTemplates` allows customisation of the templates used to generate Swagger for blueprints; see advanced section below.
114
-
*`postProcess` allows modification of the generated Swagger output before it is written to the output file; see advanced section below.
115
+
*`postProcess` allows an alternate mechanism for saving and/or modification of the generated Swagger output before it is written to
116
+
the output file; see advanced section below.
115
117
116
118
117
119
## Custom Route Configuration
@@ -454,6 +456,10 @@ Tags are added to the top-level Swagger/OpenAPI definitions as follows:
454
456
1. Where a tag with the specified name **does** exist, elements _of that tag_ that do not exist are added
455
457
e.g. `description` and `externalDocs` elements.
456
458
459
+
Note that a final *clean-up* phase is run after processing, which performs the following:
460
+
1. Removal of unreferenced tags; and
461
+
2. Creation of tags referenced but are not defined.
462
+
457
463
### Component Element Handling
458
464
459
465
Elements of components are added to the top-level Swagger/OpenAPI definitions as follows:
@@ -494,7 +500,7 @@ let componentDefinitionReference = {
494
500
Three mechanisms are provided to enable advancing filtering of the Swagger generation process:
495
501
1. An `includeRoute()` function used to filter routes to be included in generated Swagger output.
496
502
1. An `updateBlueprintActionTemplates()` function allows customisation of the templates used to generate Swagger for blueprints.
497
-
1. A `postProcess()` function allows modification of the generated Swagger output before it is written to the output file.
503
+
1. A `postProcess()` function allows an alternate mechanism for saving and/or modification of the generated Swagger output before it is written to the output file.
498
504
499
505
Each is configured in `config/swaggergenerator.js`.
500
506
@@ -621,6 +627,12 @@ Note that:
621
627
The final generated Swagger output may be post-processed before it is written to
622
628
the output file using a post-processing function specified as the `postProcess` config option.
623
629
630
+
For situations where saving the generated swagger documentation JSON to a file is
631
+
not desired/appropriate, the `postProcess` config option may be used to specify
632
+
an alternate save mechanism.
633
+
634
+
Note that if `swaggerJsonPath` config option is empty/null/undefined the output file will not be written.
0 commit comments