def write_template(self, output, filename=None):
if not filename:
filename = 'swagger.yml'
swagger_file = os.path.join(self.project_dir, filename)
_, ext = os.path.splitext(filename)
with open(swagger_file, 'w') as fh:
# Could be `.yaml` or `.yml` :/
if '.y' in ext:
fh.write(yaml.round_trip_dump(output))
elif '.json' in ext:
fh.write(json.dumps(output))
return swagger_file
评论列表
文章目录