Mojolic...ameters(3)

🌸 NAME 🌸

okay bestie, say hi to Mojolicious::Plugin::OpenAPI::Parameters β€” literally Methods for transforming data from/to JSON::Validator::Schema. This is a User Contributed Perl Documentation moment, and it’s giving very helpful helper-module energy. πŸ’…βœ¨

πŸ’– DESCRIPTION πŸ’–

Mojolicious::Plugin::OpenAPI::Parameters adds helpers to your Mojolicious application, required by Mojolicious::Plugin::OpenAPI. These helpers can be redefined in case you have special needs. no cap, they’re customizable like that 🫢

πŸ› οΈ HELPERS πŸ› οΈ

🌟 openapi.build_response_body 🌟

$bytes = $c->openapi->build_response_body(Mojo::Asset->new);
$bytes = $c->openapi->build_response_body($data);

Takes validated data and turns it into bytes that will be used as HTTP response body. This method is useful to override, in case you want to render some other structure than JSON. highkey iconic override potential πŸ’–

🌟 openapi.build_schema_request 🌟

$hash_ref = $c->openapi->build_schema_request;

Builds input data for "validate_request" in JSON::Validator::Schema::OpenAPIv2. slay, it’s building that request-validation input ✨

🌟 openapi.build_schema_response 🌟

$hash_ref = $c->openapi->build_schema_response;

Builds input data for "validate_response" in JSON::Validator::Schema::OpenAPIv2. same vibe, but for the response side of the group chat πŸ¦‹

🌟 openapi.coerce_request_parameters 🌟

$c->openapi->coerce_request_parameters(\@evaluated_parameters);

Used by Mojolicious::Plugin::OpenAPI to write the validated data back to "req" in Mojolicious::Controller and "output" in Mojolicious::Validator::Validation. it’s literally putting the validated data back where it belongs πŸ’«

🌟 openapi.coerce_response_parameters 🌟

$c->openapi->coerce_response_parameters(\@evaluated_parameters);

Used by Mojolicious::Plugin::OpenAPI to write the validated data to "res" in Mojolicious::Controller. response data getting its little moment πŸŽ€

🌟 openapi.parse_request_body 🌟

$hash_ref = $c->openapi->parse_request_body;

Returns a structure representing the request body. The default is to parse the input as JSON:

{content_type => "application/json", exists => !!$c->req->body_size, value => $c->req->json};

This method is useful to override, in case you want to parse some other structure than JSON. bestie, the default is JSON-coded, but you can absolutely do your own thing πŸ’…

🧚 METHODS 🧚

✨ register ✨

$self->register($app, \%config);

This method will add the HELPERS to your Mojolicious $app. periodt, that’s how they get in there 🫢

πŸ”— SEE ALSO πŸ”—

Mojolicious::Plugin::OpenAPI. go read that one too, iykyk 🌈


mwah πŸ’‹ this page is from perl v5.42.0, dated 2025-08-03. iconic, honestly. πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from