1
0
mirror of https://github.com/ilri/dspace-statistics-api.git synced 2024-11-22 06:15:02 +01:00

Allow configuration of Swagger and OpenAPI JSON URL
All checks were successful
continuous-integration/drone/push Build is passing

When running in production your statistics API might be deployed to
a path like /rest/statistics instead of at the root.
This commit is contained in:
Alan Orth 2020-12-22 12:50:03 +02:00
parent 893039bc6a
commit 70b2ba83ba
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 11 additions and 4 deletions

View File

@ -6,6 +6,8 @@ from .database import DatabaseManager
from .stats import get_downloads, get_views from .stats import get_downloads, get_views
from .util import set_statistics_scope, validate_post_parameters from .util import set_statistics_scope, validate_post_parameters
from .config import VERSION from .config import VERSION
from .config import SWAGGERUI_URL
from .config import SWAGGERUI_SCHEMA_URL
class RootResource: class RootResource:
@ -198,14 +200,12 @@ api.add_route("/collections", AllStatisticsResource())
api.add_route("/collection/{id_:uuid}", SingleStatisticsResource()) api.add_route("/collection/{id_:uuid}", SingleStatisticsResource())
# Swagger configuration # Swagger configuration
SWAGGERUI_URL = "/swagger" # without trailing slash api.add_route(SWAGGERUI_SCHEMA_URL, OpenAPIJSONResource())
SCHEMA_URL = "/docs/openapi.json"
api.add_route("/docs/openapi.json", OpenAPIJSONResource())
register_swaggerui_app( register_swaggerui_app(
api, api,
SWAGGERUI_URL, SWAGGERUI_URL,
SCHEMA_URL, SWAGGERUI_SCHEMA_URL,
config={ config={
"supportedSubmitMethods": ["get", "post"], "supportedSubmitMethods": ["get", "post"],
}, },

View File

@ -9,6 +9,13 @@ DATABASE_PASS = os.environ.get("DATABASE_PASS", "dspacestatistics")
DATABASE_HOST = os.environ.get("DATABASE_HOST", "localhost") DATABASE_HOST = os.environ.get("DATABASE_HOST", "localhost")
DATABASE_PORT = os.environ.get("DATABASE_PORT", "5432") DATABASE_PORT = os.environ.get("DATABASE_PORT", "5432")
# SwaggerUI configuration
# URI path where the Swagger UI should be available (without trailing slash)
SWAGGERUI_URL = os.environ.get("SWAGGERUI_URL", "/swagger")
# URI path to the OpenAPI JSON schema
SWAGGERUI_SCHEMA_URL = os.environ.get("SWAGGERUI_SCHEMA_URL", "/docs/openapi.json")
VERSION = "1.4.0-dev" VERSION = "1.4.0-dev"
# vim: set sw=4 ts=4 expandtab: # vim: set sw=4 ts=4 expandtab: