Skip to content

Commit

Permalink
#92: Update swagger generator
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 committed Oct 16, 2019
1 parent 3b1e5f7 commit b5e4a6b
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/swagger/swagger_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import yaml

from common.config import config
from src.resources.entities.entity_map import endpoints


class Parameter(object):
Expand Down Expand Up @@ -224,9 +225,6 @@ def get_spec_as_dict(self):
class SwaggerGenerator(object):
FILE_PATH = Path.cwd() / "src" / "swagger" / "openapi.yaml"

def __init__(self):
self.endpoints = []

@staticmethod
def pascal_to_normal(input):
"""
Expand All @@ -238,26 +236,14 @@ def pascal_to_normal(input):
words = re.findall(r"[A-Z]?[a-z]+|[A-Z]{2,}(?=[A-Z][a-z]|\d|\W|$)|\d+", input)
return " ".join(map(str.lower, words))

def resource_wrapper(self):
"""
Wrapper for Resource classes that appends the class name to the endpoints list
"""

def decorate(cls):
if config.is_generate_swagger():
self.endpoints.append(cls.__name__)
return cls

return decorate

def write_swagger_spec(self):
"""
Writes the openapi.yaml file
"""
if config.is_generate_swagger():
swagger_spec = SwaggerSpecification()
for endpoint in self.endpoints:
for endpoint in endpoints:
entity = Entity(endpoint)
swagger_spec.add_path(entity.entity_count_endpoint)
swagger_spec.add_path(entity.entity_id_endpoint)
Expand Down

0 comments on commit b5e4a6b

Please sign in to comment.