Skip to content

Commit 0996901

Browse files
committed
add documentation -c option and config-help
1 parent ba7025d commit 0996901

File tree

1 file changed

+65
-1
lines changed

1 file changed

+65
-1
lines changed

README.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ NAME
6060
6161
SYNOPSIS
6262
swagger generate [(-a <authorization> | --auth <authorization>)]
63+
[(-c <configuration file> | --config <configuration file>)]
64+
[-D <system properties>]
6365
(-i <spec file> | --input-spec <spec file>)
6466
(-l <language> | --lang <language>)
6567
[(-o <output directory> | --output <output directory>)]
@@ -72,6 +74,16 @@ OPTIONS
7274
remotely. Pass in a URL-encoded string of name:header with a comma
7375
separating multiple values
7476
77+
-c <configuration file>, --config <configuration file>
78+
Path to json configuration file. File content should be in a json
79+
format {"optionKey":"optionValue", "optionKey1":"optionValue1"...}
80+
Supported options can be different for each language. Run
81+
config-help -l {lang} command for language specific config options.
82+
83+
-D <system properties>
84+
sets specified system properties in the format of
85+
name=value,name=value
86+
7587
-i <spec file>, --input-spec <spec file>
7688
location of the swagger spec, as URL or file (required)
7789
@@ -166,8 +178,60 @@ SwaggerYamlGenerator.java
166178
TizenClientCodegen.java
167179
```
168180

169-
Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc., you may want to extend these.
181+
Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc. you can use a json config file to pass the values.
182+
183+
```
184+
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
185+
-i http://petstore.swagger.io/v2/swagger.json \
186+
-l java \
187+
-o samples/client/petstore/java \
188+
-c path/to/config.json
189+
```
190+
Supported config options can be different per language. Running `config-help -l {lang}` will show available options.
191+
192+
```
193+
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jarr config-help -l java
194+
```
195+
196+
Output
197+
198+
```
199+
CONFIG OPTIONS
200+
modelPackage
201+
package for generated models
202+
203+
apiPackage
204+
package for generated api classes
205+
206+
invokerPackage
207+
root package for generated code
208+
209+
groupId
210+
groupId in generated pom.xml
211+
212+
artifactId
213+
artifactId in generated pom.xml
214+
215+
artifactVersion
216+
artifact version in generated pom.xml
217+
218+
sourceFolder
219+
source folder for generated code
220+
```
221+
222+
Your config file for java can look like
223+
224+
```
225+
{
226+
"groupId":"com.my.company",
227+
"artifactId":"MyClent",
228+
"artifactVersion":"1.2.0"
229+
}
230+
```
231+
232+
For all the unspecified options default values will be used.
170233

234+
Another way to override default options is to extend config class for specific language.
171235
To change, for example, the prefix for the Objective-C generated files, simply subclass the ObjcClientCodegen.java:
172236

173237
```

0 commit comments

Comments
 (0)