Skip to content

Commit

Permalink
Fix ap_is -> apis (#2536)
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-edmonds-dd committed Jun 20, 2024
1 parent 535a952 commit edafccc
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .generator/src/generator/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import dateutil.parser

from .utils import snake_case, camel_case, untitle_case, schema_name
from .utils import safe_snake_case, snake_case, camel_case, untitle_case, schema_name

PRIMITIVE_TYPES = ["string", "number", "boolean", "integer"]

Expand Down Expand Up @@ -81,7 +81,7 @@ def block_comment(comment, prefix="#", first_line=True):


def model_filename(name):
filename = snake_case(name)
filename = safe_snake_case(name)
last = filename.split("_")[-1]
if last in SUFFIXES:
filename += "_"
Expand Down
8 changes: 8 additions & 0 deletions .generator/src/generator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
PATTERN_LEADING_ALPHA = re.compile(r"(.)([A-Z][a-z]+)")
PATTERN_FOLLOWING_ALPHA = re.compile(r"([a-z0-9])([A-Z])")
PATTERN_WHITESPACE = re.compile(r"\W")
# Other client generators have more edge cases defined but adding them here could cause backwards-incompatible breaking changes.
EDGE_CASES = {"APIs": "Apis"}


def snake_case(value):
Expand All @@ -16,6 +18,12 @@ def snake_case(value):
return PATTERN_DOUBLE_UNDERSCORE.sub("_", s1)


def safe_snake_case(value):
for token, replacement in EDGE_CASES.items():
value = value.replace(token, replacement)
return snake_case(value)


def upperfirst(value):
return value[0].upper() + value[1:]

Expand Down
File renamed without changes.

0 comments on commit edafccc

Please sign in to comment.