Build Spring Boot REST endpoints (APIs) by defining entities and CRUD operations. The grammar of this DSL automatically generates the Spring Boot REST files (application, entity, repository, service and controller classes, pom file, etc.). Once generated the files (under src-gen folder), you can run the project (structured as a Maven project) either using a command-line console (with the command:
mvn spring-boot:run) or importing the Maven project using a Java IDE.
Once installed this plugin, open a new project (generic project), new file (remember to use the .g2 as extension file). Select yes in case a window prompts you to convert the project to an Xtext project, this in order to generate the code each time you save the source file (.g2 file).
Click in this link to see an example of the language grammar.
This example will produce the corresponding Spring Boot Java files such as:
OrderController.java, also the main file
DemoAppApplication.java and the maven pom file
pom.xml. The CRUD operations specified in the entities are exposed as REST services (
OrderController.java). By default, the H2 database is used, but you can change it in the
application.properties file. Data types supported are Long, UUID, String, Integer, Double, Boolean, Date and Time. An entity property can be filtered only by data types String and Date. CRUDyLeaf will generate the corresponding endpoints for searching in the filtered properties. Date and Time data types can automatically generate values each a successful post is requested. Concerning the time zone, it is possible to define any available from
TimeZone.getAvailableIDs(). A complete list of available time zones is discussed in this link.
(updated, version 1.1) The endpoints generated are documented using OpenAPI and Swagger. By default, you can access to this information once the Spring Boot application is run, accessing the following resource: /api-doc.html, however it is possible to change this resource name in the
You can import the resulting spring boot project through a java IDE or running it with the mvn command,
The plugin can be manually installed from the URL: