1
0
mirror of https://github.com/ilri/dspace-statistics-api.git synced 2025-05-08 14:16:01 +02:00

Changes for Falcon 3.0.0

Mostly it seems we just need to use resp.text instead of resp.body,
including in falcon-swagger-ui (I forked the upstream one to make
this change).

See: https://falcon.readthedocs.io/en/latest/changes/3.0.0.html
This commit is contained in:
2021-03-21 10:32:58 +02:00
parent 0650c5985e
commit 2f8e4f8a0a
6 changed files with 25 additions and 25 deletions

View File

@ -31,7 +31,7 @@ class RootResource:
"</html"
)
resp.body = docs_html
resp.text = docs_html
class StatusResource:
@ -63,7 +63,7 @@ class OpenAPIJSONResource:
# Set the version in the schema so Swagger UI can display it
data["info"]["version"] = VERSION
resp.body = json.dumps(data)
resp.text = json.dumps(data)
class AllStatisticsResource:
@ -215,24 +215,24 @@ class SingleStatisticsResource:
resp.media = statistics
api = application = falcon.API()
api.add_route("/", RootResource())
api.add_route("/status", StatusResource())
app = application = falcon.App()
app.add_route("/", RootResource())
app.add_route("/status", StatusResource())
# Item routes
api.add_route("/items", AllStatisticsResource())
api.add_route("/item/{id_:uuid}", SingleStatisticsResource())
app.add_route("/items", AllStatisticsResource())
app.add_route("/item/{id_:uuid}", SingleStatisticsResource())
# Community routes
api.add_route("/communities", AllStatisticsResource())
api.add_route("/community/{id_:uuid}", SingleStatisticsResource())
app.add_route("/communities", AllStatisticsResource())
app.add_route("/community/{id_:uuid}", SingleStatisticsResource())
# Collection routes
api.add_route("/collections", AllStatisticsResource())
api.add_route("/collection/{id_:uuid}", SingleStatisticsResource())
app.add_route("/collections", AllStatisticsResource())
app.add_route("/collection/{id_:uuid}", SingleStatisticsResource())
# Route to the Swagger UI OpenAPI schema
api.add_route("/docs/openapi.json", OpenAPIJSONResource())
# Route to the Swagger UI Openapp schema
app.add_route("/docs/openapi.json", OpenAPIJSONResource())
# Path to host the Swagger UI. Keep in mind that Falcon will add a route for
# this automatically when we register Swagger and the path will be relative
@ -242,12 +242,12 @@ SWAGGERUI_PATH = "/swagger"
# The *absolute* path to the OpenJSON schema. This must be absolute because
# it will be requested by the client and must resolve absolutely. Note: the
# name of this variable is misleading because it is actually the schema URL
# but we pass it into the register_swaggerui_app() function as the api_url
# but we pass it into the register_swaggerui_app() function as the app_url
# parameter.
SWAGGERUI_API_URL = f"{DSPACE_STATISTICS_API_URL}/docs/openapi.json"
register_swaggerui_app(
api,
app,
SWAGGERUI_PATH,
SWAGGERUI_API_URL,
config={