docs(69): auto-tune OpenAPI regen + api/domain/decisions docs

Refs #69
This commit is contained in:
2026-07-16 22:18:52 +02:00
parent e9e701f621
commit 0320735f47
7 changed files with 445 additions and 5 deletions
+374
View File
@@ -2364,6 +2364,193 @@
]
}
},
"/api/v1/channels/auto-tune/preview": {
"post": {
"tags": [
"Channels"
],
"summary": "Preview auto-tuned channels",
"operationId": "PreviewAutoTuneChannels",
"requestBody": {
"content": {
"application/json-patch+json": {
"schema": {
"$ref": "#/components/schemas/PreviewAutoTuneChannelsRequest"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/PreviewAutoTuneChannelsRequest"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/PreviewAutoTuneChannelsRequest"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/PreviewAutoTuneChannelsRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/AutoTuneProposalResponseModel"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/AutoTuneProposalResponseModel"
}
}
},
"text/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/AutoTuneProposalResponseModel"
}
}
}
}
},
"422": {
"description": "Unprocessable Entity",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"401": {
"description": "API key missing or invalid.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"400": {
"description": "Request validation failed (model binding or FluentValidation).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ValidationProblemDetails"
}
}
}
}
},
"security": [
{ }
]
}
},
"/api/v1/channels/auto-tune": {
"post": {
"tags": [
"Channels"
],
"summary": "Create auto-tuned channels",
"operationId": "CreateAutoTunedChannels",
"requestBody": {
"content": {
"application/json-patch+json": {
"schema": {
"$ref": "#/components/schemas/CreateAutoTunedChannelsRequest"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateAutoTunedChannelsRequest"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/CreateAutoTunedChannelsRequest"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/CreateAutoTunedChannelsRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"text/plain": {
"schema": {
"$ref": "#/components/schemas/AutoTuneResultResponseModel"
}
},
"application/json": {
"schema": {
"$ref": "#/components/schemas/AutoTuneResultResponseModel"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/AutoTuneResultResponseModel"
}
}
}
},
"401": {
"description": "API key missing or invalid.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ProblemDetails"
}
}
}
},
"400": {
"description": "Request validation failed (model binding or FluentValidation).",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ValidationProblemDetails"
}
}
}
}
},
"security": [
{ }
]
}
},
"/api/v1/channels/{id}/playout/reset": {
"post": {
"tags": [
@@ -22535,6 +22722,137 @@
}
}
},
"AutoTuneAxis": {
"enum": [
"TvShow",
"TvGenre",
"MovieGenre"
],
"type": "string"
},
"AutoTuneChannelResultModel": {
"required": [
"name",
"status",
"channelId",
"reason"
],
"type": "object",
"properties": {
"name": {
"type": "string"
},
"status": {
"type": "string"
},
"channelId": {
"type": [
"null",
"integer"
],
"format": "int32"
},
"reason": {
"type": [
"null",
"string"
]
}
}
},
"AutoTunedChannelRequest": {
"required": [
"axis",
"value",
"name",
"number"
],
"type": "object",
"properties": {
"axis": {
"$ref": "#/components/schemas/AutoTuneAxis"
},
"value": {
"type": [
"null",
"string"
]
},
"name": {
"type": [
"null",
"string"
]
},
"number": {
"type": [
"null",
"string"
]
}
}
},
"AutoTuneProposalResponseModel": {
"required": [
"axis",
"value",
"name",
"number",
"itemCount",
"alreadyExists"
],
"type": "object",
"properties": {
"axis": {
"type": "string"
},
"value": {
"type": "string"
},
"name": {
"type": "string"
},
"number": {
"type": "string"
},
"itemCount": {
"type": "integer",
"format": "int32"
},
"alreadyExists": {
"type": "boolean"
}
}
},
"AutoTuneResultResponseModel": {
"required": [
"results",
"createdCount",
"skippedCount",
"failedCount"
],
"type": "object",
"properties": {
"results": {
"type": "array",
"items": {
"$ref": "#/components/schemas/AutoTuneChannelResultModel"
}
},
"createdCount": {
"type": "integer",
"format": "int32"
},
"skippedCount": {
"type": "integer",
"format": "int32"
},
"failedCount": {
"type": "integer",
"format": "int32"
}
}
},
"BlockGroupResponseModel": {
"required": [
"id",
@@ -23616,6 +23934,35 @@
}
}
},
"CreateAutoTunedChannelsRequest": {
"required": [
"templateId",
"group",
"channels"
],
"type": "object",
"properties": {
"templateId": {
"type": "integer",
"format": "int32"
},
"group": {
"type": [
"null",
"string"
]
},
"channels": {
"type": [
"null",
"array"
],
"items": {
"$ref": "#/components/schemas/AutoTunedChannelRequest"
}
}
}
},
"CreateBlockGroupRequest": {
"required": [
"name"
@@ -28295,6 +28642,33 @@
}
}
},
"PreviewAutoTuneChannelsRequest": {
"required": [
"axes",
"minItems",
"startingNumber"
],
"type": "object",
"properties": {
"axes": {
"type": [
"null",
"array"
],
"items": {
"$ref": "#/components/schemas/AutoTuneAxis"
}
},
"minItems": {
"type": "integer",
"format": "int32"
},
"startingNumber": {
"type": "integer",
"format": "int32"
}
}
},
"ProblemDetails": {
"type": "object",
"properties": {
+9
View File
@@ -307,6 +307,15 @@ After any controller/DTO change:
`endpoint-index.md` from source and fails if any of the three is stale in the diff. This is the
mechanized half of the "docs-update in the same PR" rule for the API contract.
**Endpoint inventory additions (#69, auto-tuning PR1 backend)**: two `ChannelController` actions,
both requiring the standard credential (session-or-key, per §9 — no `[SkipApiAuthorization]`/
`[RequiresAuthentication]` override):
| Method | Path | Operation | Summary |
|---|---|---|---|
| POST | `/api/v1/channels/auto-tune/preview` | `PreviewAutoTuneChannels` | Preview auto-tuned channels |
| POST | `/api/v1/channels/auto-tune` | `CreateAutoTunedChannels` | Create auto-tuned channels |
**Resolved wart (#287)**: `DayOfWeek` previously serialized as an integer in the OpenAPI schema while
the runtime JSON payload is the enum's **name string** ("Sunday".."Saturday"). It is now added to
`Startup.UseStringEnumSchemas`'s hand-list, so the "v1" schema emits it as a **string enum** matching
+14
View File
@@ -91,6 +91,7 @@ keep append-only from accreting stale, contradictory, or unreadably-large histor
- [2026-07-13 — Release promotion: floating `:prod`, exact-image scan before manual deploy (#335)](#2026-07-13--release-promotion-floating-prod-exact-image-scan-before-manual-deploy-335)
- [2026-07-16 — Functional-E2E CI harness: advisory curl-contract job over an app booted from source (#299)](#2026-07-16--functional-e2e-ci-harness-advisory-curl-contract-job-over-an-app-booted-from-source-299)
- [2026-07-16 — Optional advertised IPTV base URL (`iptv.base_url`) resolved centrally in the two generators (#340)](#2026-07-16--optional-advertised-iptv-base-url-iptvbase_url-resolved-centrally-in-the-two-generators-340)
- [2026-07-16 — Auto-tuning enumerates via EF, persists via SmartCollection; additive coexistence (#69)](#2026-07-16--auto-tuning-enumerates-via-ef-persists-via-smartcollection-additive-coexistence-69)
---
@@ -1921,3 +1922,16 @@ was explicitly out of scope.
Core `PathBase` (request routing/prefix); it does not advertise a scheme+host. `iptv.base_url` is the
separate, DB-stored (`ConfigElementKey.IptvBaseUrl`, **no EF migration**) advertised origin for IPTV
output. See `docs/m3u-xmltv.md` → "IPTV base URL (#340)".
## 2026-07-16 — Auto-tuning enumerates via EF, persists via SmartCollection; additive coexistence (#69)
Auto-tuning (#69) generates channels from library metadata (TV Show / TV Genre / Movie Genre).
Enumeration for the preview uses EF distinct+count queries (exact counts drive the min-items
threshold and preview display); each created channel is backed by a newly-created **SmartCollection**
(live Lucene query) so channels keep tracking the library as it grows. Query authorship is
server-side only — the client passes `{axis, value}`, never a Lucene string. Coexistence is additive:
the batch gets a reserved starting channel number (skipping taken numbers), a proposed channel whose
name already exists is flagged and de-selected by default, and existing channels are never mutated.
Bulk create loops the #63 `CreateChannelFromLineup` primitive via `ISender` and returns a per-channel
Created/Skipped/Failed outcome. Known MVP limitation: the generated SmartCollection is named after the
channel; a name collision with an existing SmartCollection surfaces as a per-channel Failed outcome.
+7
View File
@@ -12,6 +12,13 @@ external-JSON) — a playout belongs to exactly one **channel**. Channels are ex
(Jellyfin, Dispatcharr) as an M3U playlist + XMLTV guide, and streamed on demand via FFmpeg, all
under the `/iptv/*` routes (`ErsatzTV/Controllers/IptvController.cs`).
**Auto-tuning (#69)** is a second, automatic-first channel-creation mode alongside the manual
single-channel flow: it enumerates library metadata along an axis (TV Show / TV Genre / Movie
Genre), previews the proposed channels (name, allocated number, item count) with no writes, and
bulk-creates the selected ones via the #63 composite `CreateChannelFromLineup` primitive. Each
generated channel is backed by a newly-created, live **SmartCollection** query, so it keeps
tracking the library as it grows rather than freezing a static item list.
## Entity chain sketch
```
+3 -3
View File
@@ -2,7 +2,7 @@
*Generated by `scripts/generate-endpoint-index.py` from `ErsatzTV/wwwroot/openapi/v1.json`. Do not edit by hand -- regenerated by `scripts/update-openapi.sh`.*
161 endpoints, 244 operations.
162 endpoints, 244 operations.
## Artists
@@ -55,6 +55,8 @@
| Method | Path | Operation | Summary |
|---|---|---|---|
| POST | `/api/v1/channels` | ChannelCreate | Create a channel |
| POST | `/api/v1/channels/auto-tune` | CreateAutoTunedChannels | Create auto-tuned channels |
| POST | `/api/v1/channels/auto-tune/preview` | PreviewAutoTuneChannels | Preview auto-tuned channels |
| POST | `/api/v1/channels/bulk/delete` | ChannelBulkDelete | Delete channels |
| POST | `/api/v1/channels/bulk/group` | ChannelBulkMoveToGroup | Move channels to a group |
| POST | `/api/v1/channels/bulk/renumber` | ChannelBulkRenumber | Renumber channels |
@@ -354,8 +356,6 @@
| PUT | `/api/v1/settings/ffmpeg` | UpdateFfmpegSettings | Update global FFmpeg settings |
| GET | `/api/v1/settings/hdhr` | GetHdhrSettings | Get HDHomeRun emulation settings |
| PUT | `/api/v1/settings/hdhr` | UpdateHdhrSettings | Update HDHomeRun emulation settings |
| GET | `/api/v1/settings/iptv` | GetIptvSettings | Get IPTV output settings |
| PUT | `/api/v1/settings/iptv` | UpdateIptvSettings | Update IPTV output settings |
| GET | `/api/v1/settings/logging` | GetLoggingSettings | Get per-area minimum log levels |
| PUT | `/api/v1/settings/logging` | UpdateLoggingSettings | Update per-area minimum log levels |
| GET | `/api/v1/settings/playout` | GetPlayoutSettings | Get global playout settings |
@@ -80,8 +80,7 @@ Request:
{
"axes": ["TvShow", "TvGenre", "MovieGenre"], // subset, ≥1
"minItems": 5, // default 5
"startingNumber": 500, // default 500
"templateId": <int> // default = system default template
"startingNumber": 500 // default 500
}
```
Response — a list of proposed channels:
+37
View File
@@ -58,6 +58,33 @@ export interface components {
"ArtworkUploadResponseModel": {
"path": string;
"contentType": string;
};
"AutoTuneAxis": "TvShow" | "TvGenre" | "MovieGenre";
"AutoTuneChannelResultModel": {
"name": string;
"status": string;
"channelId": null | number;
"reason": null | string;
};
"AutoTunedChannelRequest": {
"axis": components["schemas"]["AutoTuneAxis"];
"value": null | string;
"name": null | string;
"number": null | string;
};
"AutoTuneProposalResponseModel": {
"axis": string;
"value": string;
"name": string;
"number": string;
"itemCount": number;
"alreadyExists": boolean;
};
"AutoTuneResultResponseModel": {
"results": Array<components["schemas"]["AutoTuneChannelResultModel"]>;
"createdCount": number;
"skippedCount": number;
"failedCount": number;
};
"BlockGroupResponseModel": {
"id": number;
@@ -270,6 +297,11 @@ export interface components {
"CopyTemplateRequest": {
"templateGroupId": number;
"name": null | string;
};
"CreateAutoTunedChannelsRequest": {
"templateId": number;
"group": null | string;
"channels": null | Array<components["schemas"]["AutoTunedChannelRequest"]>;
};
"CreateBlockGroupRequest": {
"name": null | string;
@@ -1143,6 +1175,11 @@ export interface components {
};
"PlexPinFlowResponseModel": {
"authUrl": string;
};
"PreviewAutoTuneChannelsRequest": {
"axes": null | Array<components["schemas"]["AutoTuneAxis"]>;
"minItems": number;
"startingNumber": number;
};
"ProblemDetails": {
"type"?: null | string;