jenkins-bot has submitted this change and it was merged.

Change subject: Allow service-checker to read YAML-formatted specs
......................................................................


Allow service-checker to read YAML-formatted specs

Writing Swagger specifications is much easier in YAML, so allow
service-checker to read those as well.

This is going to be needed for reading the MediaWiki spec, which will be
exposed directly as a plain YAML file for now.

Bug: T136839
Change-Id: Ie4f5d5f4946ff030adc19433920acb6a9dc34d80
---
M servicechecker/swagger.py
M setup.py
2 files changed, 7 insertions(+), 1 deletion(-)

Approvals:
  Giuseppe Lavagetto: Verified; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/servicechecker/swagger.py b/servicechecker/swagger.py
index ccc29fe..ea0e918 100755
--- a/servicechecker/swagger.py
+++ b/servicechecker/swagger.py
@@ -4,6 +4,7 @@
 import argparse
 from collections import namedtuple
 import json
+import yaml
 import re
 import sys
 
@@ -86,7 +87,11 @@
         try:
             r = json.loads(resp)
         except ValueError:
-            raise ValueError("No valid spec found")
+            # try to load as YAML
+            try:
+                r = yaml.safe_load(resp)
+            except yaml.YAMLError:
+                raise ValueError("No valid spec found")
 
         TemplateUrl.default = r.get('x-default-params', {})
         base_path = r.get('basePath', '')
diff --git a/setup.py b/setup.py
index 4d289ec..43c0dde 100644
--- a/setup.py
+++ b/setup.py
@@ -8,6 +8,7 @@
 
 install_requires = [
     'urllib3>=1.7',
+    'PyYAML>=3.11'
 ]
 
 test_requires = [

-- 
To view, visit https://gerrit.wikimedia.org/r/306707
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie4f5d5f4946ff030adc19433920acb6a9dc34d80
Gerrit-PatchSet: 3
Gerrit-Project: operations/software/service-checker
Gerrit-Branch: master
Gerrit-Owner: Mobrovac <mobro...@wikimedia.org>
Gerrit-Reviewer: Giuseppe Lavagetto <glavage...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: Mobrovac <mobro...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to