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)
33 if __name__ == '__main__':
34 parser = argparse.ArgumentParser(description='Create \
35 Swagger Spec documentation')
36 parser.add_argument('-ru', '--resource-listing-url',
39 default='http://localhost:8000/swagger/spec.json',
40 help='Resource Listing Spec File')
41 parser.add_argument('-au', '--api-declaration-url',
44 default='http://localhost:8000/swagger/spec',
45 help='API Declaration Spec File')
46 parser.add_argument('-o', '--output-directory',
49 help='Output Directory where the \
50 file should be stored')
51 main(parser.parse_args())