1 | # Configuration
|
2 | A project using `swagger-gen-js` must provide a configuration file. By default this file is called `.swaggergenrc` and exists in the root directory of the project. It must be a JSON file, containing a single object with the options documented below. Invalid options will be ignored.
|
3 |
|
4 | ## `api`
|
5 |
|
6 | Under Construction
|
7 |
|
8 | ## `api_reducer_location`
|
9 | A string path representing where the generated files will assume the generated reducers are stored in the redux store consuming the output. If it is missing or invalid, a default value of `state` will be used.
|
10 |
|
11 | `api_reducer_location` is an optional field.
|
12 |
|
13 | ## `change_case_operationId`
|
14 | What case change operation, if any, to apply to `operationId`s during code generation. It may be any method supported by [change-case](https://github.com/blakeembrey/change-case#readme). Several of them will result in broken code, so use with caution. The case change operation override the defaults, which vary depending on the type of code being generated. Defaults:
|
15 |
|
16 | * Redux sagas: `camel`
|
17 | * Flow types: `pascal`
|
18 | * Redux actions: `pascal`
|
19 | * File names: `pascal`
|
20 |
|
21 | `change_case_operationId` is an optional field.
|
22 |
|
23 | ## `debug`
|
24 | Boolean. Setting this to true is the same as using `-d` or `--debug` at runtime. The command line debug flag overrides this configuration if applicable.
|
25 |
|
26 | `debug` is an optional field.
|
27 |
|
28 | ## `input`
|
29 | A glob of which files to use as sources for generation. All matching files should be JSON following the swagger specification.
|
30 |
|
31 | `input` is a required field.
|
32 |
|
33 | ## `keyed_collection`
|
34 |
|
35 | Under construction
|
36 |
|
37 | ## `output`
|
38 | An object with several options used for configuring output.
|
39 |
|
40 | `output` is a required field.
|
41 |
|
42 | The available options are:
|
43 |
|
44 | ### `output.api_modules`
|
45 | The desired output directory for generated API interaction modules.
|
46 |
|
47 | `api_modules` is a required field if `redux_sagas` is specified.
|
48 |
|
49 | ### `output.include`
|
50 | An array of strings representing which "tags" should be used to produce output. These strings should be all lower case. If an endpoint has at least one tag matching a value in `include`, it will be used. If `include` is missing or invalid, all tags will be included.
|
51 |
|
52 | `include` is an optional field.
|
53 |
|
54 | ### `output.flow_types`
|
55 | The desired output directory for generated API interaction modules.
|
56 |
|
57 | `flow_types` is a required field if `api_modules`, `redux_actions`, `redux_reducers`, `redux_sagas`, or `selectors` are specified.
|
58 |
|
59 | ### `output.json_schema`
|
60 | The desired output directory for rewritten schema produced during the `swagger-gen-js` build process. This is mostly of use when debugging, or to give insight into how `swagger-gen-js` approaches parsing the swagger spec.
|
61 |
|
62 | `json_schema` is an optional field.
|
63 |
|
64 | ### `output.redux_saga`
|
65 | The desired output directory for generated redux sagas use to trigger API calls and handle responses.
|
66 |
|
67 | `redux_saga` is an optional field.
|
68 |
|
69 | ### `output.selectors`
|
70 | The desired output directory for generated selectors used to retrieve data from generated reducers.
|
71 |
|
72 | `selectors` is an optional field.
|
73 |
|
74 | ### `output.validators`
|
75 | The desired output directory for generated API output validators.
|
76 |
|
77 | `validators` is an optional field. `validators` is meaningless if `api_modules` is not set.
|
78 |
|
79 | ## `specs`
|
80 | An array of objects representing URIs from which to download swagger specifications.
|
81 |
|
82 | `specs` is an optional field.
|
83 |
|
84 | ## `translate_operationId`
|
85 | An object representing a map of `operationId`s from the spec file(s) and what strings to use to replace them. For example:
|
86 | ``` json
|
87 | translate_operationId: {
|
88 | "ThIs_OpErAtIoNiD_iS_uGlY": "thisOperationIdIsPretty",
|
89 | "WHY_IS_THIS_OPERATIONID_SO_LONG_PLEASE_STOP": "muchShorter"
|
90 | }
|
91 | ```
|
92 | Regardless of `operationId` rewrites, generated code prepends the tag name. This helps avoid accidental collision among similarly named endpoints and makes it immediatly apparent where to look for the source of generated code.
|
93 |
|
94 | `translate_operationId` is an optional field.
|