| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dcc622d commit b91c8e1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,8 @@ These names can be anything you like. If you are building a client for the white | |||
| 35 | 35 | ||
| 36 | 36 | **NOTE** Convention is to use kebab casing for names passed to `-n`. Example, `scala-finatra` would become `ScalaFinatraGenerator`. | |
| 37 | 37 | ||
| 38 | + #### Use your new generator with the CLI | ||
| 39 | + | ||
| 38 | 40 | To compile your library, enter the `out/generators/my-codegen` directory, run `mvn package` and execute the generator: | |
| 39 | 41 | ||
| 40 | 42 | ```sh | |
@@ -50,11 +52,59 @@ Note the `my-codegen` is an option for `-g` now, and you can use the usual argum | |||
| 50 | 52 | ||
| 51 | 53 | ```sh | |
| 52 | 54 | java -cp out/codegens/customCodegen/target/my-codegen-openapi-generator-1.0.0.jar:modules/openapi-generator-cli/target/openapi-generator-cli.jar \ | |
| 53 | - io.openapitools.codegen.OpenAPIGenerator generate -g my-codegen \ | ||
| 55 | + org.openapitools.codegen.OpenAPIGenerator generate -g my-codegen \ | ||
| 54 | 56 | -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml \ | |
| 55 | 57 | -o ./out/myClient | |
| 56 | 58 | ``` | |
| 57 | 59 | ||
| 60 | + For Windows users: | ||
| 61 | + ``` | ||
| 62 | + java -cp out/codegens/customCodegen/target/my-codegen-openapi-generator-1.0.0.jar;modules/openapi-generator-cli/target/openapi-generator-cli.jar \ | ||
| 63 | + org.openapitools.codegen.OpenAPIGenerator generate -g my-codegen \ | ||
| 64 | + -i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml \ | ||
| 65 | + -o ./out/myClient | ||
| 66 | + ``` | ||
| 67 | + | ||
| 68 | + #### Use your new generator with the maven plugin | ||
| 69 | + | ||
| 70 | + Install your library to your local maven repository by running: | ||
| 71 | + | ||
| 72 | + ``` | ||
| 73 | + mvn clean install -f out/generators/my-codegen | ||
| 74 | + ``` | ||
| 75 | + | ||
| 76 | + This will install `org.openapitools:my-codegen-openapi-generator:1.0.0` to your local maven repository. | ||
| 77 | + | ||
| 78 | + You can use this as additional dependency of the `openapi-generator-maven-plugin` plugin and use `my-codegen` as `generatorName` value: | ||
| 79 | + | ||
| 80 | + ```xml | ||
| 81 | + <plugin> | ||
| 82 | + <groupId>org.openapitools</groupId> | ||
| 83 | + <artifactId>openapi-generator-maven-plugin</artifactId> | ||
| 84 | + <version>${openapi-generator-version}</version> | ||
| 85 | + <executions> | ||
| 86 | + <execution> | ||
| 87 | + <id>generate-client-code</id> | ||
| 88 | + <goals> | ||
| 89 | + <goal>generate</goal> | ||
| 90 | + </goals> | ||
| 91 | + <configuration> | ||
| 92 | + <generatorName>my-codegen</generatorName> | ||
| 93 | + <!-- other configuration ... --> | ||
| 94 | + </configuration> | ||
| 95 | + </execution> | ||
| 96 | + </executions> | ||
| 97 | + <dependencies> | ||
| 98 | + <dependency> | ||
| 99 | + <groupId>org.openapitools</groupId> | ||
| 100 | + <artifactId>my-codegen-openapi-generator</artifactId> | ||
| 101 | + <version>1.0.0</version> | ||
| 102 | + </dependency> | ||
| 103 | + </dependencies> | ||
| 104 | + </plugin> | ||
| 105 | + ``` | ||
| 106 | + | ||
| 107 | + If you publish your artifact to a distant maven repository, do not forget to add this repository as `pluginRepository` for your project. | ||
| 58 | 108 | ||
| 59 | 109 | ### Selective generation | |
| 60 | 110 | You may not want to generate *all* models in your project. Likewise you may want just one or two apis to be written. If that's the case, you can use system properties to control the output: | |
| Back | FazBrowse Home | New Git URL |
0 commit comments