-
Notifications
You must be signed in to change notification settings - Fork 117
Open
Description
I have an API endpoint that may return no response or some type Inode like this:
"/fs/resolve/{path}": {
"get": {
"operationId": "resolvePath",
"responses": {
"2XX": {
"description": "",
"content": {
"application/json": {
"schema": {
"allOf": [
{
"$ref": "#/components/schemas/Inode"
}
],
"nullable": true
}
}
}
}
},
"tags": [
"Filesystem"
],
"parameters": [
{
"in": "path",
"name": "path",
"required": true,
"schema": {
"type": "string"
}
}
]
}
},
typify correctly generates an Option type but if the API returns an empty body i get an InvalidResponsePayload error.
I tracked this down to serde being unable to parse an empty byte array b"" to an Option None here:
pub async fn from_response<E>(response: reqwest::Response) -> Result<Self, Error<E>> {
let status = response.status();
let headers = response.headers().clone();
let full = response.bytes().await.map_err(Error::ResponseBodyError)?;
let inner =
serde_json::from_slice(&full).map_err(|e| Error::InvalidResponsePayload(full, e))?;
Ok(Self {
inner,
status,
headers,
})
}
Can a case for this be added?
I already tried adding a specific 204 Response to the schema, but this fails with assertion failed: response_types.len() <= 1
Metadata
Metadata
Assignees
Labels
No labels