Group
Extension

Matches 9

Mojolicious-Plugin-OpenAPI ( J/JH/JHTHORSEN/Mojolicious-Plugin-OpenAPI-5.11.tar.gz, JHTHORSEN, 2025; MetaCPAN )
Mojolicious-Plugin-OpenAPI/lib/Mojolicious/Plugin/OpenAPI.pm ( view source; MetaCPAN )
package Mojolicious::Plugin::OpenAPI;
use Mojo::Base 'Mojolicious::Plugin';

use JSON::Validator;
use Mojo::JSON;
use Mojo::Util;
use Mojolicious::Plugin::OpenAPI::Parameters;

use constant DEBUG => $
ute     => sub {undef};
has validator => sub { JSON::Validator::Schema->new; };

sub register {
  my ($self, $app, $config) = @_;

  $self->validator(JSON::Validator->new->schema($config->{url} || $co
c    = shift;
  my $path = shift // 'for_current';
  my $self = _self($c);

  # Get spec by valid JSON pointer
  return $self->validator->get($path) if ref $path or $path =~ m!^/! or !length $path;

 
Mojolicious-Plugin-OpenAPI ( J/JH/JHTHORSEN/Mojolicious-Plugin-OpenAPI-5.11.tar.gz, JHTHORSEN, 2025; MetaCPAN )
Mojolicious-Plugin-OpenAPI/lib/Mojolicious/Plugin/OpenAPI/Guides/OpenAPIv2.pod ( view source; MetaCPAN )
pecification>
and generate routes and input/output rules from it. See L<JSON::Validator> for
L<supported schema file formats|JSON::Validator/Supported schema formats>.

  {
    "swagger": "2.0",
    "
 from the keys
under C</pets>.

The different parts of the specification can also be retrieved as JSON using
the "OPTIONS" HTTP method. Example:

  OPTIONS /api/pets
  OPTIONS /api/pets?method=get

No
h

The C<basePath> will also be used to add a route that renders back the
specification either as JSON or HTML. Examples:

=over 2

=item * http://example.com/api.html

Retrieve the expanded version o
Mojolicious-Plugin-OpenAPI ( J/JH/JHTHORSEN/Mojolicious-Plugin-OpenAPI-5.11.tar.gz, JHTHORSEN, 2025; MetaCPAN )
Mojolicious-Plugin-OpenAPI/lib/Mojolicious/Plugin/OpenAPI/SpecRenderer.pm ( view source; MetaCPAN )
jolicious::Plugin::OpenAPI::SpecRenderer;
use Mojo::Base 'Mojolicious::Plugin';

use JSON::Validator;
use Mojo::JSON;
use Scalar::Util qw(blessed);

use constant DEBUG    => $ENV{MOJO_OPENAPI_DEBUG} |
fication} // 1) {
    my $spec_route = $openapi->route->get(
      '/',
      [format => [qw(html json)]],
      {format => undef},
      sub { shift->openapi->render_spec(@_) }
    );
    my $name = 
>render(json => {errors => [{message => 'No spec defined.'}]}, status => 404)
    unless my $schema = $validator->get([paths => $path, $method ? ($method) : ()]);

  return $c->render(
    json => {
 
Mojolicious-Plugin-OpenAPI ( J/JH/JHTHORSEN/Mojolicious-Plugin-OpenAPI-5.11.tar.gz, JHTHORSEN, 2025; MetaCPAN )
Mojolicious-Plugin-OpenAPI/lib/Mojolicious/Plugin/OpenAPI/Security.pm ( view source; MetaCPAN )
startup {
    my $app = shift;

    $app->plugin(OpenAPI => {
      url      => "data:///security.json",
      security => {
        dummy => sub {
          my ($c, $definition, $scopes, $cb) = @_;
 
Mojolicious-Plugin-OpenAPI ( J/JH/JHTHORSEN/Mojolicious-Plugin-OpenAPI-5.11.tar.gz, JHTHORSEN, 2025; MetaCPAN )
Mojolicious-Plugin-OpenAPI/lib/Mojolicious/Plugin/OpenAPI/Cors.pm ( view source; MetaCPAN )
message => "Some error!", path => "/Whatever"}];
  return [{message => "Some error!"}];
  return [JSON::Validator::Error->new];

=back

On success, the following headers will be set, unless already se
Mojolicious-Plugin-OpenAPI ( J/JH/JHTHORSEN/Mojolicious-Plugin-OpenAPI-5.11.tar.gz, JHTHORSEN, 2025; MetaCPAN )
Mojolicious-Plugin-OpenAPI/lib/Mojolicious/Plugin/OpenAPI/Parameters.pm ( view source; MetaCPAN )
:Parameters;
use Mojo::Base 'Mojolicious::Plugin';

use JSON::Validator::Util qw(is_bool schema_type);
use Mojo::JSON qw(encode_json decode_json);

sub register {
  my ($self, $app, $config) = @_;

  
o::Asset');
  $c->res->headers->content_type('application/json;charset=UTF-8')
    unless $c->res->headers->content_type;
  return encode_json($_[0]);
}

sub _helper_build_schema_request {
  my $c   =
 the already parsed json() or fallback to manually decoding the request
    # since it will make the eval {} fail on invalid json.
    $res->{value} //= $c->req->json // decode_json $c->req->body;
   
Mojolicious-Plugin-OpenAPI ( J/JH/JHTHORSEN/Mojolicious-Plugin-OpenAPI-5.11.tar.gz, JHTHORSEN, 2025; MetaCPAN )
Mojolicious-Plugin-OpenAPI/lib/Mojolicious/Plugin/OpenAPI/Guides/OpenAPIv3.pod ( view source; MetaCPAN )
ecification>
and generates routes and input/output rules from it. See L<JSON::Validator> for
L<supported schema file formats|JSON::Validator/Supported schema formats>.

  {
    "openapi": "3.0.2",
   
    }
          ],
          "requestBody": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
            
           "description": "Pet response",
              "content": {
                "application/json": {
                  "schema": {
                    "type": "object",
                    "prop
Mojolicious-Plugin-OpenAPI ( J/JH/JHTHORSEN/Mojolicious-Plugin-OpenAPI-5.11.tar.gz, JHTHORSEN, 2025; MetaCPAN )
Mojolicious-Plugin-OpenAPI/lib/Mojolicious/Plugin/OpenAPI/Guides/Swagger2.pod ( view source; MetaCPAN )

    # Load your specification
    $self->plugin("OpenAPI" => {url => $app->home->rel_file("myapi.json")});

    $self->hook(around_action => sub {
      my ($next, $c, $action, $last) = @_;

      # 
Mojolicious-Plugin-OpenAPI ( J/JH/JHTHORSEN/Mojolicious-Plugin-OpenAPI-5.11.tar.gz, ASHIMEMA, 2025; MetaCPAN )
Mojolicious-Plugin-OpenAPI/lib/Mojolicious/Plugin/OpenAPI/Guides/Tutorial.pod ( view source; MetaCPAN )
pecification>
and generate routes and input/output rules from it. See L<JSON::Validator> for
L<supported schema file formats|JSON::Validator/Supported schema formats>.

  {
    "swagger": "2.0",
    "
 from the keys
under C</pets>.

The different parts of the specification can also be retrieved as JSON using
the "OPTIONS" HTTP method. Example:

  OPTIONS /api/pets
  OPTIONS /api/pets?method=get

No
h

The C<basePath> will also be used to add a route that renders back the
specification either as JSON or HTML. Examples:

=over 2

=item * http://example.com/api.html

Retrieve the expanded version o

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.