Skip to content

antnettleship/openapi-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

OpenApi Generated Code Example

Backend: A SpringBoot application configured to generate both Java code and TypeScript client code from an OpenApi specification.

Frontend: A Next.js using the generated client to call the backend API.

Generation

The openapi spec is defined in backend/src/main/resources/api/books.yaml.

Maven OpenAPI Generator is configured in pom.xml to generate the following:

Java

Note: This can be configured to build and publish a separate jar rather than local files (e.g. if required by another Java client service).

TypeScript

Note: This should be configured to publish an npm library ideally, but working with local files for the purposes of this demo.

Run

Pre-requisites

  • Maven
  • Java 17
  • node >= 18.17.0

Backend

From the backend directory:

# Build and publish generated code
mvn clean install
# Run the app
mvn spring-boot:run

Testing

See BooksControllerIT.java for a demonstrative integration test.

Frontend

From the frontend directory:

# Install dependencies
npm install
# Run the app
npm run dev

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published