This example shows you a complete working application with vertx-web-api-service & vertx-web-api-contract.
You have three packages:
models: Contains all models of your application. They are annotated as@DataObjectso you can use it in other Vert.x interfaces.persistence: Contains the interfaces and implementations of persistence of your application.services: Contains the Web Api Services interfaces and implementations
The class WebApiServiceExampleMainVerticle contains the code that bootstrap your router using OpenAPI3RouterFactory and mounts your services on event bus with ServiceBinder.
You can find the OpenAPI spec under resources/openapi.json
On this directory run:
mvn clean package
java -jar target/web-api-service-example-3.6.0-fat.jarThen post a transaction with curl:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"id": "xdg-hjhj98", "from":"thomas@example.com","to":"francesco@example.com", "message": "items", "value": 45.67}' \
http://localhost:8080/api/transactions
curl http://localhost:8080/api/transactionsEventually check the recorded transactions:
curl http://localhost:8080/api/transactions