From c045a96a47c9e02020b8f9d6fcd05f47d76f896c Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 1 Jan 2019 12:34:55 +0000 Subject: [PATCH] add openapi tags to group operations --- lib/App/Netdisco/Web.pm | 9 +++++++++ lib/App/Netdisco/Web/AuthN.pm | 2 ++ lib/App/Netdisco/Web/Plugin/API/NodeIP.pm | 1 + 3 files changed, 12 insertions(+) diff --git a/lib/App/Netdisco/Web.pm b/lib/App/Netdisco/Web.pm index 795e72b7..83947f7b 100644 --- a/lib/App/Netdisco/Web.pm +++ b/lib/App/Netdisco/Web.pm @@ -77,6 +77,15 @@ my $swagger = Dancer::Plugin::Swagger->instance->doc; $swagger->{schemes} = ['http','https']; $swagger->{consumes} = 'application/json'; $swagger->{produces} = 'application/json'; +$swagger->{tags} = [ + {name => 'Global'}, + {name => 'Devices', + description => 'Operations relating to Devices (switches, routers, etc)'}, + {name => 'Nodes', + description => 'Operations relating to Nodes (end-stations such as printers)'}, + {name => 'NodeIPs', + description => 'Operations relating to MAC-IP mappings (IPv4 ARP and IPv6 Neighbors)'}, +]; $swagger->{securityDefinitions} = { APIKeyHeader => { type => 'apiKey', name => 'Authorization', in => 'header' }, diff --git a/lib/App/Netdisco/Web/AuthN.pm b/lib/App/Netdisco/Web/AuthN.pm index 9a64c53c..ebf7ba09 100644 --- a/lib/App/Netdisco/Web/AuthN.pm +++ b/lib/App/Netdisco/Web/AuthN.pm @@ -81,6 +81,7 @@ get qr{^/(?:login(?:/denied)?)?} => sub { # override default login_handler so we can log access in the database swagger_path { description => 'Obtain an API Key using HTTP BasicAuth', + tags => ['Global'], parameters => [], responses => { default => { @@ -165,6 +166,7 @@ Dancer::Plugin::Swagger->instance->doc->{paths}->{'/login'} # we override the default login_handler, so logout has to be handled as well swagger_path { description => 'Destroy user API Key and session cookie', + tags => ['Global'], parameters => [], responses => { default => { examples => { 'application/json' => {} } } }, }, diff --git a/lib/App/Netdisco/Web/Plugin/API/NodeIP.pm b/lib/App/Netdisco/Web/Plugin/API/NodeIP.pm index 35fef288..ba0cc927 100644 --- a/lib/App/Netdisco/Web/Plugin/API/NodeIP.pm +++ b/lib/App/Netdisco/Web/Plugin/API/NodeIP.pm @@ -13,6 +13,7 @@ use NetAddr::IP::Lite; swagger_path { description => 'Search for a Node to IP mapping (ARP entry)', + tags => ['NodeIPs'], parameters => [ mac => 'MAC address', ip => 'IP address',