From fff0db10e3a26d5403cdca3496df04d8a81b030d Mon Sep 17 00:00:00 2001
From: Cole Helbling <cole.e.helbling@outlook.com>
Date: Wed, 28 Apr 2021 12:16:13 -0700
Subject: [PATCH] ToJSON: allow custom as_json function

This allows us to modify what the API responds with, which in turn lets us unify
the OpenAPI specification and the actual API's responses.
---
 src/lib/Hydra/Component/ToJSON.pm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/lib/Hydra/Component/ToJSON.pm b/src/lib/Hydra/Component/ToJSON.pm
index e8f439de..727a5b1f 100644
--- a/src/lib/Hydra/Component/ToJSON.pm
+++ b/src/lib/Hydra/Component/ToJSON.pm
@@ -10,6 +10,10 @@ use JSON;
 sub TO_JSON {
     my $self = shift;
 
+    if ($self->can("as_json")) {
+        return $self->as_json();
+    }
+
     my $hint = $self->json_hint;
 
     my %json = ();