mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
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>
This commit is contained in:
@@ -14,7 +14,7 @@ use rmcp::model::{
|
||||
RawEmbeddedResource, RawImageContent, RawResource, RawTextContent, ResourceContents, Role,
|
||||
TaskSupport, TextContent, Tool, ToolAnnotations, ToolExecution,
|
||||
};
|
||||
use utoipa::{OpenApi, ToSchema};
|
||||
use utoipa::{Modify, OpenApi, ToSchema};
|
||||
|
||||
use goose::config::declarative_providers::{
|
||||
DeclarativeProviderConfig, LoadedProvider, ProviderEngine,
|
||||
@@ -333,8 +333,38 @@ derive_utoipa!(ResourceContents as ResourceContentsSchema);
|
||||
derive_utoipa!(JsonObject as JsonObjectSchema);
|
||||
derive_utoipa!(Icon as IconSchema);
|
||||
|
||||
/// utoipa renders `Vec<u8>` as `array<integer>` which produces `number[]` in TS codegen,
|
||||
/// failing typecheck at `new Blob([response.data])`. This fixup sets `string/binary` so
|
||||
/// codegen emits `Blob | File`. There is no utoipa annotation for response body format.
|
||||
struct BinaryResponseFixup;
|
||||
|
||||
impl Modify for BinaryResponseFixup {
|
||||
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
|
||||
use utoipa::openapi::schema::Schema;
|
||||
use utoipa::openapi::RefOr;
|
||||
|
||||
if let Some(path) = openapi.paths.paths.get_mut("/diagnostics/{session_id}") {
|
||||
if let Some(op) = &mut path.get {
|
||||
if let Some(RefOr::T(resp)) = op.responses.responses.get_mut("200") {
|
||||
if let Some(content) = resp.content.get_mut("application/zip") {
|
||||
content.schema = Some(RefOr::T(Schema::Object(
|
||||
ObjectBuilder::new()
|
||||
.schema_type(SchemaType::new(Type::String))
|
||||
.format(Some(SchemaFormat::KnownFormat(
|
||||
utoipa::openapi::schema::KnownFormat::Binary,
|
||||
)))
|
||||
.build(),
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(OpenApi)]
|
||||
#[openapi(
|
||||
modifiers(&BinaryResponseFixup),
|
||||
paths(
|
||||
super::routes::status::status,
|
||||
super::routes::status::system_info,
|
||||
|
||||
@@ -1632,12 +1632,8 @@
|
||||
"content": {
|
||||
"application/zip": {
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"minimum": 0
|
||||
}
|
||||
"type": "string",
|
||||
"format": "binary"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2822,7 +2822,7 @@ export type DiagnosticsResponses = {
|
||||
/**
|
||||
* Diagnostics zip file
|
||||
*/
|
||||
200: Array<number>;
|
||||
200: Blob | File;
|
||||
};
|
||||
|
||||
export type DiagnosticsResponse = DiagnosticsResponses[keyof DiagnosticsResponses];
|
||||
|
||||
Reference in New Issue
Block a user