Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #103 #104

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,14 @@ celerybeat-schedule
# dotenv
.env

# virtualenv
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
Expand All @@ -88,4 +93,9 @@ ENV/
.ropeproject

.idea
sanic/*
sanic/*

# mypy
.mypy_cache/
chenjr0719 marked this conversation as resolved.
Show resolved Hide resolved
.dmypy.json
dmypy.json
5 changes: 3 additions & 2 deletions sanic_openapi/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ def __init__(self, cls, *args, object_name=None, **kwargs):
self.cls = cls
self.object_name = object_name or cls.__name__

if self.cls not in definitions:
definitions[self.cls] = (self, self.definition)
register_as = object_name or "{}.{}".format(cls.__module__, cls.__qualname__)
if register_as not in definitions:
definitions[register_as] = (self, self.definition)
chenjr0719 marked this conversation as resolved.
Show resolved Hide resolved

@property
def definition(self):
Expand Down
4 changes: 3 additions & 1 deletion sanic_openapi/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ def build_spec(app, loop):
# --------------------------------------------------------------- #

_spec['definitions'] = {
obj.object_name: definition for cls, (obj, definition) in definitions.items()}
obj.object_name: definition
for obj, definition in definitions.values()
}

# --------------------------------------------------------------- #
# Tags
Expand Down