Skip to content

Commit ec9e485

Browse files
committed
Properly handle spaces in Enum keys. Fixes #198
1 parent 8af5023 commit ec9e485

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

CHANGELOG.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.6.1 - 2020-09-26
9+
10+
### Changes
11+
12+
- Use httpx ^0.15.0 in generated clients
13+
14+
### Fixes
15+
16+
- Properly remove spaces from generated Enum keys (#198). Thanks @bowenwr!
17+
818
## 0.6.0 - 2020-09-21
919

1020
### Breaking Changes
@@ -30,22 +40,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3040
- It's now possible to include custom headers and cookies in requests, as well as set a custom timeout. This can be done
3141
either by directly setting those parameters on a `Client` (e.g. `my_client.headers = {"Header": "Value"}`) or using
3242
a fluid api (e.g. `my_endpoint.sync(my_client.with_cookies({"MyCookie": "cookie"}).with_timeout(10.0))`).
33-
- Unsupported content types or no responses at all will no longer result in an endpoint being completely skipped. Instead,
43+
- Unsupported content types or no responses at all will no longer result in an endpoint being completely skipped. Instead,
3444
only the `detailed` versions of the endpoint will be generated, where the resulting `Response.parsed` is always `None`.
3545
(#141)
3646
- Support for Python 3.6 (#137 & #154)
3747
- Support for enums with integer values
38-
48+
3949
### Changes
4050

4151
- The format of any errors/warnings has been spaced out a bit.
4252

4353
## 0.5.5 - 2020-09-04
54+
4455
### Fixes
56+
4557
- Improved trailing comma handling in endpoint generation (#178 & #179). Thanks @dtkav!
4658
- `Optional` is now properly imported for `nullable` fields (#177 & #180). Thanks @dtkav!
4759

48-
4960
## 0.5.4 - 2020-08-29
5061

5162
### Additions

openapi_python_client/parser/properties.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,8 @@ def values_from_list(values: List[ValueType]) -> Dict[str, ValueType]:
363363
key = f"VALUE_{i}"
364364
if key in output:
365365
raise ValueError(f"Duplicate key {key} in Enum")
366-
sanitized_key = utils.fix_keywords(utils.sanitize(key))
366+
sanitized_key = utils.snake_case(key).upper()
367367
output[sanitized_key] = utils.remove_string_escapes(value)
368-
369368
return output
370369

371370
def _validate_default(self, default: Any) -> str:

tests/test_openapi_parser/test_properties.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ def test_get_imports(self, mocker):
430430
def test_values_from_list(self):
431431
from openapi_python_client.parser.properties import EnumProperty
432432

433-
data = ["abc", "123", "a23", "1bc", 4, -3]
433+
data = ["abc", "123", "a23", "1bc", 4, -3, "a Thing WIth spaces"]
434434

435435
result = EnumProperty.values_from_list(data)
436436

@@ -441,6 +441,7 @@ def test_values_from_list(self):
441441
"VALUE_3": "1bc",
442442
"VALUE_4": 4,
443443
"VALUE_NEGATIVE_3": -3,
444+
"A_THING_WITH_SPACES": "a Thing WIth spaces",
444445
}
445446

446447
def test_values_from_list_duplicate(self):

0 commit comments

Comments
 (0)