Skip to content
Snippets Groups Projects
Commit 4ecb05ca7932 authored by Frank Bessou's avatar Frank Bessou :spider_web:
Browse files

feat: remove 'api-server-name' configuration

The base url is already here for this.
parent 0e97ee793c1e
No related branches found
No related tags found
2 merge requests!34feat: remove 'api-server-name' configuration,!30chore: avoid request pre-released version of black
...@@ -27,15 +27,4 @@ ...@@ -27,15 +27,4 @@
"level": 2, "level": 2,
}, },
), ),
(
"api-server-name",
{
"type": "string",
"default": None,
"help": "The base url to use for openapi validation. "
"Set this to the CubicWeb base url if openapi cannot find the server.",
"group": "api",
"level": 2,
},
),
) )
...@@ -65,23 +65,8 @@ ...@@ -65,23 +65,8 @@
:return: The configured server name or the CubicWeb base url :return: The configured server name or the CubicWeb base url
:raise ConfigurationError if the name set in config is not valid :raise ConfigurationError if the name set in config is not valid
""" """
repo = get_cw_repo(config) cwconfig = get_cw_all_in_one_config(config)
with repo.internal_cnx() as cnx: return cwconfig.option_value('base-url')
server_name: str = repo.get_option_value("api-server-name") or cnx.base_url()
match = re.match("^[a-zA-Z0-9-_@.&+!*(),/:]{1,60}$", server_name)
if match:
return server_name
else:
if len(server_name) > 60:
raise ConfigurationError(
f"api-server-name '{server_name}' is too long. "
"Max size allowed is 60 characters. "
f"Current size is {len(server_name)}."
)
raise ConfigurationError(
f"api-server-name '{server_name}' contains invalid characters. "
"Allowed characters are: a-zA-Z0-9-_@.&+!*(),/:"
)
def get_api_path_prefix(config: Configurator) -> str: def get_api_path_prefix(config: Configurator) -> str:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment