3 # All rights reserved. This program and the accompanying materials
4 # are made available under the terms of the Apache License, Version 2.0
5 # which accompanies this distribution, and is available at
6 # http://www.apache.org/licenses/LICENSE-2.0
17 api_response = requests.get(args.api_declaration_url)
18 api_response = json.loads(api_response.content)
19 resource_response = requests.get(args.resource_listing_url)
20 resource_response = json.loads(resource_response.content)
21 resource_response['models'] = api_response['models']
22 resource_response['apis'] = api_response['apis']
24 # Storing the swagger specs
25 with open('specs.json', 'w') as outfile:
26 json.dump(resource_response, outfile)
28 # Generating html page
29 cmd = 'java -jar swagger-codegen-cli.jar generate \
30 -i specs.json -l html2 -o %s' % (args.output_directory)
31 if os.system(cmd) == 0:
37 if __name__ == '__main__':
38 parser = argparse.ArgumentParser(description='Create \
39 Swagger Spec documentation')
40 parser.add_argument('-ru', '--resource-listing-url',
43 default=('http://testresults.opnfv.org'
44 '/test/swagger/resources.json'),
45 help='Resource Listing Spec File')
46 parser.add_argument('-au', '--api-declaration-url',
49 default=('http://testresults.opnfv.org'
50 '/test/swagger/APIs'),
51 help='API Declaration Spec File')
52 parser.add_argument('-o', '--output-directory',
55 help='Output Directory where the \
56 file should be stored')
57 main(parser.parse_args())