Open paullewis opened 3 months ago
This is my bug. I defined default
as "string", because that's what examples
type is, but actually, JSON schema doesn't have a strong opinion here, and having default
be of the same type of as its port seems more logical.
The fix here is likely to change default
to be of unknown
type and rely on Build API to infer the proper type. Right?
Fetch headers are a string->string mapping, so I believe the headers
port should have type:
JSON Schema:
{
"type": "object",
"additionalProperties": {
"type": "string"
}
}
Breadboard Type Expression:
import {object} from "@breadboard-ai/build";
object({}, "string")
TypeScript:
Record<string, string>
The fix here is likely to change
default
to be ofunknown
type and rely on Build API to infer the proper type. Right?
Yeah, I agree the default type for a Breadboard port should be any JSON value which is:
JSON Schema:
{}
OR identically JSON Schema:
{"type": ["array", "boolean", "null", "number", "object", "string"]}
Breadboard Type Expression:
"unknown";
TypeScript:
type JsonSerializable =
| string
| number
| boolean
| null
| Array<JsonSerializable>
| { [K: string]: JsonSerializable };
According to our schema a port's default value should be
string|undefined
However in the fetch component we set the default for the
headers
property to be an objectNot sure which is more correct, but the net result is that the Visual Editor is expecting
string|undefined
but in this case gets{}
which then gets serialized to[object Object]