=== Required Dependencies

A `RestProducerFactory` implementation must be available when using the rest-openapi extension. The currently known extensions are:

* camel-quarkus-http
ifeval::[{doc-show-advanced-features} == true]
* camel-quarkus-netty-http
endif::[]

Maven users will need to add one of these dependencies to their `pom.xml`, for example:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-http</artifactId>
</dependency>
----

Depending on which mechanism is used to load the OpenApi specification, additional dependencies may be required. When using the `file` resource locator, the `org.apache.camel.quarkus:camel-quarkus-file` extension must be added as a project dependency. When using `ref` or `bean` to load the specification, not only must the `org.apache.camel.quarkus:camel-quarkus-bean` dependency be added, but the bean itself must be annotated with `@RegisterForReflection`.

When using the `classpath` resource locator with native code, the path to the OpenAPI specification must be specified in the `quarkus.native.resources.includes` property of the `application.properties` file. For example:

[source]
----
quarkus.native.resources.includes=openapi.json
----

=== Contract First Development
The model classes generation has been integrated with the `quarkus-maven-plugin`. So there's no need to use the `swagger-codegen-maven-plugin`, instead put your contract files in `src/main/openapi` with a `.json` suffix. And add the `generate-code` goal to the `quarkus-maven-plugin` like:

[source,xml]
----
<plugin>
    <groupId>io.quarkus</groupId>
    <artifactId>quarkus-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>generate-code</goal>
            </goals>
        </execution>
    </executions>
</plugin>
----

It requires a specific package name for the model classes by using the `quarkus.camel.openapi.codegen.model-package` property of the `application.properties` file. For example:

[source,properties]
----
quarkus.camel.openapi.codegen.model-package=org.acme
----
This package name should be added in `camel.rest.bindingPackageScan` as well.

The contract files in `src/main/openapi` needs to be added in the classpath since they could be used in Camel Rest DSL. So you can add `src/main/openapi` in `pom.xml`

[source,xml]
----
<build>
    <resources>
        <resource>
            <directory>src/main/openapi</directory>
        </resource>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
    </resources>
</build>
----

When running in the native mode, the contract files must be specified the `quarkus.native.resources.include` like

[source,properties]
----
quarkus.native.resources.includes=contract.json
----

[IMPORTANT]
====
It's recommended to configure a base path under which your REST service endpoints will be accessible.

Using the default path `/` can result in other HTTP endpoints already hosted under that path being inaccessible.

To set a base path, do any one of the following.

* Add https://swagger.io/docs/specification/v3_0/api-host-and-base-path/[servers configuration] into your OpenAPI spec file.
* Add configuration to `application.properties` like `camel.component.rest-openapi.basePath=/api/v1`.
* Set a context path on the REST DSL configuration like `restConfiguration().contextPath("/api/v1")`.
====
