This page outlines how you can use ApiHug to create quick demos in 15 minutes.

Prerequisites

  1. JDK 17+ OpenJDK or Oracle’s
  2. Gradle 8+
  3. IDEA 2022+
  4. ApiHug - API design Copilot

Plugin Install

  1. File
  2. Settings
  3. Plugin
  4. Search ApiHug
  5. Install & Restart
Install ApiHug Plugin

Project Wizard

ApiHug - API design Copilot provides a highly friendly and intuitive project template to kickstart your API development. It guides you through step-by-step creation of API projects that adhere to best practices.

01-Start ApiHug Project

  1. File
  2. New -> Project
  3. ApiHug
Start project from ApiHug Plugin

02-Project Settings

  1. Project settings
  2. package
  3. name
  4. description
  5. SDK Settings
  6. version
  7. DB Vendor
  8. Cache
  9. Port
ApiHug Project Settings

03-Spring Settings

This is a standard Start Spring configuration:

  1. Select Type
  2. Choice the components for example Spring Web
ApiHug Project Spring Settings

Eventually click Create -> Open Project to open the project:

04-Start Project

The SDK version may update while our project goes on;please check:

For an exist project, then you can upgrade them manually:

  1. YOUR_PROJECT > gradle > libs.versions.toml
  2. apihug = "0.9.2-RELEASE" update to latest version

Follow the IDEA’s instruction:

  1. load this project as Gradle, if not please manually reload(check Notification)
  2. two modules demo-app-proto & demo-app should be recognized
ApiHug Load Project

The simplest project layout will be like (simplest-demo):

+---gradle
|   |   libs.versions.toml  (1)
+---demo-app  (2)
|   |   build.gradle
|   \---src
|       \---main
|           +---java
|           |   \---com
|           |       \---apihug
|           |           \---demo
|           |               |   DemoAppApplication.java
|           |               +---domain
|           |               \---service
|           \---resources
|               |   hope-stub.json  (3)
|
+---demo-app-proto (4)
|   |   build.gradle
|   \---src
|       \---main
|           +---proto
|           |   \---com
|           |       \---apihug
|           |           \---demo
|           |               \---proto
|           |                   +---api
|           |                   \---infra
|           \---resources
|                   hope-wire.json (5)
FileComment
(1) libs.versions.tomlVersion toml configuration
(2) demo-appApplication module
(3) hope-stub.jsonApplication module configuration
(4) demo-app-protoProtocol module
(5) hope-wire.jsonProtocol module configuration
# libraries
apihug = "0.9.9-RELEASE"
# plugins
springBoot = "3.2.5"
springDependency = "1.1.4"

#Apihug Common
apihugBom = { group = "com.apihug", name = "it-bom", version.ref = "apihug" }

#Spring plugin
springBoot = { id = "org.springframework.boot", version.ref = "springBoot" }
springDependency = { id = "io.spring.dependency-management", version.ref = "springDependency" }

04.1-Wire

Wire task of the proto module response for verify and compile the protocol buffers files.

  1. Open README.md > 0. Build All;
  2. find the command, parse to the Terminal, Example: gradlew clean build -x test -x wireTest -x stubTest;
  3. press Enter to execute;
  4. Check the demo-app-proto path main > wire for updates;
ApiHug Wire Project

04.2-Stub

Stub task of the application module response for generate the stub code from the protocol definition.

  1. Open README.md > 2. Build Stub (Individual);
  2. find the command, parse to the Terminal, Example: gradlew.bat demo-app:clean stub build -x test -x stubTest;
  3. press Enter to execute;
  4. Check the demo-app path main > stub for updates;
ApiHug Stub Project

04.3-Boot

  1. Open README.md > 3. Run Application;
  2. find the command, parse to the Terminal, Example: gradlew demo-app:bootRun;
  3. press Enter to execute;
  4. Check the log print of demo-app;
ApiHug Spting Boot
----------------------------------------------------------

Application 'demo-app' is running! Access URLs:

Local                             http://localhost:18089/
External                          http://192.168.0.115:18089/
OAS                               http://192.168.0.115:18089/v3/api-docs
Actuator                          http://192.168.0.115:18089/management
Api-Errors                        http://192.168.0.115:18089/hope/meta/errors
Api-Dictionaries                  http://192.168.0.115:18089/hope/meta/dictionaries
Api-Authorities                   http://192.168.0.115:18089/hope/meta/authorities
Profile(s)                        dev

04.4-Check OAS

  1. copy the url(/v3/api-docs) from the console;
  2. parse them in the Chrome to view;
ApiHug API Information

ApiHug Tool Window

ApiHug Tool Window should dock on the right side of the IDE, if not you can also bring it up from the top menu bar: ApiHug > ApiHug Designer:

ApiHug Tool Window

Congratulations! You have successfully finished a perfect API development joinery!

Summary

During the last 15-minute demo, we went through the typical steps involved in API design and development. These steps often include various trivial tasks that distract us from focusing on the core business logic design. However, with ApiHug, you can leave behind all the tedious and troublesome steps.

ApiHug automates these tasks and generates high-quality designs with a user-friendly and easily understandable structure and code details. In the upcoming lessons, we will delve deeper into exploring the capabilities of ApiHug.

In fact, the techniques used by ApiHug are not entirely new inventions. Platforms like Jhipster, Spring Starter, Grails, and Ruby on Rails have paved the way for similar approaches.

ApiHug builds upon the best practices and lessons learned from these predecessors, making them more practical and straightforward for everyday use. We acknowledge and appreciate the contributions of these platforms in shaping the foundation of ApiHug.