add documentation -c option and config-help

This commit is contained in:
Richie Azaria 2015-05-29 13:01:42 -07:00
parent ba7025d54b
commit 0996901e72

View File

@ -60,6 +60,8 @@ NAME
SYNOPSIS
swagger generate [(-a <authorization> | --auth <authorization>)]
[(-c <configuration file> | --config <configuration file>)]
[-D <system properties>]
(-i <spec file> | --input-spec <spec file>)
(-l <language> | --lang <language>)
[(-o <output directory> | --output <output directory>)]
@ -72,6 +74,16 @@ OPTIONS
remotely. Pass in a URL-encoded string of name:header with a comma
separating multiple values
-c <configuration file>, --config <configuration file>
Path to json configuration file. File content should be in a json
format {"optionKey":"optionValue", "optionKey1":"optionValue1"...}
Supported options can be different for each language. Run
config-help -l {lang} command for language specific config options.
-D <system properties>
sets specified system properties in the format of
name=value,name=value
-i <spec file>, --input-spec <spec file>
location of the swagger spec, as URL or file (required)
@ -166,8 +178,60 @@ SwaggerYamlGenerator.java
TizenClientCodegen.java
```
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.
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.
```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l java \
-o samples/client/petstore/java \
-c path/to/config.json
```
Supported config options can be different per language. Running `config-help -l {lang}` will show available options.
```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jarr config-help -l java
```
Output
```
CONFIG OPTIONS
modelPackage
package for generated models
apiPackage
package for generated api classes
invokerPackage
root package for generated code
groupId
groupId in generated pom.xml
artifactId
artifactId in generated pom.xml
artifactVersion
artifact version in generated pom.xml
sourceFolder
source folder for generated code
```
Your config file for java can look like
```
{
"groupId":"com.my.company",
"artifactId":"MyClent",
"artifactVersion":"1.2.0"
}
```
For all the unspecified options default values will be used.
Another way to override default options is to extend config class for specific language.
To change, for example, the prefix for the Objective-C generated files, simply subclass the ObjcClientCodegen.java:
```