Skip to content

Commit 05b2747

Browse files
committed
Allow per-Operation docstrings
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.
1 parent 559b769 commit 05b2747

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/labthings/apispec/plugins.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,19 @@ def spec_for_interaction(cls, interaction):
6060

6161
for method in http_method_funcs:
6262
if hasattr(interaction, method):
63+
property = getattr(interaction, method)
6364
d[method] = {
64-
"description": getattr(interaction, "description", None)
65-
or get_docstring(interaction),
66-
"summary": getattr(interaction, "summary", None)
65+
"description": getattr(property, "description", None)
66+
or get_docstring(property, remove_newlines=False)
67+
or getattr(interaction, "description", None)
68+
or get_docstring(interaction, remove_newlines=False),
69+
"summary": getattr(property, "summary", None)
70+
or get_summary(property)
71+
or getattr(interaction, "summary", None)
6772
or get_summary(interaction),
6873
"tags": list(interaction.get_tags()),
6974
"responses": {
70-
"default": {
75+
"5XX": {
7176
"description": "Unexpected error",
7277
"content": {
7378
"application/json": {

0 commit comments

Comments
 (0)