Follow these steps to use REST Builder to create a headless REST API for your app:
Create a project.
Install REST Builder. For instructions on this, see REST Builder Gradle Plugin.
gradlew clean deploy. Note that your Gradle wrapper may not be in your app’s project directory, so you may need to use
..to locate it (e.g.,
../../../gradlew clean deploy).
*-implprojects with the usual files (
bnd.bnd). Also create a
rest-config.yamlwith the author, paths, and packages. For example, here’s the
apiDir: "../headless-delivery-api/src/main/java" apiPackagePath: "com.liferay.headless.delivery" application: baseURI: "/headless-delivery" className: "HeadlessDeliveryApplication" name: "Liferay.Headless.Delivery" author: "Javier Gamarra" clientDir: "../headless-delivery-client/src/main/java" testDir: "../headless-delivery-test/src/testIntegration/java"
*-implmodule’s root folder, write your OpenAPI profile in YAML. You can use the Swagger Editor to validate syntax and ensure compliance with the OpenAPI specification.
*-implmodule or root module folder, run
gradlew buildREST(make sure you locate your Gradle wrapper as instructed in step two above).
REST Builder generates the interfaces with the JAX-RS endpoints. It also generates a
*ResourceImplclass where you must implement the business logic for each service.
After implementing the business logic for each service, deploy your modules. Your APIs are then available at this URL:
You can also execute
jaxrs:checkin the OSGi console to see all the JAX-RS endpoints.