Skip to content

Code Generation Pipeline

Medipal's CI pipeline automatically generates typed clients and models from the schema definitions whenever mp-schema changes.

Pipeline Steps

  1. Validate — JSON Schema files are validated for correctness
  2. Generate OpenAPI specifications — derive OpenAPI 3.x specs from schema definitions
  3. Generate TypeScript API clientsmp-typescript-api-generator + mp-typescript-api-generator-templates produce three typed Axios clients:
    • mp-frontend-api — admin frontend client
    • mp-mobile-app-api — mobile app client
    • mp-mobile-app-tracker-api — tracker client (from mp-tracker-api-spec)
  4. Generate Python modelsgenma + yamser produce four server-side modules:
    • mp-server-pydantic-models — Pydantic v2 request/response models
    • mp-server-sql-alchemy-models — SQLAlchemy 2.0 ORM models
    • mp-server-api — FastAPI route stubs
    • mp-server-config-schema — application configuration schema
  5. Publish — generated packages are published to GitHub Packages (npm) and consumed as git submodules (Python)

Tooling

ToolLanguageRole
genmaPythonCode generation engine — reads schema definitions, produces source files via Jinja2 templates
yamserPythonYAML serialisation/deserialisation with schema validation and reference resolution
mp-typescript-api-generatorTypeScriptCLI tool wrapping swagger-typescript-api with Medipal-specific configuration
mp-typescript-api-generator-templatesETATemplates controlling the shape of generated Api classes, method signatures, and type exports
mp-typescript-api-validationTypeScriptAJV-based runtime request validation, used by frontend and mobile to validate payloads before sending

Generated Artefacts

RepositoryTypeConsumer
mp-frontend-apiTypeScript API clientmp-frontend
mp-mobile-app-apiTypeScript API clientmp-mobile-app
mp-mobile-app-tracker-apiTypeScript API clientmp-mobile-app
mp-server-pydantic-modelsPython Pydantic modelsmp-server
mp-server-sql-alchemy-modelsPython SQLAlchemy ORMmp-server
mp-server-apiFastAPI route definitionsmp-server
mp-server-config-schemaConfiguration schemamp-server

Never edit manually

These repositories are regenerated on every mp-schema push. Manual edits will be overwritten.

Triggering Generation

Generation runs automatically on push to the mp-schema main branch and can be triggered manually via GitHub Actions.

See Platform Architecture for how these artefacts fit into the full dependency graph.