Skip to content

Commit 3e0b90d

Browse files
Handle non-str param name property
1 parent 3efaf41 commit 3e0b90d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- Add support for handling `parameters` defined on `path items` (common
1515
parameters for all operation under a certain path).
1616
Refer to the [`Path Item` specification](https://swagger.io/specification/#path-item-object).
17+
- Fix bug happening when a parameter has a non-str `name` property.
1718

1819
## [1.1.0] - 2025-01-18
1920

openapidocs/mk/v3/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,11 @@ def _resolve_opt_ref(self, obj):
410410
return self.resolve_reference(obj)
411411
return obj
412412

413+
def _lower(self, obj):
414+
if isinstance(obj, str):
415+
return obj.lower()
416+
return str(obj)
417+
413418
def get_parameters(self, operation) -> List[dict]:
414419
"""
415420
Returns a list of objects describing the input parameters for a given operation.
@@ -424,7 +429,7 @@ def get_parameters(self, operation) -> List[dict]:
424429
param
425430
for param in sorted(
426431
parameters,
427-
key=lambda x: x["name"].lower() if (x and "name" in x) else "",
432+
key=lambda x: self._lower(x["name"]) if (x and "name" in x) else "",
428433
)
429434
if param
430435
]

0 commit comments

Comments
 (0)