summaryrefslogtreecommitdiffstats
path: root/testapi/htmlize/htmlize.py
diff options
context:
space:
mode:
authorrohitsakala <rohitsakala@gmail.com>2016-12-16 00:38:41 +0530
committerrohitsakala <rohitsakala@gmail.com>2017-01-04 17:41:38 +0530
commit934706da3e662945dc56288e3438586b097ed745 (patch)
treeeda5d42da680b050b26bc67aeca36ab31655d7b9 /testapi/htmlize/htmlize.py
parentf6f24d49702a4680b40b3f5bbf809951ef44ac37 (diff)
Create Jenkins Job for testapi automation
Right now, only builder for creating testapi doc is included JIRA: FUNCTEST-664 Change-Id: If0a34154084c1d01ed6b997d2226779da43bcb14 Signed-off-by: rohitsakala <rohitsakala@gmail.com>
Diffstat (limited to 'testapi/htmlize/htmlize.py')
-rw-r--r--testapi/htmlize/htmlize.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/testapi/htmlize/htmlize.py b/testapi/htmlize/htmlize.py
new file mode 100644
index 0000000..68d02fe
--- /dev/null
+++ b/testapi/htmlize/htmlize.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+
+import argparse
+import requests
+import json
+import os
+
+
+def main(args):
+
+ # Merging two specs
+ api_response = requests.get(args.api_declaration_url)
+ api_response = json.loads(api_response.content)
+ resource_response = requests.get(args.resource_listing_url)
+ resource_response = json.loads(resource_response.content)
+ resource_response['models'] = api_response['models']
+ resource_response['apis'] = api_response['apis']
+
+ # Storing the swagger specs
+ with open('specs.json', 'w') as outfile:
+ json.dump(resource_response, outfile)
+
+ # Generating html page
+ cmd = 'java -jar swagger-codegen-cli.jar generate \
+ -i specs.json -l html2 -o %s' % (args.output_directory)
+ os.system(cmd)
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description='Create \
+ Swagger Spec documentation')
+ parser.add_argument('-ru', '--resource-listing-url',
+ type=str,
+ required=False,
+ default='http://localhost:8000/swagger/spec.json',
+ help='Resource Listing Spec File')
+ parser.add_argument('-au', '--api-declaration-url',
+ type=str,
+ required=False,
+ default='http://localhost:8000/swagger/spec',
+ help='API Declaration Spec File')
+ parser.add_argument('-o', '--output-directory',
+ required=True,
+ default='./',
+ help='Output Directory where the \
+ file should be stored')
+ main(parser.parse_args())