diff --git a/modules/openapi-generator-maven-plugin/README.md b/modules/openapi-generator-maven-plugin/README.md index 3f267b41f7e..2d02194aab3 100644 --- a/modules/openapi-generator-maven-plugin/README.md +++ b/modules/openapi-generator-maven-plugin/README.md @@ -91,6 +91,7 @@ mvn clean compile | `reservedWordsMappings` | `openapi.generator.maven.plugin.reservedWordsMappings` | specifies how a reserved name should be escaped to. Otherwise, the default `_` is used. For example `id=identifier`. You can also have multiple occurrences of this option | `skipIfSpecIsUnchanged` | `codegen.skipIfSpecIsUnchanged` | Skip the execution if the source file is older than the output folder (`false` by default. Can also be set globally through the `codegen.skipIfSpecIsUnchanged` property) | `engine` | `openapi.generator.maven.plugin.engine` | The name of templating engine to use, "mustache" (default) or "handlebars" (beta) +| `httpUserAgent` | `openapi.generator.maven.plugin.httpUserAgent` | Sets custom User-Agent header value ### Custom Generator diff --git a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java index 552a44f2563..3cbb6093cc6 100644 --- a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java +++ b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java @@ -206,6 +206,12 @@ public class CodeGenMojo extends AbstractMojo { @Parameter(name = "ignoreFileOverride", property = "openapi.generator.maven.plugin.ignoreFileOverride", required = false) private String ignoreFileOverride; + /** + * Sets custom User-Agent header value + */ + @Parameter(name = "httpUserAgent", property = "openapi.generator.maven.plugin.httpUserAgent", required = false) + private String httpUserAgent; + /** * To remove operationId prefix (e.g. user_getName => getName) */ @@ -462,6 +468,10 @@ public class CodeGenMojo extends AbstractMojo { configurator.setIgnoreFileOverride(ignoreFileOverride); } + if (isNotEmpty(httpUserAgent)) { + configurator.setHttpUserAgent(httpUserAgent); + } + if (skipValidateSpec != null) { configurator.setValidateSpec(!skipValidateSpec); }