diff options
author | grakiss <grakiss.wanglei@huawei.com> | 2017-09-28 03:47:54 -0400 |
---|---|---|
committer | grakiss <grakiss.wanglei@huawei.com> | 2017-09-28 05:15:01 -0400 |
commit | 0cf6b232ac9cf128ee9183a27c08f4f74ab2e2e6 (patch) | |
tree | 7be233b8f8f65fa968c7b93f1d1e75b691952ed9 /cvp/htmlize/htmlize.py | |
parent | 63c2e2aa4b8d86349a767f611123ceafc19fa6d6 (diff) |
add api&web services for cvp
JIRA: DOVETAIL-512
add api&web services for cvp
Change-Id: I9ef9525e980fe61dc3108035ef9a3ff8783b2697
Signed-off-by: grakiss <grakiss.wanglei@huawei.com>
Diffstat (limited to 'cvp/htmlize/htmlize.py')
-rw-r--r-- | cvp/htmlize/htmlize.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/cvp/htmlize/htmlize.py b/cvp/htmlize/htmlize.py new file mode 100644 index 00000000..da6a6cf9 --- /dev/null +++ b/cvp/htmlize/htmlize.py @@ -0,0 +1,57 @@ +#!/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) + if os.system(cmd) == 0: + exit(0) + else: + exit(1) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Create \ + Swagger Spec documentation') + parser.add_argument('-ru', '--resource-listing-url', + type=str, + required=False, + default=('http://testresults.opnfv.org' + '/test/swagger/resources.json'), + help='Resource Listing Spec File') + parser.add_argument('-au', '--api-declaration-url', + type=str, + required=False, + default=('http://testresults.opnfv.org' + '/test/swagger/APIs'), + 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()) |