From 88c517261680a74c52bf066274972f0ef5f7fed9 Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Mon, 6 Jul 2026 14:17:52 +0200 Subject: [PATCH 1/8] API: generate /api/state documentation from UI types --- .../components/ChargingPlans/ChargingPlan.vue | 4 +- .../ChargingPlans/ChargingPlanModal.vue | 8 +- .../components/ChargingPlans/PlanStrategy.vue | 2 +- .../ChargingPlans/PlansRepeatingSettings.vue | 2 +- .../ChargingPlans/PlansSettings.vue | 16 +- .../js/components/ChargingPlans/Warnings.vue | 3 +- assets/js/components/ChargingPlans/types.d.ts | 39 - assets/js/components/Forecast/types.ts | 25 + assets/js/components/Loadpoints/Loadpoint.vue | 2 +- assets/js/components/Vehicles/Title.vue | 2 +- assets/js/components/Vehicles/Vehicle.vue | 2 +- assets/js/types/evcc.ts | 549 +++- eslint.config.mts | 1 + package-lock.json | 244 +- package.json | 8 +- scripts/state-schema/index.ts | 34 + scripts/state-schema/openapi.ts | 58 + scripts/state-schema/schemas.ts | 182 ++ scripts/state-schema/validate.ts | 93 + server/mcp/openapi.json | 2323 ++++++++++++++++- server/mcp/openapi.md | 6 +- server/openapi.yaml | 1805 ++++++++++++- tests/state-api.spec.ts | 25 + tsconfig.json | 2 +- 24 files changed, 5203 insertions(+), 232 deletions(-) delete mode 100644 assets/js/components/ChargingPlans/types.d.ts create mode 100644 scripts/state-schema/index.ts create mode 100644 scripts/state-schema/openapi.ts create mode 100644 scripts/state-schema/schemas.ts create mode 100644 scripts/state-schema/validate.ts create mode 100644 tests/state-api.spec.ts diff --git a/assets/js/components/ChargingPlans/ChargingPlan.vue b/assets/js/components/ChargingPlans/ChargingPlan.vue index 3750c1cc936..6bb096a23be 100644 --- a/assets/js/components/ChargingPlans/ChargingPlan.vue +++ b/assets/js/components/ChargingPlans/ChargingPlan.vue @@ -38,9 +38,7 @@ import formatter from "@/mixins/formatter"; import minuteTicker from "@/mixins/minuteTicker"; import { optionStep, fmtEnergy } from "@/utils/energyOptions.ts"; import { defineComponent, type PropType } from "vue"; -import type { CURRENCY, Vehicle } from "@/types/evcc"; -import type { PlanStrategy } from "./types"; -import type { Forecast } from "@/types/evcc.ts"; +import type { CURRENCY, Forecast, PlanStrategy, Vehicle } from "@/types/evcc"; export default defineComponent({ name: "ChargingPlan", diff --git a/assets/js/components/ChargingPlans/ChargingPlanModal.vue b/assets/js/components/ChargingPlans/ChargingPlanModal.vue index 03c5e817bb8..e575e4b1a42 100644 --- a/assets/js/components/ChargingPlans/ChargingPlanModal.vue +++ b/assets/js/components/ChargingPlans/ChargingPlanModal.vue @@ -85,13 +85,17 @@ import PlansSettings from "./PlansSettings.vue"; import Arrival from "./Arrival.vue"; import api from "@/api"; import type { + CURRENCY, + Forecast, PlanStrategy, RepeatingPlan, + SMART_COST_TYPE, StaticEnergyPlan, StaticPlan, StaticSocPlan, -} from "./types"; -import type { CURRENCY, Forecast, SMART_COST_TYPE, UiLoadpoint, Vehicle } from "@/types/evcc"; + UiLoadpoint, + Vehicle, +} from "@/types/evcc"; export default defineComponent({ name: "ChargingPlanModal", diff --git a/assets/js/components/ChargingPlans/PlanStrategy.vue b/assets/js/components/ChargingPlans/PlanStrategy.vue index a8014a76bfe..0e63f3f8393 100644 --- a/assets/js/components/ChargingPlans/PlanStrategy.vue +++ b/assets/js/components/ChargingPlans/PlanStrategy.vue @@ -64,7 +64,7 @@