Endpoint for configuration JSON schema

I’d like to use IDE to edit complex HA configurations, but it’s difficult do it w/o instant schema validation / code completion. This leads to a tedious cycle of editing in an IDE, testing in Home Assistant, and fixing errors.

This is where a dedicated endpoint providing the YAML schema for the configuration?

Picture an endpoint like /homeassistant/openapi.json that returns a JSON schema representing the entire configuration structure. Popular IDEs like PyCharm could then leverage this schema to offer:

  • Real-time validation: Highlight errors and issues as you type, preventing them from reaching Home Assistant.
  • Code completion: Access detailed information about each option and get suggestions for valid values and nested structures.
  • Improved maintainability: Catch errors early.

AFAIK Home Assistant uses Pydantic to build data structures. Pydantic conveniently offers built-in mechanisms to generate JSON schemas from its data models. Moreover, similar functionality exists in frameworks like FastAPI, where /openapi.json provides complete JSON schma of data structures.

The question is: Does such an endpoint currently exist for Home Assistant? Has anyone explored building or requesting it? The benefits for YAML editing users, who uses IDEs, would be immense!

1. I’m not asking for complete YAML validation as HA may do , but at least keywords, structure, types can be checked via JSON schema.

2. Projects like this will tend to fall-behind, be incomplete and incorrect vs specific version, because of the need to follow-up all changes in the product and differences between different versions of HA. Only the instance of HA can say, which config it accepts .

Related to this.

5 Likes

This would be amazing!
Particularly if custom cards are allowed to pass a json schema for their configuration yaml.

I just made an external web app for my own custom card since due to its nature (the schema is 35k lines) it only allows yaml configuration for anything non-trivial.

If I could get this level of detail directly into the home assistant yaml editor, my users (and me too) would have a much easier time: Plotly graph card yaml editor