|
|
@ -384,14 +384,47 @@ sub generate_swagger_datastructure {
|
|
|
|
|
|
|
|
|
|
|
|
# ---------------------------------------------
|
|
|
|
# ---------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# possible values for types: null, (select options), Number, Boolean, Array, Object, String
|
|
|
|
|
|
|
|
my $e = _fields_to_swagger_schema($col->{fields});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$schemas{$entity} = $e;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $role = "".$user_role;
|
|
|
|
|
|
|
|
my $result = {
|
|
|
|
|
|
|
|
"openapi" => "3.0.0",
|
|
|
|
|
|
|
|
"info" => {
|
|
|
|
|
|
|
|
"title" => "NGCP API",
|
|
|
|
|
|
|
|
"description" => "Sipwise NGCP API (role $role)",
|
|
|
|
|
|
|
|
"version" => "1.0.1",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"servers" => [ { "url" => "/api" } ],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paths" => \%paths,
|
|
|
|
|
|
|
|
"tags" => \@tag_descriptions,
|
|
|
|
|
|
|
|
"components" => {
|
|
|
|
|
|
|
|
"schemas" => \%schemas,
|
|
|
|
|
|
|
|
"responses" => \%responses,
|
|
|
|
|
|
|
|
"parameters" => \%parameters,
|
|
|
|
|
|
|
|
"requestBodies" => \%requestBodies,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# this is recursive to parse subfields
|
|
|
|
|
|
|
|
sub _fields_to_swagger_schema {
|
|
|
|
|
|
|
|
my ($fields) = @_;
|
|
|
|
|
|
|
|
|
|
|
|
my $e = {
|
|
|
|
my $e = {
|
|
|
|
type => "object",
|
|
|
|
type => "object",
|
|
|
|
properties => {},
|
|
|
|
properties => {},
|
|
|
|
required => [],
|
|
|
|
required => [],
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# possible values for types: null, (select options), Number, Boolean, Array, Object, String
|
|
|
|
for my $f (@{ $fields }) {
|
|
|
|
for my $f (@{ $col->{fields} }) {
|
|
|
|
|
|
|
|
my $p = {};
|
|
|
|
my $p = {};
|
|
|
|
if ($f->{type_original} eq "Select" ||
|
|
|
|
if ($f->{type_original} eq "Select" ||
|
|
|
|
($f->{type_original} =~ m/\+NGCP::Panel::Field::.*Select$/ && $f->{enum})) {
|
|
|
|
($f->{type_original} =~ m/\+NGCP::Panel::Field::.*Select$/ && $f->{enum})) {
|
|
|
@ -415,7 +448,13 @@ sub generate_swagger_datastructure {
|
|
|
|
$p->{type} = "string";
|
|
|
|
$p->{type} = "string";
|
|
|
|
} elsif ($f->{type_original} eq "Repeatable" || grep {m/^Array$/} @{$f->{types}}) {
|
|
|
|
} elsif ($f->{type_original} eq "Repeatable" || grep {m/^Array$/} @{$f->{types}}) {
|
|
|
|
$p->{type} = "array";
|
|
|
|
$p->{type} = "array";
|
|
|
|
|
|
|
|
if ($f->{subfields}) {
|
|
|
|
|
|
|
|
$p->{items} = _fields_to_swagger_schema($f->{subfields});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$p->{items}{type} = "object"; # content of array basically unspecified
|
|
|
|
$p->{items}{type} = "object"; # content of array basically unspecified
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} elsif ($f->{subfields}) { # object with subfields
|
|
|
|
|
|
|
|
$p = _fields_to_swagger_schema($f->{subfields});
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$p->{type} = "object"; # object or uncategorizable
|
|
|
|
$p->{type} = "object"; # object or uncategorizable
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -434,30 +473,7 @@ sub generate_swagger_datastructure {
|
|
|
|
delete $e->{properties}; # try delete empty properties (then it's a valid Free Form Object)
|
|
|
|
delete $e->{properties}; # try delete empty properties (then it's a valid Free Form Object)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$schemas{$entity} = $e;
|
|
|
|
return $e;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $role = "".$user_role;
|
|
|
|
|
|
|
|
my $result = {
|
|
|
|
|
|
|
|
"openapi" => "3.0.0",
|
|
|
|
|
|
|
|
"info" => {
|
|
|
|
|
|
|
|
"title" => "NGCP API",
|
|
|
|
|
|
|
|
"description" => "Sipwise NGCP API (role $role)",
|
|
|
|
|
|
|
|
"version" => "1.0.1",
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
"servers" => [ { "url" => "/api" } ],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"paths" => \%paths,
|
|
|
|
|
|
|
|
"tags" => \@tag_descriptions,
|
|
|
|
|
|
|
|
"components" => {
|
|
|
|
|
|
|
|
"schemas" => \%schemas,
|
|
|
|
|
|
|
|
"responses" => \%responses,
|
|
|
|
|
|
|
|
"parameters" => \%parameters,
|
|
|
|
|
|
|
|
"requestBodies" => \%requestBodies,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
1;
|
|
|
|
1;
|
|
|
|