summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/BzAPI/Extension.pm8
-rw-r--r--extensions/BzAPI/lib/Constants.pm5
-rw-r--r--extensions/BzAPI/lib/Resources/Bugzilla.pm20
3 files changed, 31 insertions, 2 deletions
diff --git a/extensions/BzAPI/Extension.pm b/extensions/BzAPI/Extension.pm
index 0790e6596..cd08369b0 100644
--- a/extensions/BzAPI/Extension.pm
+++ b/extensions/BzAPI/Extension.pm
@@ -146,8 +146,12 @@ sub webservice_rest_response {
$cache->{bzapi_rpc} ||= $rpc;
return if !Bugzilla->request_cache->{bzapi}
- || ref $$result ne 'HASH'
- || exists $$result->{error};
+ || ref $$result ne 'HASH';
+
+ if (exists $$result->{error}) {
+ $$result->{documentation} = BZAPI_DOC;
+ return;
+ }
# Load the appropriate response handler based on path and type
if (my $handler = _find_handler($rpc, 'response')) {
diff --git a/extensions/BzAPI/lib/Constants.pm b/extensions/BzAPI/lib/Constants.pm
index c36543daf..65ae00480 100644
--- a/extensions/BzAPI/lib/Constants.pm
+++ b/extensions/BzAPI/lib/Constants.pm
@@ -17,6 +17,8 @@ our @EXPORT = qw(
ATTACHMENT_FIELD_MAP
DEFAULT_BUG_FIELDS
DEFAULT_ATTACHMENT_FIELDS
+
+ BZAPI_DOC
);
# These are fields that are normally exported as a single value such
@@ -147,4 +149,7 @@ use constant ATTACHMENT_FIELD_MAP => {
'type' => 'content_type',
};
+# A base link to the current BzAPI Documentation.
+use constant BZAPI_DOC => 'https://wiki.mozilla.org/Bugzilla:BzAPI';
+
1;
diff --git a/extensions/BzAPI/lib/Resources/Bugzilla.pm b/extensions/BzAPI/lib/Resources/Bugzilla.pm
index 6c436e861..26aae0849 100644
--- a/extensions/BzAPI/lib/Resources/Bugzilla.pm
+++ b/extensions/BzAPI/lib/Resources/Bugzilla.pm
@@ -17,6 +17,9 @@ use Bugzilla::Keyword;
use Bugzilla::Product;
use Bugzilla::Status;
use Bugzilla::Field;
+use Bugzilla::Util qw(correct_urlbase);
+
+use Bugzilla::Extension::BzAPI::Constants;
use Digest::MD5 qw(md5_base64);
@@ -27,10 +30,18 @@ use Digest::MD5 qw(md5_base64);
BEGIN {
require Bugzilla::WebService::Bugzilla;
*Bugzilla::WebService::Bugzilla::get_configuration = \&get_configuration;
+ *Bugzilla::WebService::Bugzilla::get_empty = \&get_empty;
}
sub rest_handlers {
my $rest_handlers = [
+ qr{^/$}, {
+ GET => {
+ resource => {
+ method => 'get_empty'
+ }
+ }
+ },
qr{^/configuration$}, {
GET => {
resource => {
@@ -115,4 +126,13 @@ sub get_configuration {
return $result;
}
+sub get_empty {
+ my ($self) = @_;
+ return {
+ urlbase => $self->type('string', correct_urlbase() . "bzapi/"),
+ documentation => $self->type('string', BZAPI_DOC),
+ version => $self->type('string', BUGZILLA_VERSION)
+ };
+}
+
1;