bedrock.generators.code_generators.common.helpers

 1from bedrock._helpers.string import kebab_case_to_camelCase, as_singular
 2
 3
 4def get_model_class_name_from_endpoint(endpoint_path: str, model_name: str or None = None) -> str:
 5    if model_name:
 6        return model_name
 7    return as_singular(kebab_case_to_camelCase(get_endpoint_name(endpoint_path), True))
 8
 9
10def get_endpoint_name(endpoint_path: str) -> str:
11    return endpoint_path.split("/")[-1]
12
13
14def get_endpoint_prefixes(endpoint_path: str) -> list[str]:
15    return endpoint_path.split("/")[1:-1]
def get_model_class_name_from_endpoint(endpoint_path: str, model_name: str = None) -> str:
5def get_model_class_name_from_endpoint(endpoint_path: str, model_name: str or None = None) -> str:
6    if model_name:
7        return model_name
8    return as_singular(kebab_case_to_camelCase(get_endpoint_name(endpoint_path), True))
def get_endpoint_name(endpoint_path: str) -> str:
11def get_endpoint_name(endpoint_path: str) -> str:
12    return endpoint_path.split("/")[-1]
def get_endpoint_prefixes(endpoint_path: str) -> list[str]:
15def get_endpoint_prefixes(endpoint_path: str) -> list[str]:
16    return endpoint_path.split("/")[1:-1]