Skip to content

Commit

Permalink
Allow per-Operation docstrings
Browse files Browse the repository at this point in the history
Previously, GET and POST requests both used the same description, which
doesn't make sense when they do different things.  I've changed this to
use` __doc__` or `description` attributes
 on the `get` or `post` method if available.
  • Loading branch information
rwb27 committed Jul 6, 2021
1 parent 559b769 commit 05b2747
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/labthings/apispec/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,19 @@ def spec_for_interaction(cls, interaction):

for method in http_method_funcs:
if hasattr(interaction, method):
property = getattr(interaction, method)
d[method] = {
"description": getattr(interaction, "description", None)
or get_docstring(interaction),
"summary": getattr(interaction, "summary", None)
"description": getattr(property, "description", None)
or get_docstring(property, remove_newlines=False)
or getattr(interaction, "description", None)
or get_docstring(interaction, remove_newlines=False),
"summary": getattr(property, "summary", None)
or get_summary(property)
or getattr(interaction, "summary", None)
or get_summary(interaction),
"tags": list(interaction.get_tags()),
"responses": {
"default": {
"5XX": {
"description": "Unexpected error",
"content": {
"application/json": {
Expand Down

0 comments on commit 05b2747

Please sign in to comment.