Skip to content

Settle three API names before 1.1.0, and hold the OpenAPI specs to kebab-case - #2826

Merged
Flix6x merged 7 commits into
mainfrom
kebab-wire-names-openapi
Nov 5, 2026
Merged

Flix6x merged 7 commits into
mainfrom
kebab-wire-names-openapi

Conversation

@Flix6x

@Flix6x Flix6x commented Nov 5, 2026

Copy link
Copy Markdown
Member

Description

Settles the API names that 1.1.0 would otherwise ship in a spelling we'd have to support, and widens the naming test that should have caught one of them.

  • GET /sensors/<id>/status takes asset, not asset_id. The query parameter came in with Fix what the asset status page reports about its sensors #2474, after v1.0.1, so no release accepted asset_id and it is renamed without an alias. The sensor status page, its only caller, is updated. The sensor listing already takes asset (with asset_id as a legacy alias), so the two now agree.
  • Both DELETE sensor endpoints take start and end. They took start and until, where POST .../annotations and every other time window in the API take start and end.
    • DELETE /sensors/<id>/data shipped with until, so it keeps accepting until as a deprecated alias (via SupportsLegacyFieldAliases).
    • DELETE /sensors/<id>/annotations is new in 1.1.0, so it takes no alias and refuses until with a 422.
  • The naming test now also checks the published OpenAPI specs. test_field_naming.py (Hold new field names to kebab-case, and list the ones that predate it #2547) walks the Marshmallow schemas defined in FlexMeasures modules. That missed asset_id, because a parameter declared inline, as in @use_kwargs({"asset": AssetIdField(data_key="asset_id")}), gets a schema that Marshmallow generates in its own module. Response fields built as plain dicts have no schema to walk either. Two new tests check the query/header/cookie parameters and the body properties named in the specs against the same list of names that predate kebab-case. The 14 names only the specs reveal all shipped in v1.0.1, so they join that list. The stale-entry test now counts names found in the specs too.
  • The API change log spells the 1.1.0 changes the way the API does. It said next_run and n_jobs, where the API sends next-run and n-jobs. The main changelog and the automation trigger's description had the same slips. It now also describes asset and end above, and the deprecation of until.
  • Added changelog item in documentation/changelog.rst

The regenerated OpenAPI specs also pick up the PATCH asset description from #2825, which main's specs had not caught up with.

Look & Feel

DELETE /api/v3_0/sensors/1/data         {"start": "...", "end": "..."}    → 204
DELETE /api/v3_0/sensors/1/data         {"start": "...", "until": "..."}  → 204 (deprecated)
DELETE /api/v3_0/sensors/1/annotations  {"until": "..."}                  → 422
GET    /api/v3_0/sensors/1/status?asset=2

A new snake_case parameter in the specs now fails like this:

AssertionError: these parameters are named with an underscore in the OpenAPI specs:
  asset_id: GET /api/v3_0/sensors/{id}/status

How to test

  • pytest flexmeasures/data/schemas/tests/test_field_naming.py
  • pytest flexmeasures/api/v3_0/tests/test_sensors_api.py -k status
  • pytest flexmeasures/api/v3_0/tests/test_sensors_delete_data_fresh_db.py flexmeasures/api/v3_0/tests/test_annotations.py

Each new test was checked against the change it covers:

  • naming asset_id again fails the status test;
  • dropping the until alias fails the data endpoint's until case;
  • giving the annotations endpoint that alias fails its refusal test;
  • main's spec fails the new parameter check;
  • removing a response property from the list fails the new property check.

Further Improvements

Related Items

Follows up on #2547 and #2474.


Sign-off

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on code under GPL or other license that is incompatible with FlexMeasures

🤖 Generated with Claude Code

https://claude.ai/code/session_01DWv6v5ELzmj2eBM1L4GTBz

Flix6x and others added 6 commits November 5, 2026 09:04
…t asset_id

Context:
- GET /sensors/<id>/status gained an asset_id query parameter in #2474, after v1.0.1, so it has not shipped in a release yet.
- New wire names are kebab-case, and a single word where it can be (#2540); the sensor listing already takes asset, with asset_id as a legacy alias.

Change:
- Rename the query parameter to asset, without a legacy alias, as no release accepted asset_id.
- Update the sensor status page, which is its only caller.
- The regenerated OpenAPI specs also pick up the PATCH asset description from #2825, which main's specs had not caught up with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5ELzmj2eBM1L4GTBz
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Context:
- DELETE /sensors/<id>/data and DELETE /sensors/<id>/annotations took start and until, where POST annotations and every other time window in the API take start and end.
- DELETE /sensors/<id>/annotations is new in 1.1.0; DELETE /sensors/<id>/data shipped with until.

Change:
- Name the second bound end on both endpoints, in their schemas, validation messages and descriptions.
- Keep accepting until on DELETE /sensors/<id>/data, as a legacy alias for end; the annotations endpoint never shipped with until, so it gets no alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5ELzmj2eBM1L4GTBz
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Context:
- GET /sensors/<id>/status had no API test, so renaming its query parameter could not break one.

Change:
- Check that the status reports the sensor's relation to the asset named by asset, and to its own asset by default.
- Fails when the parameter is spelled asset_id again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5ELzmj2eBM1L4GTBz
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Context:
- Both DELETE sensor endpoints now name their second bound end; only DELETE /sensors/<id>/data keeps accepting until.

Change:
- Send end in the existing tests of both endpoints.
- Run the data endpoint's end filter test with until as well, which fails when the alias is dropped.
- Check that the annotations endpoint refuses until, which fails when it is given the alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5ELzmj2eBM1L4GTBz
Signed-off-by: F.N. Claessen <claessen@seita.nl>
…mes too

Context:
- The test on wire names walks the Marshmallow schemas defined in FlexMeasures modules.
- A parameter declared inline, as in use_kwargs({...}), gets a schema that Marshmallow generates in its own module, so the asset_id query parameter of GET /sensors/<id>/status (#2474) went unnoticed.
- Response fields built as plain dicts and documented on their endpoint have no schema to walk at all.

Change:
- Check the query, header and cookie parameters and the body properties named in the published OpenAPI specs against the same list of names that predate kebab-case.
- Add the 14 names that only the specs reveal, all of which shipped in v1.0.1, to that list.
- Count names found in the specs when looking for stale entries in it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5ELzmj2eBM1L4GTBz
Signed-off-by: F.N. Claessen <claessen@seita.nl>
Context:
- The API change log called two response fields next_run and n_jobs, where automation responses send next-run and the automation trigger sends n-jobs; the main changelog and the trigger endpoint's description said the same.
- The previous commits renamed the status endpoint's asset_id to asset, and the DELETE endpoints' until to end.

Change:
- Correct next-run and n-jobs in the API change log, the main changelog and the trigger endpoint's description.
- Describe the status endpoint's asset parameter and the annotations endpoint's end under their own entries.
- Note that DELETE /sensors/<id>/data takes end, still accepting until, which is deprecated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5ELzmj2eBM1L4GTBz
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@Flix6x Flix6x added this to the 1.1.0 milestone Nov 5, 2026
Context:
- PR #2826 renames until to end on DELETE /sensors/<id>/data, keeping until as a deprecated alias, and widens the naming test to the published OpenAPI specs.

Change:
- Add the DELETE /sensors/<id>/data change under API and plugins.
- Extend the naming test's existing entry with what it now covers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DWv6v5ELzmj2eBM1L4GTBz
Signed-off-by: F.N. Claessen <claessen@seita.nl>
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 flexmeasures | 🛠️ Build #35665007 | 📁 Comparing 5183405 against latest (8a1f508)

  🔍 Preview build  

4 files changed
± changelog.html
± _autosummary/flexmeasures.api.v3_0.sensors.html
± api/change_log.html
± api/v3_0.html

@Flix6x Flix6x self-assigned this Nov 5, 2026
@Flix6x
Flix6x merged commit 85668c9 into main Nov 5, 2026
13 checks passed
@Flix6x
Flix6x deleted the kebab-wire-names-openapi branch November 5, 2026 10:12
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