-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPE-2004] Support const
and default
attributes [Other languages]
#202
Comments
Hi, We have a discriminator (generated via FastAPI/Pydantic Literal') It generates the following snippets in the OpenAPI spec, however the speakeasy cli fails with: "Distribution": {
"properties": {
"style": {
"const": "distribution",
"title": "Style",
"default": "distribution"
}
},
"type": "object",
"title": "Distribution",
"description": "Pydantic class for when we want the distribution on a particular date."
} "statistic": {
"oneOf": [
{
"$ref": "#/components/schemas/Mean"
},
{
"$ref": "#/components/schemas/Quantile"
},
{
"$ref": "#/components/schemas/Distribution"
}
],
"title": "Statistic",
"discriminator": {
"propertyName": "style",
"mapping": {
"distribution": "#/components/schemas/Distribution",
"mean": "#/components/schemas/Mean",
"quantile": "#/components/schemas/Quantile"
}
}
} It seems it is failing on the missing Is this related to implying types from const/default attributes not being supported? |
Hi @fergusdixon thanks for the issue report. So looking through the schemas you provided above the issue you are seeing is because your We rely on strong typing in your OpenAPI spec as much as possible to ensure we are generating the right types, so when a While json-schema does allow for loose typing like this and assumptions on the type of the schema being made on heuristics around what other properties are present in the schema, we do little of that ourselves except where we can be pretty confident we have the type right, for example if you have a So we just don't assume type in these situations and required it to be explicitly defined. Hope that provides some context around why this is failing |
Hey, thanks for the clarification and definitely makes sense. Frustrating that the FastAPI/Pydantic Literal types don't include this. I think we can find a workaround using |
Allow values to be set without user input
From SyncLinear.com | SPE-2004
The text was updated successfully, but these errors were encountered: