3.9. Camel REST DSL OpenApi Maven Plugin


The Camel REST DSL OpenApi Maven Plugin supports the following goals.

  • camel-restdsl-openapi:generate - To generate consumer REST DSL RouteBuilder source code from OpenApi specification
  • camel-restdsl-openapi:generate-with-dto - To generate consumer REST DSL RouteBuilder source code from OpenApi specification and with DTO model classes generated via the swagger-codegen-maven-plugin.
  • camel-restdsl-openapi:generate-xml - To generate consumer REST DSL XML source code from OpenApi specification
  • camel-restdsl-openapi:generate-xml-with-dto - To generate consumer REST DSL XML source code from OpenApi specification and with DTO model classes generated via the swagger-codegen-maven-plugin.
  • camel-restdsl-openapi:generate-yaml - To generate consumer REST DSL YAML source code from OpenApi specification
  • camel-restdsl-openapi:generate-yaml-with-dto - To generate consumer REST DSL YAML source code from OpenApi specification and with DTO model classes generated via the swagger-codegen-maven-plugin.

3.9.1. Adding plugin to Maven pom.xml

This plugin can be added to your Maven pom.xml file by adding it to the plugins section, for example in a Spring Boot application:

<build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>

    <plugin>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-restdsl-openapi-plugin</artifactId>
      <version>{CamelCommunityVersion}</version>
    </plugin>

  </plugins>
</build>

The plugin can then be executed using its prefix camel-restdsl-openapi as shown below.

$mvn camel-restdsl-openapi:generate

3.9.2. camel-restdsl-openapi:generate

The goal of the Camel REST DSL OpenApi Maven Plugin is used to generate REST DSL RouteBuilder implementation source code from Maven.

3.9.2.1. Options

The plugin supports the following options which can be configured from the command line (use -D syntax), or defined in the pom.xml file in the configuration tag.

Expand
ParameterDefault ValueDescription

skip

false

Set to true to skip code generation

filterOperation

 

Used for including only the operation ids specified. Multiple ids can be separated by comma. Wildcards can be used, eg find* to include all operations starting with find.

specificationUri

src/spec/openapi.json

URI of the OpenApi specification, supports filesystem paths, HTTP and classpath resources, by default src/spec/openapi.json within the project directory. Supports JSON and YAML.

auth

 

Adds authorization headers when fetching the OpenApi specification definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values.

className

from title or RestDslRoute

Name of the generated class, taken from the OpenApi specification title or set to RestDslRoute by default

packageName

from host or rest.dsl.generated

Name of the package for the generated class, taken from the OpenApi specification host value or rest.dsl.generated by default

indent

" "

Which indenting character(s) to use, by default four spaces, you can use \t to signify tab character

outputDirectory

generated-sources/restdsl-openapi

Where to place the generated source file, by default generated-sources/restdsl-openapi within the project directory

destinationGenerator

 

Fully qualified class name of the class that implements org.apache.camel.generator.openapi.DestinationGenerator interface for customizing destination endpoint

destinationToSyntax

direct:${operationId}

The default to syntax for the to uri, which is to use the direct component.

restConfiguration

true

Whether to include generation of the rest configuration with detected rest component to be used.

apiContextPath

 

Define openapi endpoint path if restConfiguration is set to true.

clientRequestValidation

false

Whether to enable request validation.

basePath

 

Overrides the api base path as defined in the OpenAPI specification.

requestMappingValues

