Backend-frontend parallel development: OpenApi
Apr 26, 2022
This blog is part of series: Itchy guy and his quest for Zen
We will look at:
- Problem
- Weakly typed api contract sharing with no comments
- Frontend waits for backend to complete api development
- Manual writing of request/response models and api methods in calling services - Define Api contracts before starting development
- Viewing Api contract on different tools(web, vscode)
- Auto generate server interface and client code with:
- cli
- gradle build script - Publish as client library for use by calling services
Define and view contract
View on web: https://editor.swagger.io/
Ide Integration:
# if you just want to preview apis and models:
code --install-extension Arjun.swagger-viewer
code /path/to/greeting_api.yml# cmd+shift+p -> `Preview Swagger`. A preview window will open on side with similar view as webapp # For editing and code auto-completion
code --install-extension 42Crunch.vscode-openapi