Generate Project Using API Specs

Generate Project Stub

Overview

This page provides detailed steps for generating projects using the given API specifications.

Steps

Build A Microservice

  1. Prepare Swagger arrow-up-rightcontracts that detail all the APIs that the service is going to expose for external consumption. eGov uses a customised Swagger Codegen arrow-up-righttool.

  2. Download the jar file and make sure it is available in the classpath. Use the Swagger Codegen toolarrow-up-right to generate client SDKs using these Swagger contracts.

circle-info

Refer to the following tutorials to understand the creation of Swagger contracts -

OpenAPI 3.0 Tutorial| Swagger Tutorial For Beginners | Design REST API Using Swagger Editorarrow-up-right

Generate API Skeleton

  1. Use the generic command below to create an API skeleton for any Swagger contract:

circle-info
java -jar codegen-2.0-SNAPSHOT-jar-with-dependencies.jar 
-l -t -u {CONTRACT_PATH } -a project_name -b digit

The following sequence is used to generate the API skeleton using codegen jar:

  1. Navigate to the folder where you have downloaded the codegen jar.

  2. Execute the following command:

OR

Download the contract available here arrow-up-rightand save it in a file locally. Run the following command to generate the skeleton code from the contract.

  1. Rename the output folder to birth-registration.

  2. Import it in Eclipse or VS Code.

  3. Update the spring-boot-starter-parent to 3.2.2 in pom.xml.

  4. Perform a maven update once the spring boot version is updated.

  5. Put a slash in front of server.contextPath and add this property to the application.properties file which helps request handlers to serve requests -

  1. Add the below external dependencies to pom.xml:

Last updated

Was this helpful?