/**

Allows generation of custom RequestMapping mapping values. Multiple mapping values can be passed as:

<requestMappingValues> <param>/my-api-path/</param> <param>/my-other-path/</param> </requestMappingValues>

3.9.3. Spring Boot Project with Servlet component

If the Maven project is a Spring Boot project and restConfiguration is enabled and the servlet component is being used as REST component, then this plugin will autodetect the package name (if packageName has not been explicitly configured) where the @SpringBootApplication main class is located, and use the same package name for generating Rest DSL source code and a needed CamelRestController support class.

3.9.4. camel-restdsl-openapi:generate-with-dto

Works as generate goal but also generates DTO model classes by automatic executing the swagger-codegen-maven-plugin to generate java source code of the DTO model classes from the OpenApi specification.

This plugin has been scoped and limited to only support a good effort set of defaults for using the swagger-codegen-maven-plugin to generate the model DTOs. If you need more power and flexibility then use the Swagger Codegen Maven Plugin directly to generate the DTO and not this plugin.

The DTO classes may require additional dependencies such as:

    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.10.1</version>
    </dependency>
    <dependency>
      <groupId>io.swagger.core.v3</groupId>
      <artifactId>swagger-core</artifactId>
      <version>2.2.8</version>
    </dependency>
    <dependency>
      <groupId>org.threeten</groupId>
      <artifactId>threetenbp</artifactId>
      <version>1.6.8</version>
    </dependency>

3.9.4.1. Options

The plugin supports the following additional options

Expand
ParameterDefault ValueDescription

swaggerCodegenMavenPluginVersion

3.0.36

The version of the io.swagger.codegen.v3:swagger-codegen-maven-plugin maven plugin to be used.

modelOutput

 

Target output path (default is ${project.build.directory}/generated-sources/openapi)

modelPackage

io.swagger.client.model

The package to use for generated model objects/classes

modelNamePrefix

 

Sets the pre- or suffix for model classes and enums

modelNameSuffix

 

Sets the pre- or suffix for model classes and enums

modelWithXml

false

Enable XML annotations inside the generated models (only works with libraries that provide support for JSON and XML)

configOptions

 

Pass a map of language-specific parameters to swagger-codegen-maven-plugin

3.9.5. camel-restdsl-openapi:generate-xml

The camel-restdsl-openapi:generate-xml goal of the Camel REST DSL OpenApi Maven Plugin is used to generate REST DSL XML implementation source code from Maven.

3.9.5.1. Options

The plugin supports the following options which can be configured from the command line (use -D syntax), or defined in the pom.xml file in the <configuration> tag.

Expand
ParameterDefault ValueDescription

skip

false

Set to true to skip code generation.

filterOperation

 

Used for including only the operation ids specified. Multiple ids can be separated by comma. Wildcards can be used, eg find* to include all operations starting with find.

specificationUri

src/spec/openapi.json

URI of the OpenApi specification, supports filesystem paths, HTTP and classpath resources, by default src/spec/openapi.json within the project directory. Supports JSON and YAML.

auth

 

Adds authorization headers when fetching the OpenApi specification definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values.

outputDirectory

generated-sources/restdsl-openapi

Where to place the generated source file, by default generated-sources/restdsl-openapi within the project directory

fileName

camel-rest.xml

The name of the XML file as output.

blueprint

false

If enabled generates OSGi Blueprint XML instead of Spring XML.

destinationGenerator

 

Fully qualified class name of the class that implements org.apache.camel.generator.openapi.DestinationGenerator interface for customizing destination endpoint

destinationToSyntax

direct:${operationId}

The default to syntax for the to uri, which is to use the direct component.

 

restConfiguration

true

Whether to include generation of the rest configuration with detected rest component to be used.

apiContextPath

 

Define openapi endpoint path if restConfiguration is set to true.

clientRequestValidation

false

Whether to enable request validation.

basePath

 

Overrides the api base path as defined in the OpenAPI specification.

requestMappingValues

/**

3.9.6. camel-restdsl-openapi:generate-xml-with-dto

Works as generate-xml goal but also generates DTO model classes by automatic executing the swagger-codegen-maven-plugin to generate java source code of the DTO model classes from the OpenApi specification.

This plugin has been scoped and limited to only support a good effort set of defaults for using the swagger-codegen-maven-plugin to generate the model DTOs. If you need more power and flexibility then use the Swagger Codegen Maven Plugin directly to generate the DTO and not this plugin.

The DTO classes may require additional dependencies such as:

    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.10.1</version>
    </dependency>
    <dependency>
      <groupId>io.swagger.core.v3</groupId>
      <artifactId>swagger-core</artifactId>
      <version>2.2.8</version>
    </dependency>
    <dependency>
      <groupId>org.threeten</groupId>
      <artifactId>threetenbp</artifactId>
      <version>1.6.8</version>
    </dependency>

3.9.6.1. Options

The plugin supports the following additional options

Expand
ParameterDefault ValueDescription

swaggerCodegenMavenPluginVersion

3.0.36

The version of the io.swagger.codegen.v3:swagger-codegen-maven-plugin maven plugin to be used.

modelOutput

 

Target output path (default is ${project.build.directory}/generated-sources/openapi)

modelPackage

io.swagger.client.model

The package to use for generated model objects/classes

modelNamePrefix

 

Sets the pre- or suffix for model classes and enums

modelNameSuffix

 

Sets the pre- or suffix for model classes and enums

modelWithXml

false

Enable XML annotations inside the generated models (only works with libraries that provide support for JSON and XML)

configOptions

 

Pass a map of language-specific parameters to swagger-codegen-maven-plugin

3.9.7. camel-restdsl-openapi:generate-yaml

The camel-restdsl-openapi:generate-yaml goal of the Camel REST DSL OpenApi Maven Plugin is used to generate REST DSL YAML implementation source code from Maven.

3.9.7.1. Options

The plugin supports the following options which can be configured from the command line (use -D syntax), or defined in the pom.xml file in the <configuration> tag.

Expand
ParameterDefault ValueDescription

skip

false

Set to true to skip code generation.

filterOperation

 

Used for including only the operation ids specified. Multiple ids can be separated by comma. Wildcards can be used, eg find* to include all operations starting with find.

specificationUri

src/spec/openapi.json

URI of the OpenApi specification, supports filesystem paths, HTTP and classpath resources, by default src/spec/openapi.json within the project directory. Supports JSON and YAML.

auth

 

Adds authorization headers when fetching the OpenApi specification definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values.

outputDirectory

generated-sources/restdsl-openapi

Where to place the generated source file, by default generated-sources/restdsl-openapi within the project directory

fileName

camel-rest.xml

The name of the XML file as output.

destinationGenerator

 

Fully qualified class name of the class that implements org.apache.camel.generator.openapi.DestinationGenerator interface for customizing destination endpoint

destinationToSyntax

direct:${operationId}

The default to syntax for the to uri, which is to use the direct component.

 

restConfiguration

true

Whether to include generation of the rest configuration with detected rest component to be used.

apiContextPath

 

Define openapi endpoint path if restConfiguration is set to true.

clientRequestValidation

false

Whether to enable request validation.

basePath

 

Overrides the api base path as defined in the OpenAPI specification.

requestMappingValues

/**

3.9.8. camel-restdsl-openapi:generate-yaml-with-dto

Works as generate-yaml goal but also generates DTO model classes by automatic executing the swagger-codegen-maven-plugin to generate java source code of the DTO model classes from the OpenApi specification.

This plugin has been scoped and limited to only support a good effort set of defaults for using the swagger-codegen-maven-plugin to generate the model DTOs. If you need more power and flexibility then use the Swagger Codegen Maven Plugin directly to generate the DTO and not this plugin.

The DTO classes may require additional dependencies such as:

    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.10.1</version>
    </dependency>
    <dependency>
      <groupId>io.swagger.core.v3</groupId>
      <artifactId>swagger-core</artifactId>
      <version>2.2.8</version>
    </dependency>
    <dependency>
      <groupId>org.threeten</groupId>
      <artifactId>threetenbp</artifactId>
      <version>1.6.8</version>
    </dependency>

3.9.8.1. Options

The plugin supports the following additional options

Expand
ParameterDefault ValueDescription

swaggerCodegenMavenPluginVersion

3.0.36

The version of the io.swagger.codegen.v3:swagger-codegen-maven-plugin maven plugin to be used.

modelOutput

 

Target output path (default is ${project.build.directory}/generated-sources/openapi)

modelPackage

io.swagger.client.model

The package to use for generated model objects/classes

modelNamePrefix

 

Sets the pre- or suffix for model classes and enums

modelNameSuffix

 

Sets the pre- or suffix for model classes and enums

modelWithXml

false

Enable XML annotations inside the generated models (only works with libraries that provide support for JSON and XML)

configOptions

 

Pass a map of language-specific parameters to swagger-codegen-maven-plugin

Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 문서 정보

Legal Notice

Theme

© 2026 Red Hat
맨 위로 이동