Manager API: Added 404 response code to openapi spec, improved error message on category not found when getting/listing application(s) and added tests to ensure 404 is returned on category or apps not found.

Moo
Soisik Froger 5 years ago
parent de2db0fd5b
commit 53cce170d2
  1. 48
      doc/pages/manager-api/index.html
  2. 2
      doc/sources/manager-api/openapi-spec.yaml
  3. 10
      lemonldap-ng-manager/lib/Lemonldap/NG/Manager/Api/Menu/App.pm
  4. 12
      lemonldap-ng-manager/t/04-menu-api.t

@ -7939,6 +7939,54 @@ except ApiException as e:
</div>
</div>
<h3> Status: 404 - The specified resource was not found </h3>
<ul class="nav nav-tabs nav-tabs-examples" >
<li class="active">
<a data-toggle="tab" href="#responses-getMenuApps-404-schema">Schema</a>
</li>
</ul>
<div class="tab-content" style='margin-bottom: 10px;'>
<div class="tab-pane active" id="responses-getMenuApps-404-schema">
<div id='responses-getMenuApps-404-schema-404' style="padding: 30px; border-left: 1px solid #eee; border-right: 1px solid #eee; border-bottom: 1px solid #eee;">
<script>
$(document).ready(function() {
var schemaWrapper = {
"description" : "The specified resource was not found",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/Error"
}
}
}
};
var schema = schemaWrapper.content["application/json"].schema;
if (schema.$ref != null) {
schema = defsParser.$refs.get(schema.$ref);
} else {
schemaWrapper.components = {};
schemaWrapper.components.schemas = Object.assign({}, defs);
$RefParser.dereference(schemaWrapper).catch(function(err) {
console.log(err);
});
}
//console.log(JSON.stringify(schema));
var view = new JSONSchemaView(schema, 3);
$('#responses-getMenuApps-404-schema-data').val(stringify(schema));
var result = $('#responses-getMenuApps-404-schema-404');
result.empty();
result.append(view.render());
});
</script>
</div>
<input id='responses-getMenuApps-404-schema-data' type='hidden' value=''></input>
</div>
</div>
</article>
</div>
<hr>

@ -787,6 +787,8 @@ paths:
$ref: '#/components/responses/ManyMenuApp'
400:
$ref: '#/components/responses/Error'
404:
$ref: '#/components/responses/NotFound'
post:
tags:
- menuapp

@ -23,6 +23,11 @@ sub getMenuApp {
# Get latest configuration
my $conf = $self->_confAcc->getConf;
# Check if catConfKey is defined
return $self->sendError( $req,
"Menu category '$catConfKey' not found", 404 )
unless ( defined $conf->{applicationList}->{$catConfKey} );
if ( defined $appConfKey ) {
# Return one application referenced with this appConfKey
@ -50,11 +55,6 @@ sub getMenuApp {
"[API] Menu applications from category $catConfKey configuration requested"
);
# Check if catConfKey is defined
return $self->sendError( $req,
"Menu category '$catConfKey' not found", 404 )
unless ( defined $conf->{applicationList}->{$catConfKey} );
my $cat = $conf->{applicationList}->{$catConfKey};
my @menuApps =

@ -301,6 +301,9 @@ my $cat2 = {
order => 2
};
$test = "Cat - Get mycat1 cat should err on not found";
checkGetNotFound( $test, 'cat', 'mycat1' );
$test = "Cat - Add should succeed";
checkAdd( $test, 'cat', $cat1 );
checkGet( $test, 'cat', 'mycat1', 'catname', 'My Cat 1' );
@ -382,6 +385,15 @@ my $app3 = {
order => 1
};
$test = "App - Get mycat3 apps should err on not found";
checkGetNotFound( $test, 'app', 'mycat3' );
$test = "App - Get app myapp1 from existing mycat2 should err on not found";
checkGetNotFound( $test, 'app/mycat2', 'myapp1' );
$test = "App - Get app myapp1 from mycat3 should err on not found";
checkGetNotFound( $test, 'app/mycat3', 'myapp1' );
$test = "App - Add app1 to cat1 should succeed";
checkAdd( $test, 'app/mycat1', $app1 );
checkGet( $test, 'app/mycat1', 'myapp1', 'order', '1' );

Loading…
Cancel
Save