diff options
author | Trevor Bramwell <tbramwell@linuxfoundation.org> | 2017-11-10 15:25:33 -0800 |
---|---|---|
committer | Trevor Bramwell <tbramwell@linuxfoundation.org> | 2017-11-10 15:30:05 -0800 |
commit | 48a16b2f416af135a60e92e1292bb126ba38523c (patch) | |
tree | 822f6f5f93dbc322779eab552a335bb33184b2c4 /ci/htmlize/htmlize.py | |
parent | 5dba82b4e8b5560eb726603d290698ca4c22ea11 (diff) |
Initial Commit CI Files
These files come from the releng repository and are used in the
automated deploy of testapi. Moving them into this repository removes
the need to clone multiple repositories when deploying the testapi site
and verifying the repository.
Change-Id: Ibd54c47bd76e3f2d801cfb4eaaeb1623bd1ae7b9
Signed-off-by: Trevor Bramwell <tbramwell@linuxfoundation.org>
Diffstat (limited to 'ci/htmlize/htmlize.py')
-rw-r--r-- | ci/htmlize/htmlize.py | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ci/htmlize/htmlize.py b/ci/htmlize/htmlize.py new file mode 100644 index 0000000..da6a6cf --- /dev/null +++ b/ci/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()) |