From f6428b2d9d64a8c12b907d935a99674582fa0c31 Mon Sep 17 00:00:00 2001
From: Martijn Vermaat <martijn@vermaat.name>
Date: Fri, 6 Dec 2013 14:35:26 +0100
Subject: [PATCH] Update JSON webservice to use JsonDocument instead of
 deprecated JsonObject

This changes the output format of the JSON webservice. Results are no longer
wrapped (twice) in an object. For example, the request

    /checkSyntax?variant=AB026906.1:c.274del

used to return

    {"checkSyntaxResponse": {"checkSyntaxResult":
      {"valid": true, "messages": {"SoapMessage": []}}}}

and now returns

    {"valid": true, "messages": []}

We also use "soft" input validation.
---
 mutalyzer/services/json.py | 9 +++------
 mutalyzer/services/rpc.py  | 2 ++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/mutalyzer/services/json.py b/mutalyzer/services/json.py
index de28cb83..6362282c 100644
--- a/mutalyzer/services/json.py
+++ b/mutalyzer/services/json.py
@@ -5,17 +5,14 @@ Mutalyzer web service HTTP/RPC with JSON response payloads.
 
 from spyne.application import Application
 from spyne.protocol.http import HttpRpc
-from spyne.protocol.json import JsonObject
+from spyne.protocol.json import JsonDocument
 
 import mutalyzer
 from mutalyzer.services import rpc
 
 
 # HTTP/RPC application.
-# Output JSON can be made more consise by specifying skip_depth=2 in the
-# JsonObject constructor, but to match the API documentation better (and hence
-# have more predictable behaviour) we leave it out.
 application = Application([rpc.MutalyzerService], tns=mutalyzer.SOAP_NAMESPACE,
-                          in_protocol=HttpRpc(),
-                          out_protocol=JsonObject(),
+                          in_protocol=HttpRpc(validator='soft'),
+                          out_protocol=JsonDocument(),
                           name='Mutalyzer')
diff --git a/mutalyzer/services/rpc.py b/mutalyzer/services/rpc.py
index 80ecfb81..3a8b701a 100644
--- a/mutalyzer/services/rpc.py
+++ b/mutalyzer/services/rpc.py
@@ -5,6 +5,8 @@ Mutalyzer RPC services.
        kind of strictness checks on the input. For example, in
        transcriptInfo, the build argument must really be present. (Hint:
        use __checkBuild.)
+       We should use the built-in validator functionality from Spyne for
+       this.
 """
 
 
-- 
GitLab