Skip to content
This repository was archived by the owner on Jan 25, 2020. It is now read-only.

Commit 4aeee91

Browse files
authored
Merge pull request #91 from krakenjs/v3.x
Major version v3.0.0
2 parents 0255b67 + b537642 commit 4aeee91

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3821
-1764
lines changed

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
coverage
2+
templates

.eslintrc

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"rules": {
3+
"indent": [
4+
2,
5+
4
6+
],
7+
"quotes": [
8+
2,
9+
"single"
10+
],
11+
"linebreak-style": [
12+
2,
13+
"unix"
14+
],
15+
"semi": [
16+
2,
17+
"always"
18+
]
19+
},
20+
"env": {
21+
"es6": true,
22+
"node": true
23+
},
24+
"extends": "eslint:recommended"
25+
}

.jshintrc

-69
This file was deleted.

.npmignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
work
2626
build
27-
test
27+
./test
2828
pids
2929
logs
3030
results

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# v3.0.0
2+
3+
## Breaking changes
4+
- `models` are not generated anymore, instead `data` providers are generated. Data providers use `mock` responses by default.
5+
6+
## Enhancements and Bug fixes
7+
- new yeoman infrastructure
8+
- #80 - Use swagger parser to parse and validate swagger 2.0 spec
9+
- #61, #54 - Support to define Reference Object as a Relative Schema File
10+
- #17 - Pass the swagger source file as a CLI option
11+
- #49 - apiPath options assumes that the path is local. Remote file paths are not allowed as this CLI option
12+
- #51 - Generator won't handle enums
13+
- #8 - Issue with allOf in swagger definitions
14+
- #66 - Generated handler sets a `501` status code and generated tests check for `200` status code
15+
- #72 - Deprecate warning using generated code : body-parser deprecated bodyParser() usage
16+
117
# v2.0.2
218

319
## Bug fixes

README.md

+129-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
generator-swaggerize
22
====================
33

4-
Lead Maintainer: [Trevor Livingston](https://github.com/tlivings/)
4+
Lead Maintainer: [Subeesh Chothendavida](https://github.com/subeeshcbabu/)
55

66
[![Build Status](https://travis-ci.org/krakenjs/generator-swaggerize.svg?branch=master)](https://travis-ci.org/krakenjs/generator-swaggerize)
77
[![NPM version](https://badge.fury.io/js/generator-swaggerize.png)](http://badge.fury.io/js/generator-swaggerize)
88

99

10-
Yeoman generator for swagger application with krakenjs/swaggerize tools.
10+
Yeoman generator for swagger application with `swaggerize` tools.
1111

1212
Generates projects for:
1313
- Express
1414
- Hapi
15+
- Restify
1516

1617
See also:
1718
- [swaggerize-express](https://github.com/krakenjs/swaggerize-express)
@@ -37,15 +38,136 @@ Create a project:
3738
$ yo swaggerize
3839
```
3940

40-
### Re-running handlers, test, and models generator
41+
### Generators
4142

42-
In an existing project, you can run the generator with the `--only` option. This option supports a comma delimited string of types to generate.
43+
- `yo swaggerize`
44+
45+
Generates a new swaggerize application
4346

4447
```
45-
$ yo swaggerize --only=handlers,models,tests
48+
49+
$ yo swaggerize
50+
51+
Swaggerize Generator
52+
Tell us a bit about your application
53+
? Path (or URL) to swagger document: http://petstore.swagger.io/v2/swagger.json
54+
? Framework: express
55+
? What would you like to call this project: myapp
56+
? Your name: Lorem Ipsum
57+
? Your github user name: loremipsum
58+
? Your email: [email protected]
59+
create .eslintrc
60+
create .gitignore
61+
create .npmignore
62+
create package.json
63+
create README.md
64+
.
65+
.
66+
.
4667
```
4768

48-
### Other CLI Options
69+
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`).
121+
122+
More details or handlers and routing:
123+
124+
[swaggerize-express handlers](https://github.com/krakenjs/swaggerize-express#handlers-directory)
125+
126+
[swaggerize-hapi handlers](https://github.com/krakenjs/swaggerize-hapi#handlers-directory)
49127

50-
- `--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`).
51148
- `--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

Comments
 (0)