typescript-utcp icon indicating copy to clipboard operation
typescript-utcp copied to clipboard

OpenAPI converter: pre-existing data-loss gaps in schema/example extraction

Open h3xxit opened this issue 5 months ago • 0 comments

Surfaced during a cross-repo audit of the examples-parsing implementation. These are pre-existing gaps (they pre-date the examples work and also drop the schema, not just examples), so they were left out of the examples PRs and tracked here. All cause silent data loss on spec-legal input. File: packages/http/src/openapi_converter.ts.

1. requestBody with a media type other than application/json / application/x-www-form-urlencoded drops the entire body

_extractInputs only inspects those two media types and has no fallback, unlike _extractOutputs which falls back to the first content type with a schema. A body declared only as application/xml (etc.) produces a tool with no body input.

2. Parameter content form is ignored

A Parameter Object may carry its schema under content: {<media-type>: {schema, example, examples}} instead of schema. _extractInputs reads only resolvedParam.schema, so the schema and examples are lost.

{ "name": "filter", "in": "query", "content": { "application/json": { "schema": {...}, "example": {...} } } }

3. OAS2 response examples sibling map is not read

In Swagger 2.0 the response example lives at responses.<code>.examples as { <mime>: <value> }. _extractOutputs OAS2 branch reads only .schema, so these are dropped. The shape differs from the three forms _extractExamples handles and needs bespoke extraction.

Notes

  • Same gaps exist in python-utcp (companion: universal-tool-calling-protocol/python-utcp#98).
  • The body-vs-response asymmetry (response already has a first-content-type fallback) is the cleanest place to start for (1).

h3xxit avatar Jun 24 '26 21:06 h3xxit