Project

General

Profile

Feature #40962

Updated by Ernesto Puerta over 4 years ago

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":https://json-schema.org both in: 
 * "Typescript":https://github.com/YousefED/typescript-json-schema 
 * "Python":https://pypi.org/project/jsonschema/. 
 * Additionally there are tools to extract json-schemas from OpenAPI/Swagger definitions, which would allow for an API driven scenario. 

 The As the API comes from Python code, the workflow would be more or less like this: 
 # Python code -> OpenAPI Schema -> JSON Schema -> {Python code, Typescript (we might skip the OpenAPI Schema, Typescript} (It seems there's no easy to way to export intermediate step, and generate JSON Schema right from Python type hints to JSON schema, but only the other way). and feed Typescript with that. Additionally, OpenAPI schema would be generated also from Python code. 

 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. 

Back