Skip to content

Commit 940ea78

Browse files
jh-blockclaude
andcommitted
fix: restore binary schema for diagnostics response to fix TS typecheck
utoipa renders Vec<u8> as array<integer>, producing number[] in TS codegen. This fails typecheck: new Blob([response.data]) expects BlobPart, not number[]. Add a minimal Modify fixup to set the diagnostics response schema to string/binary (no utoipa annotation exists for response body format). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 85d53e2 commit 940ea78

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

crates/goose-server/src/openapi.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rmcp::model::{
1414
RawEmbeddedResource, RawImageContent, RawResource, RawTextContent, ResourceContents, Role,
1515
TaskSupport, TextContent, Tool, ToolAnnotations, ToolExecution,
1616
};
17-
use utoipa::{OpenApi, ToSchema};
17+
use utoipa::{Modify, OpenApi, ToSchema};
1818

1919
use goose::config::declarative_providers::{
2020
DeclarativeProviderConfig, LoadedProvider, ProviderEngine,
@@ -333,8 +333,38 @@ derive_utoipa!(ResourceContents as ResourceContentsSchema);
333333
derive_utoipa!(JsonObject as JsonObjectSchema);
334334
derive_utoipa!(Icon as IconSchema);
335335

336+
/// utoipa renders `Vec<u8>` as `array<integer>` which produces `number[]` in TS codegen,
337+
/// failing typecheck at `new Blob([response.data])`. This fixup sets `string/binary` so
338+
/// codegen emits `Blob | File`. There is no utoipa annotation for response body format.
339+
struct BinaryResponseFixup;
340+
341+
impl Modify for BinaryResponseFixup {
342+
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
343+
use utoipa::openapi::schema::Schema;
344+
use utoipa::openapi::RefOr;
345+
346+
if let Some(path) = openapi.paths.paths.get_mut("/diagnostics/{session_id}") {
347+
if let Some(op) = &mut path.get {
348+
if let Some(RefOr::T(resp)) = op.responses.responses.get_mut("200") {
349+
if let Some(content) = resp.content.get_mut("application/zip") {
350+
content.schema = Some(RefOr::T(Schema::Object(
351+
ObjectBuilder::new()
352+
.schema_type(SchemaType::new(Type::String))
353+
.format(Some(SchemaFormat::KnownFormat(
354+
utoipa::openapi::schema::KnownFormat::Binary,
355+
)))
356+
.build(),
357+
)));
358+
}
359+
}
360+
}
361+
}
362+
}
363+
}
364+
336365
#[derive(OpenApi)]
337366
#[openapi(
367+
modifiers(&BinaryResponseFixup),
338368
paths(
339369
super::routes::status::status,
340370
super::routes::status::system_info,

ui/desktop/openapi.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,12 +1632,8 @@
16321632
"content": {
16331633
"application/zip": {
16341634
"schema": {
1635-
"type": "array",
1636-
"items": {
1637-
"type": "integer",
1638-
"format": "int32",
1639-
"minimum": 0
1640-
}
1635+
"type": "string",
1636+
"format": "binary"
16411637
}
16421638
}
16431639
}

ui/desktop/src/api/types.gen.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2822,7 +2822,7 @@ export type DiagnosticsResponses = {
28222822
/**
28232823
* Diagnostics zip file
28242824
*/
2825-
200: Array<number>;
2825+
200: Blob | File;
28262826
};
28272827

28282828
export type DiagnosticsResponse = DiagnosticsResponses[keyof DiagnosticsResponses];

0 commit comments

Comments
 (0)