File Coverage

blib/lib/Swagger/Schema/Kubernetes.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 28 28 100.0


line stmt bran cond sub pod time code
1 1     1   67287 use Swagger::Schema;
  1         1335788  
  1         102  
2              
3             package Swagger::Schema::KubernetesGroupVersionKind;
4 1     1   11 use MooseX::DataModel;
  1         2  
  1         10  
5              
6             key group => (isa => 'Str', required => 1);
7             key kind => (isa => 'Str', required => 1);
8             key version => (isa => 'Str', required => 1);
9              
10             package Swagger::Schema::KubernetesOperation;
11 1     1   9574 use MooseX::DataModel;
  1         2  
  1         4  
12             extends 'Swagger::Schema::Operation';
13              
14             key x_kubernetes_action => (isa => 'Str', location => 'x-kubernetes-action');
15             key x_kubernetes_group_version_kind => (isa => 'Swagger::Schema::KubernetesGroupVersionKind', location => 'x-kubernetes-group-version-kind');
16              
17             package Swagger::Schema::KubernetesPath;
18 1     1   9009 use MooseX::DataModel;
  1         3  
  1         5  
19             extends 'Swagger::Schema::Path';
20 1     1   9058 use namespace::autoclean;
  1         3  
  1         16  
21              
22             key get => (isa => 'Swagger::Schema::KubernetesOperation');
23             key put => (isa => 'Swagger::Schema::KubernetesOperation');
24             key post => (isa => 'Swagger::Schema::KubernetesOperation');
25             key delete => (isa => 'Swagger::Schema::KubernetesOperation');
26             key options => (isa => 'Swagger::Schema::KubernetesOperation');
27             key head => (isa => 'Swagger::Schema::KubernetesOperation');
28             key patch => (isa => 'Swagger::Schema::KubernetesOperation');
29              
30             package Swagger::Schema::KubernetesSchema;
31 1     1   162 use MooseX::DataModel;
  1         3  
  1         6  
32             extends 'Swagger::Schema::Schema';
33              
34             object properties => (isa => 'Swagger::Schema::KubernetesSchema');
35              
36             array x_kubernetes_list_map_keys => (isa => 'Str', location => 'x-kubernetes-list-map-keys');
37             key x_kubernetes_list_type => (isa => 'Str', location => 'x-kubernetes-list-type');
38             key x_kubernetes_patch_merge_key => (isa => 'Str', location => 'x-kubernetes-patch-merge-key');
39             key x_kubernetes_patch_strategy => (isa => 'Str', location => 'x-kubernetes-patch-strategy');
40              
41             package Swagger::Schema::Kubernetes;
42 1     1   9085 use MooseX::DataModel;
  1         3  
  1         6  
43             our $VERSION = '0.01';
44             extends 'Swagger::Schema';
45             object paths => (isa => 'Swagger::Schema::KubernetesPath', required => 1);
46             object definitions => (isa => 'Swagger::Schema::KubernetesSchema');
47              
48             1;
49             ### main pod documentation begin ###
50            
51             =encoding UTF-8
52            
53             =head1 NAME
54            
55             Swagger::Schema::Kubernetes - Object model to Kubernetes Swagger / OpenAPI schema files
56            
57             =head1 SYNOPSIS
58            
59             use File::Slurp;
60             my $data = read_file($swagger_file);
61             my $schema = Swagger::Schema::Kubernetes->MooseX::DataModel::new_from_json($data);
62             # use the object model
63             say "This API consists of:";
64             foreach my $path (sort keys %{ $schema->paths }){
65             foreach my $http_verb (sort keys %{ $schema->paths->{ $path } }) {
66             say "$http_verb on $path";
67             }
68             }
69            
70             =head1 DESCRIPTION
71            
72             Get programmatic access to Kubenertes Swagger / OpenAPI files.
73              
74             This module builds upon L<Swagger::Schema> to produce the same object model, enabling
75             access to the extra properties that the Kubernetes swagger definitions adds.
76            
77             =head1 OBJECT MODEL
78            
79             The object model is defined with L<MooseX::DataModel>. Take a look at the
80             C<lib/Swagger/Schema/Kubernetes.pm> and C<lib/Swagger/Schema.pm> files or the swagger spec
81             to know what you can find inside the objects
82            
83             =head1 SEE ALSO
84              
85             L<https://github.com/kubernetes/kubernetes/tree/master/api/openapi-spec>
86            
87             L<https://github.com/OAI/OpenAPI-Specification>
88            
89             L<http://swagger.io>
90            
91             =head1 AUTHOR
92            
93             Jose Luis Martinez
94             CAPSiDE
95             jlmartinez@capside.com
96            
97             =head1 BUGS and SOURCE
98            
99             The source code is located here: https://github.com/pplu/swagger-schema-kubernetes
100            
101             Please report bugs to: https://github.com/pplu/swagger-schema-kubernetes/issues
102            
103             =head1 COPYRIGHT and LICENSE
104            
105             Copyright (c) 2018 by CAPSiDE
106            
107             This code is distributed under the Apache 2 License. The full text of the
108             license can be found in the LICENSE file included with this module.