This project is to leran how to define OpenAPI specification and generate REST client using Quarkus.
-
Start the server in dev mode
./mvnw compile quarkus:dev -pl server
Live Coding is enabled and the Dev UI is available at
http://localhost:8080/q/dev/. When you need to refresh the OpenAPI document, launch the server on another port (for example,-Dquarkus.http.port=8888) and runmake download_openapi_yamlto store the definition inserver/openapi-definition/openapi.yaml, making it easy to compare with generated clients. -
Develop REST clients
After updating the server OpenAPI spec, run
./mvnw quarkus:generate-code -pl clientto regenerate the REST client stubs. Follow it with./mvnw test -pl clientto execute unit and integration tests for the client and ensure that the generated code stays in sync. -
Shared tooling
Download the Java formatter via
make get_google_java_format, then applymake fix_import_onlyormake reformat_java_filesbefore submitting changes.
-
Package the server
./mvnw package -pl server
A runnable JAR (
quarkus-run.jar) and its dependencies are produced inserver/target/quarkus-app/. Add-Dquarkus.package.type=uber-jarif you need a single executable JAR. -
Build a fat (über) JAR
./mvnw package -Dquarkus.package.type=uber-jar -pl server
The resulting file
server/target/quarkus-rest-client-example-server-*-runner.jaris self-contained and can be copied to any JVM 17 host without the accompanyinglibdirectory. -
Run the packaged JAR
java -jar server/target/quarkus-app/quarkus-run.jar
If you produced an über-jar, start it with
java -jar server/target/*-runner.jar. -
Build container images
The
quarkus-container-image-jibplugin lets you produce OCI images and push them to a registry. Providequarkus.container-image.*properties inapplication.propertiesor via the command line../mvnw package -Dquarkus.container-image.build=true -pl server ./mvnw package -Dquarkus.container-image.build=true -Dquarkus.container-image.push=true -pl server
-
Optional native binary
With GraalVM or Mandrel configured, run
./mvnw package -Dnative -pl serverto produce a native executable and start it directly fromserver/target/*-runner.