Project

General

Profile

Actions

Feature #40962

open

Feature #50320: mgr/dashboard: Lean Dashboard

mgr/dashboard: REST API: runtime front-end/back-end (end-to-end) schema validation

Added by Ernesto Puerta almost 5 years ago. Updated about 3 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
General - Back-end
Target version:
-
% Done:

0%

Source:
Tags:
Backport:
Reviewed:
Affected Versions:
Pull request ID:

Description

While front-end language Typescript provides build-time type-checks, there's no current action taken to ensure run-time type-safety from-to back-end API.

Apart from extra safety measures like type guards (typeof|instanceof|etc), it'd desirable to have a type definition framework to share between Python (now wer're enforcing type hints) and Typescript.

It seems there are libraries for handling jsonschema both in:
  • Typescript
  • Python: jsonschema (JSON schema to Python type hints), pydantic (generating JSON schema from Python type hints).
  • Additionally there are tools to extract json-schemas from OpenAPI/Swagger definitions, which would allow for an API driven scenario.
The workflow would be more or less like this (as Python is our source of truth in terms of API):
  1. JSON Schema -> {Python code, OpenAPI Schema, Typescript} (It seems there's no easy to way to export Python type hints to JSON schema, but only the other way).
  2. Or Python code -> JSON Schema -> {OpenAPI Schema, Typescript} (It seems there's no easy to way to export Python type hints to JSON schema, but only the other way).

If we find the way to enforce type/schemas between C++ API and Python (as the initiative proposed by SebastianW), we might ensure end-to-end type safety in Ceph.


Subtasks 1 (1 open0 closed)

Feature #46423: mgr/dashboard: Python runtime typechecking frameworkNew

Actions
Actions #1

Updated by Ernesto Puerta almost 5 years ago

  • Description updated (diff)
Actions #2

Updated by Ernesto Puerta almost 5 years ago

  • Description updated (diff)
Actions #3

Updated by Sebastian Wagner almost 5 years ago

Yeah, I'd go the OpenAPI Schema -> Python route, as there are plenty of tools to write those specs. And then possibly even auto generate some python code.

Actions #4

Updated by Ernesto Puerta about 3 years ago

  • Parent task changed from #40907 to #50320
Actions

Also available in: Atom PDF