Skip to content

Normalize Special Characters #1285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/normalize_special_characters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
default: patch
---

# Normalize Special Characters

#1285 by @MatteoGisondi

Fixes #1284
6 changes: 4 additions & 2 deletions openapi_python_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from keyword import iskeyword
from typing import Any

from unidecode import unidecode

from .config import Config

DELIMITERS = r"\. _-"
Expand Down Expand Up @@ -44,8 +46,8 @@ def __deepcopy__(self, _: Any) -> ClassName:


def sanitize(value: str) -> str:
"""Removes every character that isn't 0-9, A-Z, a-z, or a known delimiter"""
return re.sub(rf"[^\w{DELIMITERS}]+", "", value)
"""Removes every character that isn't 0-9, A-Z, a-z, or a known delimiter and normalizes it to convert special characters"""
return unidecode(re.sub(rf"[^\w{DELIMITERS}]+", "", value))


def split_words(value: str) -> list[str]:
Expand Down
13 changes: 12 additions & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ dependencies = [
"ruamel.yaml>=0.18.6,<0.19.0",
"ruff>=0.2,<0.13",
"typing-extensions>=4.8.0,<5.0.0",
"unidecode>=1.4.0",
]
name = "openapi-python-client"
version = "0.25.2"
Expand Down
Loading