OpenAPI
TUMApply uses OpenAPI Generator to generate client code from the server-side API.
Development Workflow
We follow a server-first approach:
- Develop the server-side endpoint — implement the REST controller, DTOs, and service logic
- Generate the OpenAPI spec — extract the spec from the server annotations
- Generate the client code — produce TypeScript API services and model interfaces from the spec
- Use only the generated code on the client — always import API services and models from
src/main/webapp/app/generated
Do not create custom interfaces or service wrappers on the client to call API endpoints. Always use the generated API services and model interfaces. If a generated endpoint is not compatible with your use case, discuss it with an admin — exceptions can be made on a case-by-case basis.
Structure
openapi/openapi.yaml: The central OpenAPI definition file- Generated client files go to:
src/main/webapp/app/generated
Generate OpenAPI Spec from Annotations
To generate a new openapi.yaml from the Spring annotations in the codebase, run:
./gradlew generateApiDocs -x webapp
This outputs the updated spec to openapi/openapi.yaml based on the server-side code annotations.
Generate Client API Services
To generate the TypeScript Angular client services based on the openapi.yaml file, run:
./gradlew openApiGenerate
This generates the API services and model interfaces into src/main/webapp/app/generated.
Notes
- Always validate
openapi.yamlin tools like Swagger Editor - Follow consistent naming for paths and parameters
- Define enums explicitly (avoid using
stringif enum is expected) - Use
operationIdconsistently for better client generation