openapi-generators / openapi-generators/openapi-python-client
Odd behaviour of snake_case functions
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 2k
- 分支
- 293
- 平均合併
- 34 分鐘
- 30 天內合併 PR
- 1
描述
Describe the bug
The names of apis are odd, having '_' in irregular and unpredictable places
To Reproduce
The following behavior can be observed using the snake_case function from utils:
utils.snake_case("get_v2_abc")
'get_v2_abc'
utils.snake_case("get_v2_abc_deFgHij")
'get_v_2_abc_de_fg_hij'
These would for example be created for paths: /v2/abc and /v2/abc/deFgHij
The results however inserts an additional underscore between v and 2, so v_2 instead of v2.
Expected behavior
results should be:
get_v2_abc_de_fg_hij
Desktop (please complete the following information):
- OS: CentOS7
- Python Version: 3.8
- openapi-python-client version: github-master from today
Suggestion:
snake_case uses split_words function , which only splits on Aa, so a capital letter followed by a lowercase one, not on underscore. split_words should first split on underscore, then split on capital followed by lowercase. This would solve the issue of mixed snake and camelcase names.
Some additional odd outcomes:
>>> utils.snake_case("MODEL4dd")
'model4_dd'
>>> utils.snake_case("MODEl4dd")
'mod_el_4_dd'
These of course violate camelCase, but in my estimate should all be treated as one word, i.e. multiple consecutive capital letters are treated as a single block. So above model4dd would be the outcome in both cases.
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先找出 Python 產生器中的 utils.snake_case 和 split_words 實作。重現 issue 中的範例,然後驗證混合使用 snake_case 和 camelCase 的輸入是否產生預期的單字,以及 MODEL4dd 情況是否仍維持為一個單字;如果有相關的 utility 測試,請新增或執行這些測試。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- tooling
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100