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
{{ message }}
This repository was archived by the owner on Jan 25, 2020. It is now read-only.
If you want to generate (or regenerate) only a specific component, you can use `swaggerize` sub generators.
70
+
71
+
-`yo swaggerize:data`
72
+
73
+
Generates `data` providers based on `paths` and `responses` in swagger api document.
74
+
This also generates the `config/swagger.json` (A copy of the swagger api document file input) and `security` authorize handlers based on `securityDefinitions`.
75
+
76
+
-`yo swaggerize:handler`
77
+
78
+
Generates `handlers` based on `paths` in swagger api document. (`data` providers are also generated as a pre step)
79
+
80
+
-`yo swaggerize:test`
81
+
82
+
Generates unit `tests` based on `paths`, `parameters` and `responses` in swagger api document. (`handlers` and `data` providers are also generated as a pre step)
83
+
84
+
#### Project structure
85
+
86
+
-`/config` - A copy of the swagger api document file input, will be generated at `/config/swagger.json`.
87
+
-`/data` - Data providers for paths(routes).
88
+
-`/security` - Authorize handlers for security schemes declared by `securityDefinitions`.
89
+
-`/handlers` - Application paths (routes) based on swagger api `paths`.
90
+
-`/tests` - Unit tests for paths(routes).
91
+
92
+
Example:
93
+
94
+
```
95
+
├── README.md
96
+
├── .eslintrc
97
+
├── .gitignore
98
+
├── .npmignore
99
+
├── config
100
+
│ └── swagger.json
101
+
├── data
102
+
│ ├── mockgen.js
103
+
│ └── hellopath
104
+
│ └── {id}.js
105
+
├── handlers
106
+
│ └── hellopath
107
+
│ └── {id}.js
108
+
├── package.json
109
+
├── security
110
+
│ ├── hello_Oauth2.js
111
+
│ └── hello_api_key.js
112
+
├── server.js
113
+
└── tests
114
+
└── hellopath
115
+
└── {id}.js
116
+
```
117
+
118
+
##### Handlers
119
+
120
+
A handler file will be generated corresponding to every a `path` definition of the swagger api (`paths`).
-`--framework` - specify the framework (`hapi` or `express`).
128
+
##### Data providers
129
+
130
+
A data file will be generated corresponding to every a `path` definition of the swagger api (`paths`).
131
+
132
+
By default [Response Mock generator](https://github.com/subeeshcbabu/swagmock#responses) is used to provide the data based on the `responses` definition of swagger api.
133
+
Developers should replace these default mock data generators with actual data feeds, based on the functionality.
134
+
135
+
##### Security authorize handlers
136
+
137
+
A security authorize handler file will be generated corresponding to the declaration of the security schemes `securityDefinitions`.
138
+
139
+
##### Unit tests
140
+
141
+
A unit test file will be generated corresponding to every a `path` definition of the swagger api (`paths`).
142
+
143
+
By default [Request Mock generator](https://github.com/subeeshcbabu/swagmock#requests) is used to generator api requests based on the `parameters` definition of swagger api.
144
+
145
+
#### CLI Options
146
+
147
+
-`--framework` - specify the framework (`hapi`, `express`, or `restify`).
51
148
-`--apiPath` - specify the path to the swagger document.
149
+
-`--handlerPath` - specify the path to generate the handler files. By default `handlers` directory.
150
+
-`--dataPath` - specify the path to generate the data files. By default `data` directory.
151
+
-`--securityPath` - specify the path to generate the security authorize files. By default `security` directory.
152
+
-`--testPath` - specify the path to generate the unit test files. By default `tests` directory.
153
+
-`--skip-npm-install` - To skip the default `npm install` on the generated project.
154
+
155
+
#### Prompts
156
+
157
+
-`apiPath` - Path (or URL) to swagger document
158
+
159
+
The path to the swagger api document. This path could be a local or remote URL.
160
+
161
+
If there is no CLI option `--apiPath` specified, the generator will prompt for `apiPath`. The swagger api will be validated against the swagger schema and spec before proceeding with scaffolding process.
162
+
163
+
-`framework` - The choice of framework to generate the application.
164
+
165
+
There are three options - `express`, `hapi` and `restify`. If there is no CLI option `--framework` specified, the generator will prompt for `framework`.
166
+
167
+
Also, generator checks the working directory for `package.json` dependencies, to find out whether the application already depends on, one of the framework options. If a match is found, that framework will be used as an option without prompting for the value.
168
+
169
+
-`appName` - The name of the application
170
+
171
+
By default the yeoman project root will be used as the name of the application, however, the prompt lets developers change this default.
172
+
173
+
-`creatorName`, `githubUser` and `email` - Creator details to build the `package.json`.
0 commit comments