Class: A2A::Faraday::Middleware::SchemaRequest
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- A2A::Faraday::Middleware::SchemaRequest
- Defined in:
- lib/a2a/faraday/middleware/schema_request.rb
Overview
Faraday request middleware that converts A2A::Schema::Definition objects into their hash representation for JSON serialization.
Place this before the :json request middleware in the stack so that Schema bodies are converted to hashes before Faraday’s JSON middleware serializes them to strings.
Instance Method Summary collapse
Instance Method Details
#on_request(env) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/a2a/faraday/middleware/schema_request.rb', line 19 def on_request(env) body = env.body return unless body.is_a?(A2A::Schema::Definition) env.body = body.to_h env.request_headers["content-type"] ||= "application/json" end |