2018-04-17 07:19:10 +00:00
openapi-generator-maven-plugin
2015-06-22 18:17:29 +00:00
============================
2018-04-17 07:19:10 +00:00
A Maven plugin to support the OpenAPI generator project
2015-06-22 18:17:29 +00:00
Usage
============================
Add to your `build->plugins` section (default phase is `generate-sources` phase)
```xml
< plugin >
2018-04-17 07:19:10 +00:00
< groupId > org.openapitools< / groupId >
< artifactId > openapi-generator-maven-plugin< / artifactId >
2018-02-01 13:22:41 +00:00
< version > 2.3.1< / version >
2015-06-22 18:17:29 +00:00
< executions >
< execution >
< goals >
< goal > generate< / goal >
< / goals >
< configuration >
2018-04-17 07:19:10 +00:00
< inputSpec > ${project.basedir}/src/main/resources/api.yaml< / inputSpec >
2015-06-22 18:17:29 +00:00
< language > java< / language >
2015-06-24 05:31:10 +00:00
< configOptions >
< sourceFolder > src/gen/java/main< / sourceFolder >
< / configOptions >
2015-06-22 18:17:29 +00:00
< / configuration >
< / execution >
< / executions >
< / plugin >
```
Followed by:
```
mvn clean compile
```
2015-06-24 05:31:10 +00:00
### General Configuration parameters
2015-06-22 18:17:29 +00:00
2015-12-30 22:52:15 +00:00
- `inputSpec` - OpenAPI Spec file path
2015-06-22 18:17:29 +00:00
- `language` - target generation language
- `output` - target output path (default is `${project.build.directory}/generated-sources/swagger` )
- `templateDirectory` - directory with mustache templates
- `addCompileSourceRoot` - add the output directory to the project as a source root (`true` by default)
2015-06-24 05:31:10 +00:00
- `modelPackage` - the package to use for generated model objects/classes
- `apiPackage` - the package to use for generated api objects/classes
- `invokerPackage` - the package to use for the generated invoker objects
2017-01-17 07:26:30 +00:00
- `modelNamePrefix` and `modelNameSuffix` - Sets the pre- or suffix for model classes and enums
2017-08-03 07:35:33 +00:00
- `withXml` - enable XML annotations inside the generated models and API (only works with Java `language` and libraries that provide support for JSON and XML)
2015-06-24 05:31:10 +00:00
- `configOptions` - a map of language-specific parameters (see below)
2016-01-05 13:02:05 +00:00
- `configHelp` - dumps the configuration help for the specified library (generates no sources)
2018-04-17 07:19:10 +00:00
- `ignoreFileOverride` - specifies the full path to a `.openapi-generator-ignore` used for pattern based overrides of generated outputs
2017-03-18 07:46:10 +00:00
- `generateApis` - generate the apis (`true` by default)
- `generateApiTests` - generate the api tests (`true` by default. Only available if `generateApis` is `true` )
- `generateApiDocumentation` - generate the api documentation (`true` by default. Only available if `generateApis` is `true` )
- `generateModels` - generate the models (`true` by default)
- `modelsToGenerate` - A comma separated list of models to generate. All models is the default.
- `generateModelTests` - generate the model tests (`true` by default. Only available if `generateModels` is `true` )
- `generateModelDocumentation` - generate the model documentation (`true` by default. Only available if `generateModels` is `true` )
- `generateSupportingFiles` - generate the supporting files (`true` by default)
- `supportingFilesToGenerate` - A comma separated list of supporting files to generate. All files is the default.
2017-04-10 15:31:58 +00:00
- `skip` - skip code generation (`false` by default. Can also be set globally through the `codegen.skip` property)
2015-06-24 05:31:10 +00:00
2016-05-24 18:44:21 +00:00
### Custom Generator
Specifying a custom generator is a bit different. It doesn't support the classpath:/ syntax, but it does support the fully qualified name of the package. You can also specify your custom templates, which also get pulled in. Notice the dependency on a project, in the plugin scope. That would be your generator/template jar.
```xml
< plugin >
2018-04-17 07:19:10 +00:00
< groupId > org.openapitools< / groupId >
< artifactId > openapi-generator-maven-plugin< / artifactId >
< version > ${openapi-generator-maven-plugin-version}< / version >
2016-05-24 18:44:21 +00:00
< executions >
< execution >
< goals >
< goal > generate< / goal >
< / goals >
< configuration >
2018-04-17 07:19:10 +00:00
< inputSpec > ${project.basedir}/src/main/resources/yaml/yamlfilename.yaml< / inputSpec >
<!-- language file, like e.g. JavaJaxRSCodegen -->
2016-05-24 18:44:21 +00:00
< language > com.my.package.for.GeneratorLanguage< / language >
< templateDirectory > myTemplateDir< / templateDirectory >
< output > ${project.build.directory}/generated-sources< / output >
< apiPackage > ${default.package}.handler< / apiPackage >
< modelPackage > ${default.package}.model< / modelPackage >
< invokerPackage > ${default.package}.handler< / invokerPackage >
< / configuration >
< / execution >
< / executions >
< dependencies >
< dependency >
< groupId > com.my.generator< / groupId >
< artifactId > customgenerator< / artifactId >
< version > 1.0-SNAPSHOT< / version >
< / dependency >
< / dependencies >
< / plugin >
```
2016-01-05 13:02:05 +00:00
### Sample configuration
2015-06-24 05:31:10 +00:00
2016-05-24 18:44:21 +00:00
- Please see [an example configuration ](examples ) for using the plugin