NAME
WWW::Gitea::Role::OpenAPI - operationId-based dispatch against a cached operation table
VERSION
version 0.001
SYNOPSIS
package WWW::Gitea::API::Repos;
use Moo;
has client => ( is => 'ro', required => 1, weak_ref => 1 );
has openapi_operations => (
is => 'lazy',
builder => sub {
return {
'repos.get' => { method => 'GET', path => '/repos/{owner}/{repo}' },
'repos.delete' => { method => 'DELETE', path => '/repos/{owner}/{repo}' },
# ...
};
},
);
with 'WWW::Gitea::Role::OpenAPI';
sub get {
my ($self, $owner, $repo) = @_;
return $self->call_operation('repos.get',
path => { owner => $owner, repo => $repo },
);
}
DESCRIPTION
Role for API controllers that dispatch by operationId. The consumer ships a pre-computed operation table via "openapi_operations", avoiding any YAML/JSON spec parsing at runtime. Modelled on WWW::PayPal::Role::OpenAPI (itself inspired by Langertha::Role::OpenAPI): no OpenAPI::Modern, no spec loading, just a cached lookup table.
Path parameters in curly braces ({owner}, {repo}, {index}, {id}, ...) are substituted from the path argument to "call_operation".
Consumers must provide:
client— a WWW::Gitea instance (used for HTTP).openapi_operations— HashRef mappingoperationIdto{ method, path, content_type? }.
get_operation
my $op = $self->get_operation('repos.get');
Returns the operation HashRef (method, path, optional content_type) for the given operationId.
call_operation
my $data = $self->call_operation('repos.get',
path => { owner => 'getty', repo => 'p5-www-gitea' },
);
Dispatches an operation by operationId, substitutes path parameters, and returns the decoded JSON response.
SEE ALSO
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://codeberg.org/getty/p5-www-gitea/issues.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.