Skip to content

Reconcile spec with Wonde docs, add groups endpoint, regenerate on pydantic-v2-native generator - #4

Open
johndagostino wants to merge 3 commits into
mainfrom
feat/class-type-and-groups
Open

Reconcile spec with Wonde docs, add groups endpoint, regenerate on pydantic-v2-native generator#4
johndagostino wants to merge 3 commits into
mainfrom
feat/class-type-and-groups

Conversation

@johndagostino

Copy link
Copy Markdown

Needed by Edrolo Admin Hub work that lets schools choose which Wonde timetable data to sync (class types + campus). Three separable commits.

1. Reconcile the spec with the docs (66756b2)

Wonde publishes no OpenAPI document, so meta/wonde.openapi.yaml is hand-authored against the prose docs and drifts silently. It had. Audited every endpoint this client exposes; findings recorded in the new meta/DRIFT.md.

Resource Drift Action
Classes type url parameter never transcribed Added (plain string — it takes a comma-separated list, so an enum would reject valid input)
Classes students.enrolments missing from the include enum (list + detail) Added
Classes object missing type, priority, academic_year, year_group Added, nullable
Students classes.enrolments and regional_data missing from include Added
Students upfsm_date_ranges — no such include Corrected to upfsm_exception_date_ranges
Students object missing title, gender_identity Added, nullable
Students gender enumerated [male, female] Enum dropped — see below
Groups resource absent Added listSchoolGroups + Group schema
Employees / Subjects / Lessons / Schools / Deletions none — checked, faithful

The Student.gender enum was a latent landmine

enum: [male, female] generated a real validator in wonde/models/student.py that raises ValueError on anything else. The docs list six values: male, female, intersex or indeterminate, not stated/inadequately described, redacted for privacy, other.

Not currently breaking — sync works today, so Wonde must be returning the two common values — but one student with any of the other four would have failed that school's entire sync. The spec also contradicted itself, pairing a lower-case enum with example: MALE. Replaced with a plain nullable string documenting all six.

Groups / campuses

Campuses are not a Wonde resource — a campus is a Group with type=CAMPUS, and campus membership is only ever an include, never a query filter. meta/TODO.md already tracked /groups as unimplemented; the list endpoint is now implemented (detail deliberately still isn't).

Scope held to the 24 existing operations plus listSchoolGroups. The ~30 other resources in the docs stay deliberately unimplemented.

2. Fix the generator script on macOS (3b78a8a)

id --user / id --group are GNU coreutils flags; BSD id rejects them outright (id: illegal option -- -), so the script could not run at all on a Mac. Switched to POSIX id -u / id -g. pre-commit is now invoked via uvx rather than assumed on PATH.

3. Regenerate on a pydantic-v2-native generator (440c27f)

This fixes a trap. .openapi-generator/VERSION was 7.0.1, but the python generator only moved to pydantic v2 in 7.1.0 (#16685). So 7.0.1 emits pydantic v1 code, and this repo's pydantic v2 support was a hand-patch over generated output (3ce2d7c, editing 9 files to swap validate_argumentsvalidate_call and Field(const=True)Field(default=...)).

Any regeneration silently reverted that patch. Bumping to v7.24.0 makes the generator emit pydantic v2 natively, so the patch is unnecessary and the trap is gone. Floor and rationale documented in README.md and the script.

⚠️ Breaking: ApiClient.last_response removed

v7.x drops it. Consumers reading raw response bodies must switch to the *_with_http_info variants, whose ApiResponse carries both .data (deserialized) and .raw_data (raw body) — one request, both representations.

Edrolo's wonde_sync/strategies.py depended on this and has been updated in the corresponding Edrolo PR. Worth checking any other consumer: the failure is quiet where the access is wrapped in except AttributeError.

Verification

  • 25 operations (24 existing + listSchoolGroups); operation-set diff shows exactly one addition and no removals
  • All 28 $refs resolve
  • No validate_arguments / const=True anywhere in generated output
  • Public API surface diffed before/after: no methods removed, every business parameter name preserved (only **kwargs → explicit _request_* params)
  • Against Edrolo's suite: 800 backend tests pass, including full wonde_sync

Wonde publishes no OpenAPI document, so this spec is hand-authored against the
prose docs and had drifted. Reconciled the endpoints the client exposes:

- classes: the documented 'type' filter was never transcribed, along with the
  type/priority/academic_year/year_group object fields and the
  students.enrolments include
- students: classes.enrolments and regional_data includes were missing, and
  upfsm_date_ranges is not a real include (upfsm_exception_date_ranges is);
  title and gender_identity were missing from the object
- students: gender enumerated (male, female), which generated an enforced
  validator. The docs list six values, so one student with any of the other
  four would have failed the school's whole sync. Enum dropped.

Adds the groups endpoint, which is how campuses are modelled upstream.
See meta/DRIFT.md.
id --user/--group are GNU coreutils flags and fail on BSD id; pre-commit is not
assumed to be on PATH.
Replaces the hand-patched pydantic v2 compatibility from 3ce2d7c. The python
generator emits pydantic v2 natively from v7.1.0, so the patch is no longer
needed and regeneration no longer silently reverts it.

Also picks up the spec reconciliation from 66756b2: the classes 'type' filter,
the new class object fields, and the groups endpoint.

BREAKING: ApiClient.last_response is gone. Use the *_with_http_info variants,
whose ApiResponse carries both .data and .raw_data.

The blue hook pinned python3.8, which is EOL and unavailable, so it could not
build its environment; relaxed to python3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant