Skip to content

OpenAPI-derived models

Everything /api/openapi.json#/components/schemas describes, emitted as pydantic + StrEnum by the OAS codegen. v42 ships 562 classes + 260 StrEnums + 104 scalar aliases under dhis2w_client.generated.v42.oas.

Most callers reach these models indirectly — the domain shims re-export the relevant slices:

  • dhis2w_client.envelopesWebMessage (as WebMessageResponse subclass), ImportReport, ObjectReport, TypeReport, Stats, ErrorReport, ImportCount, ImportConflict (as Conflict).
  • dhis2w_client.aggregateDataValue, DataValueSet.
  • dhis2w_client.systemSystemInfo.
  • dhis2w_client.maintenanceDataIntegrityCheck, DataIntegrityIssue.
  • dhis2w_client.auth_schemes — the 5 *AuthScheme leaves (each subclassed to add the type discriminator).
  • dhis2w_client.generated.v42.trackerTrackerTrackedEntity, TrackerEnrollment, TrackerEvent, TrackerRelationship, TrackerRelationshipItem, TrackerDataValue, TrackerAttribute, TrackerNote, plus EnrollmentStatus / EventStatus.

Import directly from the OAS module when you need a shape the shims don't expose — e.g. TrackerImportReport, Grid, AppIcons, any of the 400+ admin-parameters / dimension-item / filter-wrapper schemas:

from dhis2w_client.generated.v42.oas import TrackerImportReport, Grid

report = TrackerImportReport.model_validate(raw)
grid = Grid.model_validate(analytics_response)

Regeneration (from the committed openapi.json, no network):

uv run dhis2 dev codegen oas-rebuild --version v42

See Codegen for emitter specifics — every-field-optional rule, the _MAX_CLOSED_ENUM_SIZE threshold that demotes 488-member ErrorCode to a str alias, the DHIS2Warning builtin-shadow rename, the _types_namespace injection trick that resolves sibling references without cycles.

The __all__ list on dhis2w_client.generated.v42.oas holds every emitted symbol.