Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contract first development section in rest-openapi doc #6115

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions docs/modules/ROOT/pages/reference/extensions/rest-openapi.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,58 @@ When using the `classpath` resource locator with native code, the path to the Op
quarkus.native.resources.includes=openapi.json
----

[id="extensions-rest-openapi-usage-contract-first-development"]
=== 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
----

Please refer to https://camel.apache.org/manual/rest-dsl-openapi.html#_contract_first[Camel Rest DSL Contract First] for more details.


[id="extensions-rest-openapi-additional-camel-quarkus-configuration"]
== Additional Camel Quarkus configuration
Expand Down
53 changes: 52 additions & 1 deletion extensions/rest-openapi/runtime/src/main/doc/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,55 @@ When using the `classpath` resource locator with native code, the path to the Op
[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
----

Please refer to https://camel.apache.org/manual/rest-dsl-openapi.html#_contract_first[Camel Rest DSL Contract First] for more details.