Skip to content

Commit

Permalink
Add metadata for openapi render
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaGeo committed Apr 24, 2023
1 parent 6bdc69e commit 77d399c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
38 changes: 37 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,18 @@ def custom_openapi():
openapi_schema = get_openapi(
title="pyagsapi - AGS File Utilities Tools and API",
version="4.5.0",
description=("The API performs schema validation, data validation and conversion of your AGS files. "
description=("The API performs schema validation, data validation and conversion of your AGS files. It also exports a graphical log from AGS data held by NGDC"
"Schema validation and conversion uses https://gitlab.com/ags-data-format-wg/ags-python-library"),
terms_of_service="https://www.bgs.ac.uk/legal-and-policy/terms-of-use/",
contact={
"name": "BGS Enquiries",
"url": "https://www.bgs.ac.uk/about-bgs/contact-us/",
"email": "[email protected]",
},
license_info={
"name": "Open Government Licence v3",
"url": "https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/",
},
routes=app.routes,
)
openapi_schema["info"]["x-logo"] = {
Expand All @@ -95,6 +105,32 @@ def custom_openapi():
app.openapi_schema = openapi_schema
return app.openapi_schema

tags_metadata = [
{
"name": "validate",
"description": "Validate an AGS4 file to the AGS File Format v4.x rules and the NGDC data submission requirements. Uses the Offical AGS4 Python Library.",
"externalDocs": {
"description": "Official AGS4 Python Library",
"url": "https://gitlab.com/ags-data-format-wg/ags-python-library",
},
},
{
"name": "convert",
"description": "Convert files between .ags and .xlsx format. Option to sort worksheets in .xlsx file in alphabetical order. ",
"externalDocs": {
"description": "Official AGS4 Python Library",
"url": "https://gitlab.com/ags-data-format-wg/ags-python-library",
},
},
{
"name": "ags_log",
"description": "Generate a graphical log (.pdf) from AGS data held by the National Geoscience Data Centre.",
"externalDocs": {
"description": "NGDC AGS Data",
"url": "https://ogcapi.bgs.ac.uk/collections/agsboreholeindex",
},
},
]

app.openapi = custom_openapi

Expand Down
3 changes: 3 additions & 0 deletions app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class ResponseType(StrEnum):


@router.post("/validate/",
tags=["validate"],
response_model=ValidationResponse,
responses=log_responses)
async def validate(background_tasks: BackgroundTasks,
Expand Down Expand Up @@ -161,6 +162,7 @@ async def validate(background_tasks: BackgroundTasks,


@router.post("/convert/",
tags=["convert"],
response_class=StreamingResponse,
responses=zip_responses)
async def convert(background_tasks: BackgroundTasks,
Expand Down Expand Up @@ -208,6 +210,7 @@ def prepare_validation_response(request, data):


@router.get("/ags_log/",
tags=["ags_log"],
response_class=Response,
responses=pdf_responses)
def get_ags_log(bgs_loca_id: int = ags_log_query,
Expand Down

0 comments on commit 77d399c

Please sign in to comment.