APISchema
view release on metacpan or search on metacpan
lib/APISchema.pm view on Meta::CPAN
package APISchema;
use 5.014;
use strict;
use warnings;
our $VERSION = "1.37";
1;
__END__
=encoding utf-8
=head1 NAME
APISchema - Schema for API
=head1 SYNOPSIS
# bmi.def
resource figure => {
type => 'object',
description => 'Figure, which includes weight and height',
properties => {
weight => {
type => 'number',
description => 'Weight(kg)',
example => 50,
},
height => {
type => 'number',
description => 'Height(m)',
example => 1.6,
},
},
required => ['weight', 'height'],
};
resource bmi => {
type => 'object',
description => 'Body mass index',
properties => {
value => {
type => 'number',
description => 'bmi value',
example => 19.5,
},
},
required => ['value'],
};
POST '/bmi/' => {
title => 'BMI API',
description => 'This API calculates your BMI.',
destination => {
controller => 'BMI',
action => 'calculate',
},
request => 'figure',
response => 'bmi',
};
# main.pl
use APISchema::DSL;
my $schema = APISchema::DSL::process {
include 'bmi.def';
};
# Routing
use APISchema::Generator::Router::Simple;
( run in 1.358 second using v1.01-cache-2.11-cpan-e1769b4cff6 )