Skip to content

Commit

Permalink
#15: Use config to control generation
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Aug 5, 2019
1 parent cd1668d commit 735eda4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/swagger/swagger_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
import re
from pathlib import Path

from common.config import config


class SwaggerGenerator(object):
FILE_PATH = Path.cwd() / "swagger" / "openapi.yaml"
is_generating = False

def __init__(self):
self.endpoints = []
Expand All @@ -26,7 +27,7 @@ def resource_wrapper(self):
Wrapper for Resource classes that appends the class name to the endpoints list
"""
def decorate(cls):
if SwaggerGenerator.is_generating:
if config.is_generate_swagger():
self.endpoints.append(cls.__name__)
return cls
return decorate
Expand All @@ -36,7 +37,7 @@ def write_swagger_spec(self):
Writes the openapi.yaml file
"""
if SwaggerGenerator.is_generating:
if config.is_generate_swagger():
with open(SwaggerGenerator.FILE_PATH, "w+") as target:
target.write(self.get_yaml_top())
target.write(self.get_yaml_paths())
Expand Down

0 comments on commit 735eda4

Please sign in to comment.