flexmeasures.api.v3_0
Modules
FlexMeasures API v3
Functions
- flexmeasures.api.v3_0.collapse_schema_to_field(spec: APISpec, schema_cls: Type[Schema], field_name: str) dict[str, Any]
Replace the OpenAPI component named after schema_cls with the OpenAPI schema generated for field_name inside that schema.
- flexmeasures.api.v3_0.create_openapi_specs(app: Flask)
Create OpenAPI specs for the API and save them to a JSON file in the static folder. This function should be called when generating docs (and needs extra dependencies).
- flexmeasures.api.v3_0.document_rate_limits(spec_dict: dict, trigger_limited_operations: set[tuple])
Document the 429 response on every endpoint the rate limiter guards.
Rate limiting is applied by the limiter rather than by the views themselves (see
flexmeasures.api.common.rate_limiting), so no view docstring declares this response. We add it here, so that the published contract keeps matching what the limiter does, without every docstring having to remember to say so.
- flexmeasures.api.v3_0.flask_rule_to_openapi_path(rule: str) str
Turn a Flask rule like “/api/v3_0/assets/<id>/automations/<int:automation_id>” into its OpenAPI path.
Path parameters are spelled in kebab-case, like the rest of the API, as in “/api/v3_0/assets/{id}/automations/{automation-id}”. Flask cannot name a route variable that way, so the rule keeps the underscore, which never reaches the wire.
- flexmeasures.api.v3_0.kebab_case_path_parameters(spec_dict: dict)
Spell the path parameters in the paths of the OpenAPI specs in kebab-case (see flask_rule_to_openapi_path).
- flexmeasures.api.v3_0.register_at(app: Flask)
This can be used to register this blueprint together with other api-related things
- flexmeasures.api.v3_0.register_path_id_field(spec: APISpec, param_name: str, field: Field, location: str = 'path', required: bool = True)
Register the field as an OpenAPI parameter
- flexmeasures.api.v3_0.register_swagger_ui(app: Flask)
Register the Swagger UI blueprint to view the OpenAPI specs.