UNPKG

4.32 kBMarkdownView Raw
1
2
3
4## Command-line interface reference
5
6Create, run, and manage Swagger projects from the command line.
7
8* [swagger](#swagger)
9* [project create](#create)
10* [project start](#start)
11* [project verify](#verify)
12* [project edit](#edit)
13* [project open](#open)
14* [project test](#test)
15* [docs](#docs)
16
17#### <a name="swagger"></a>swagger
18
19Options:
20
21* -h, --help: Outputs usage information.
22* -V, --version: Outputs the swagger cli version number.
23
24Example:
25
26 swagger -V
27 0.2.0
28
29
30#### <a name="create"></a>swagger project create [options] [name]
31
32Creates a folder with the specified [name] containing a new Swagger project. A project skeleton is downloaded from GitHub and installed in the new folder.
33
34Options:
35
36* -h, --help: Outputs usage information.
37* -f, --framework <framework>: Specifies an API framework to use with the project. Choices are connect, express, hapi, restify, or sails.
38
39Example:
40
41 swagger project create -f express sn-express
42 ls sn-express
43 README.md api app.js config node_modules package.json test
44
45
46#### <a name="start"></a>swagger project start [options] [directory]
47
48Starts the Swagger project in the current (or specified) directory. The server automatically restarts when you make changes to the project. You can also force a restart by typing `rs` on the server command line.
49
50Options:
51
52* -h, --help: Outputs usage information.
53* -d, --debug <port>: Start in remote debug mode so you can connect to it with a debugger.
54* -b, --debug-brk <port>: Start in remote debug mode, wait for debugger.
55* -m, --mock: Start in mock mode. For more information, see [Running in mock mode](./mock-mode.md).
56* -o, --open: Open the default browser as a client to the project.
57* -n, --node-args <args>: Pass extra arguments to node. E.g. `swagger project start --node-args "--harmony"` will run node with [ES6 a.k.a harmony features](https://github.com/joyent/node/wiki/ES6-%28a.k.a.-Harmony%29-Features-Implemented-in-V8-and-Available-in-Node) enabled.
58
59Example:
60
61 cd ./myproject
62 swagger -m project start
63
64
65#### <a name="verify"></a>swagger project verify [options] [project root directory]
66
67Verifies that the project in the current (or specified) directory is correct. Reports errors and warnings from the Swagger model, project configuration, etc.
68
69Options:
70
71* -h, --help: Outputs usage information.
72* -j, --json: Output information in JSON format.
73
74Example:
75
76 cd ./myproject
77 swagger project verify
78 Project Errors
79 --------------
80 #/: Missing required property: paths
81 #/: Additional properties not allowed: aths
82 Results: 2 errors, 0 warnings
83
84
85
86#### <a name="edit"></a>swagger project edit [options] [directory]
87
88Opens the project in the current (or specified) directory in the [Swagger Editor](https://github.com/swagger-api/swagger-editor).
89
90![alt text](./images/swagger-editor.png)
91
92Options:
93
94* -h, --help: Outputs usage information.
95* -s, --silent: Do not open the browser.
96* --host <host>: The hostname the editor is served from (default: 127.0.0.1).
97* -p, --port <port>: The port the editor is served from (default: random port).
98
99Example:
100
101 cd ./myproject
102 swagger project edit
103
104
105#### <a name="open"></a>swagger project open [directory]
106
107Opens the browser as a client to the current or specified project.
108
109Options:
110
111* -h, --help: Outputs usage information.
112
113Example:
114
115`swagger project open ./myproject`
116
117
118
119#### <a name="test"></a>swagger project test [options] [directory-or-file]
120
121Runs project tests.
122
123Options:
124
125* -h, --help: Outputs usage information.
126* -d, --debug <port>: Start in remote debug mode so you can connect to it with a debugger.
127* -b, --debug-brk <port>: Start in remote debug mode, wait for debugger.
128* -m, --mock: Start in mock mode. For more information, see [Running in mock mode](./mock-mode.md).
129
130Example:
131
132 `swagger project test`
133
134 controllers
135 hello_world
136 GET /hello
137 ✓ should return a default string
138 ✓ should accept a name parameter
139 2 passing (27ms)
140
141
142##### <a name="docs"></a>swagger docs
143
144Opens the Swagger 2.0 specification in your browser.
145
146Example:
147
148 swagger docs
149
150
151
152