2# +==== BEGIN CatFeeder =================+
5# ...............)..(.')
7# ...............\(__)|
8# Inspired by Joan Stark
9# source https://www.asciiart.eu/
13# FILE: docs_constants.py
14# CREATION DATE: 26-11-2025
15# LAST Modified: 14:46:12 19-12-2025
17# This is the backend server in charge of making the actual website work.
19# COPYRIGHT: (c) Cat Feeder
20# PURPOSE: The file containing the constants for the documentation handler.
22# +==== END CatFeeder =================+
26from display_tty
import Disp, initialise_logger
28from ..config
import EnvLoader, TOMLLoader
30IDISP: Disp = initialise_logger(
"docs_constants",
False)
40 """Enumeration of available documentation providers.
42 Each provider offers a different interface for viewing API documentation.
43 Multiple providers can be enabled simultaneously.
56OPENAPI_URL: str = TOML.get_toml_variable(
57 "Documentation",
"openapi_url",
"/openapi.json"
59OPENAPI_TITLE: str = TOML.get_toml_variable(
60 "Documentation",
"api_title",
"CatFeeder API"
62OPENAPI_VERSION: str = TOML.get_toml_variable(
63 "Documentation",
"api_version",
"1.0.0"
65OPENAPI_DESCRIPTION: str = TOML.get_toml_variable(
66 "Documentation",
"api_description",
67 "API documentation for the CatFeeder server"
71CONTACT_INFO: dict = TOML.get_toml_variable(
72 "Documentation.contact",
"info", {
73 "name":
"Asperguide Team",
74 "url":
"https://github.com/Asperguide",
75 "email":
"support@asperguide.com",
80LICENSE_INFO: dict = TOML.get_toml_variable(
81 "Documentation.license",
"info", {
82 "name":
"Proprietary",
83 "url":
"https://github.com/Asperguide/back-end/blob/prod/LICENSE",
88SERVERS: list = TOML.get_toml_variable(
89 "Documentation",
"servers", [
90 {
"url":
"http://localhost:5000",
"description":
"Development server"},
91 {
"url":
"https://api.asperguide.fr",
"description":
"Production server"},
96TAGS_METADATA: list = TOML.get_toml_variable(
97 "Documentation",
"tags_metadata", [
98 {
"name":
"Welcome",
"description":
"Welcome and health check endpoints"},
99 {
"name":
"Authentication",
100 "description":
"Authentication and authorization operations"},
101 {
"name":
"Users",
"description":
"User management operations"},
102 {
"name":
"Server",
"description":
"Server management and control operations"},
103 {
"name":
"Documentation",
"description":
"API documentation endpoints"},
109 ENABLE_REDOC: bool = ENV.get_environment_variable(
112except (ValueError, AttributeError):
113 ENABLE_REDOC: bool =
False
115 "ENABLE_REDOC not set, defaulting to False"
119 ENABLE_EDITOR: bool = ENV.get_environment_variable(
122except (ValueError, AttributeError):
123 ENABLE_EDITOR: bool =
False
125 "ENABLE_EDITOR not set, defaulting to False"
129 ENABLE_SCALAR: bool = ENV.get_environment_variable(
132except (ValueError, AttributeError):
133 ENABLE_SCALAR: bool =
False
135 "ENABLE_SCALAR not set, defaulting to False"
139 ENABLE_SWAGGER: bool = ENV.get_environment_variable(
142except (ValueError, AttributeError):
143 ENABLE_SWAGGER: bool =
True
145 "ENABLE_SWAGGER not set, defaulting to True"
149 ENABLE_RAPIDOC: bool = ENV.get_environment_variable(
152except (ValueError, AttributeError):
153 ENABLE_RAPIDOC: bool =
False
155 "ENABLE_RAPIDOC not set, defaulting to False"
159 ENABLE_RAPIPDF: bool = ENV.get_environment_variable(
162except (ValueError, AttributeError):
163 ENABLE_RAPIPDF: bool =
False
165 "ENABLE_RAPIPDF not set, defaulting to False"
169 ENABLE_EXPLORER: bool = ENV.get_environment_variable(
172except (ValueError, AttributeError):
173 ENABLE_EXPLORER: bool =
False
175 "ENABLE_EXPLORER not set, defaulting to False"
179 ENABLE_ELEMENTS: bool = ENV.get_environment_variable(
182except (ValueError, AttributeError):
183 ENABLE_ELEMENTS: bool =
False
185 "ENABLE_ELEMENTS not set, defaulting to False"
189_enabled_providers = []
191 _enabled_providers.append(DocumentationProvider.SWAGGER)
193 _enabled_providers.append(DocumentationProvider.REDOC)
195 _enabled_providers.append(DocumentationProvider.RAPIDOC)
197 _enabled_providers.append(DocumentationProvider.SCALAR)
199 _enabled_providers.append(DocumentationProvider.EDITOR)
201 _enabled_providers.append(DocumentationProvider.EXPLORER)
203 _enabled_providers.append(DocumentationProvider.RAPIPDF)
205 _enabled_providers.append(DocumentationProvider.ELEMENTS)
207DEFAULT_PROVIDERS: tuple[DocumentationProvider, ...] = tuple(
211RAPIDOC_CDN_VERSION: str = TOML.get_toml_variable(
212 "Documentation.cdn_versions",
"rapidoc",
"9.3.4"
214SCALAR_CDN_VERSION: str = TOML.get_toml_variable(
215 "Documentation.cdn_versions",
"scalar",
"1.24.0"
217ELEMENTS_CDN_VERSION: str = TOML.get_toml_variable(
218 "Documentation.cdn_versions",
"elements",
"8.4.7"
220EDITOR_CDN_VERSION: str = TOML.get_toml_variable(
221 "Documentation.cdn_versions",
"editor",
"5.0.0"
223EXPLORER_CDN_VERSION: str = TOML.get_toml_variable(
224 "Documentation.cdn_versions",
"explorer",
"0.0.58"
226RAPIPDF_CDN_VERSION: str = TOML.get_toml_variable(
227 "Documentation.cdn_versions",
"rapipdf",
"2.2.1"
231OAUTH2_REDIRECT_URL: str = TOML.get_toml_variable(
232 "Documentation",
"oauth2_redirect_url",
"/docs/oauth2-redirect"
234ENABLE_OAUTH2_DOCS: bool = TOML.get_toml_variable(
235 "Documentation",
"enable_oauth2",
False
239_DEFAULT_OAUTH2_SCOPES: dict[str, str] = {
240 "read":
"Read access to API resources",
241 "write":
"Write access to API resources",
242 "admin":
"Administrative access to API resources",
244OAUTH2_SCOPES: dict[str, str] = TOML.get_toml_variable(
245 "Documentation",
"oauth2_scopes", _DEFAULT_OAUTH2_SCOPES
250 OAUTH2_AUTHORIZATION_URL: str = ENV.get_environment_variable(
251 "DOCS_OAUTH2_AUTHORIZATION_URL"
254 OAUTH2_AUTHORIZATION_URL: str =
""
256 "DOCS_OAUTH2_AUTHORIZATION_URL not set in environment"
260 OAUTH2_TOKEN_URL: str = ENV.get_environment_variable(
261 "DOCS_OAUTH2_TOKEN_URL"
264 OAUTH2_TOKEN_URL: str =
""
266 "DOCS_OAUTH2_TOKEN_URL not set in environment"