Repository navigation
Accept Mojolicious requests, responses and transactions in validate - #4
Conversation
validate now takes a Mojo::Message::Request and/or Mojo::Message::Response in place of the request and response hashes, or a Mojo::Transaction::HTTP in place of both. The private OpenAPI::Humbug::Adapter::Mojo converts them to the existing hashes, which are then validated as before; it is loaded only when a Mojo object is passed, and Mojolicious stays optional (suggested). The Mojo objects are only read, never changed. Closes #2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
maint/cip-before-install installs the current stable Go and builds humbug from go-humbug's default branch into /home/cip/bin; linux.yml passes OPENAPI_HUMBUG_EXECUTABLE to the tests through CIP_ENV. cip's own "cip pkg golang" installs Go 1.19.2, too old for go-humbug (uperl/cip#15). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
One small question about URL credentials in |
Mojo::URL->to_string documents that it leaves out userinfo; clear it on the copy anyway so that does not depend on which method is called. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Good question. It was guaranteed: the Still, I agree it's better to be intentional, so 3f9a3e2 clears it explicitly. |
Closes #2.
validatenow accepts Mojolicious objects as well as the existing hashes:The conversion lives in
OpenAPI::Humbug::Adapter::Mojo, documented as internal. It turns the objects into the existing request/response hashes, which then go through the usual argument checks and encoding. The sidecar, wire protocol and transport are unchanged.Behaviour (documented under MOJOLICIOUS in the POD)
META.jsonit is a runtime suggests and a test recommends. A test hides Mojolicious and checks that hashref callers work and nothing Mojo-related gets loaded.fix_headers,build_body,to_string,get_*_chunk) are not called. A test comparesData::Dumpersnapshots before and after and checks that nofinishevent fires. I checked that it catches afix_headerscall.$req->url->to_abs, without fragment or credentials. A relative URL is resolved only against the base Mojo already has (on the server, from the connection andHost). If there's no scheme and host it is an argument error, not a guess.Set-Cookie) stay separate and in order. Two things Mojo loses before we see the message are documented: the relative order of lines with different names (Mojo sorts names), and the original casing of common names.Content-LengthorTransfer-Encoding.validate($tx): the response is included only if it has a status code and Mojo has finished it (fully received, or fully sent on the server). Otherwise only the request is checked. Asking for the response withvalidate => { response => 1 }is then an argument error. On the server before sending (e.g.after_dispatch), passrequest/responseexplicitly.Tests
t/openapi_humbug__mojo.t: in-memory against the fake transport, checking the exact wire form. Covers request-only, request plus response, mixed hash/Mojo, the transaction shorthand, unfinished and partially received transactions, repeated headers, binary/empty/absent bodies, non-ASCII header values, relative/absolute URLs and the missing-base failure, objects that can't be converted, and objects left unchanged.t/openapi_humbug__no_mojo.t: hashref callers with Mojolicious hidden.t/integration.t: a Mojolicious app and user agent against the real humbug (skipped without Mojolicious).Build
dist.inisetsdiag = -EV. Without it the bundle addsBEGIN { eval q{ use EV; } }to the generatedt/00_diag.tonce Mojolicious appears in the prereqs, and that line fails theProhibitStringyEvalcritic policy.🤖 Generated with Claude Code