-
Couldn't load subscription status.
- Fork 32
Description
Summary
HistoryClass is supposed to model the backend-v3 style history of Datasets, where the changed fields are placed at the top level:
{
id: "...",
updatedAt: "...",
updatedBy: "...",
keywords: {
previousValue: [],
currentValue: ["tag1"]
},
datasetlifecycle: {
previousValue: {x: "a"},
currentValue: {x: "b"}
}
}To accomodate this, an index signature [key: string]: unkown was added in the class. However, this has no representation in the OpenAPI document that is generated. i.e. the openapi generator does not e.g. generate additionalProperties: true for the HistoryClass schema.
As a result, various SDK generators, which take as input the OpenAPI document, only generate a class with the mandatory history fields i.e.
{
id: "...",
updatedAt: "...",
updatedBy: "...",
}e.g. historyClass.d.ts. And we need to manually intersect HistoryClass with the index signature in the frontend e.g.
export type HistoryWithProperties = HistoryClass & {[key:string]: unknown}to get proper type checking.
In the python sdk, trying to add an extra field to the HistoryClass instance triggers a runtime error:
see discussion here.
Steps to Reproduce
Current Behaviour
Expected Behaviour
Quting a propsed fix from the above discussion:
I think a fix to the HistoryClass would be to move the additional properties in a dedicated field e.g. changes, whose type is Record<string, unknown>, e.g. in the UserSettings model, this way OpenAPI contains this information:
"externalSettings": {
"type": "object",
"default": {},
"additionalProperties": true,
}and pydantic generates
external_settings: Dict[str, Any] = Field(...and the typescript sdk contains:
externalSettings: {
[key: string]: any;
};Then changes could be made to the frontend / response of /v3/datasets to still present the output in the old format.