Swagger::Schema - Object access to Swagger / OpenAPI schema files
use File::Slurp; my $data = read_file($swagger_file); my $schema = Swagger::Schema->MooseX::DataModel::new_from_json($data); # use the object model say "This API consists of:"; foreach my $path (sort keys %{ $schema->paths }){ foreach my $http_verb (sort keys %{ $schema->paths->{ $path } }) { say "$http_verb on $path"; } }
Get programmatic access to a Swagger / OpenAPI file.
The object model is defined with MooseX::DataModel. Take a look at the lib/Swagger/Schema.pm file or the swagger spec https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md to know what you can find inside the objects
lib/Swagger/Schema.pm
https://github.com/OAI/OpenAPI-Specification
http://swagger.io
Jose Luis Martinez CAPSiDE jlmartinez@capside.com
The source code is located here: https://github.com/pplu/swagger-schema-perl
Please report bugs to: https://github.com/pplu/swagger-schema-perl/issues
Copyright (c) 2015 by CAPSiDE
This code is distributed under the Apache 2 License. The full text of the license can be found in the LICENSE file included with this module.
To install Swagger::Schema, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Swagger::Schema
CPAN shell
perl -MCPAN -e shell install Swagger::Schema
For more information on module installation, please visit the detailed CPAN module installation guide.