Skip to content

Commit

Permalink
Merge pull request #468 from munrojm/enhance_getbykey_descriptions
Browse files Browse the repository at this point in the history
Enable enhanced documentation
  • Loading branch information
munrojm committed Aug 4, 2021
2 parents 7eca4d5 + c4d0932 commit 5c8c620
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/maggma/api/API.py
Expand Up @@ -23,6 +23,8 @@ def __init__(
version: str = "v0.0.0",
debug: bool = False,
heartbeat_meta: Optional[Dict] = None,
description: str = None,
tags_meta: List[Dict] = None,
):
"""
Args:
Expand All @@ -31,11 +33,15 @@ def __init__(
version: the version for this API
debug: turns debug on in FastAPI
heartbeat_meta: dictionary of additional metadata to include in the heartbeat response
description: decription of the API to be used in the generated docs
tags_meta: descriptions of tags to be used in the generated docs
"""
self.title = title
self.version = version
self.debug = debug
self.heartbeat_meta = heartbeat_meta
self.description = description
self.tags_meta = tags_meta

if len(resources) == 0:
raise RuntimeError("ERROR: There are no endpoints provided")
Expand All @@ -60,6 +66,8 @@ def app(self):
version=self.version,
on_startup=[self.on_startup],
debug=self.debug,
description=self.description,
openapi_tags=self.tags_meta,
)

# Allow requests from other domains in debug mode. This allows
Expand Down
3 changes: 2 additions & 1 deletion src/maggma/api/query_operator/sparse_fields.py
Expand Up @@ -30,7 +30,8 @@ def __init__(
def query(
fields: str = Query(
None,
description=f"Fields to project from {str(model_name)} as a list of comma seperated strings",
description=f"Fields to project from {str(model_name)} as a list of comma seperated strings.\
Fields include: {model_fields}",
),
all_fields: bool = Query(False, description="Include all fields."),
) -> STORE_PARAMS:
Expand Down
3 changes: 2 additions & 1 deletion src/maggma/api/resource/read_resource.py
Expand Up @@ -147,7 +147,8 @@ async def get_by_key(

self.router.get(
f"{self.sub_path}{{{key_name}}}/",
response_description=f"Get an {model_name} by {key_name}",
summary=f"Get a {model_name} document by by {key_name}",
response_description=f"Get a {model_name} document by {key_name}",
response_model=self.response_model,
response_model_exclude_unset=True,
tags=self.tags,
Expand Down

0 comments on commit 5c8c620

Please sign in to comment.