Skip to content

Commit

Permalink
Fix: Replace slash from generated operationId (#264)
Browse files Browse the repository at this point in the history
Fix: Replace '/' with _ in operationId

Fixes #263

Signed-off-by: Harish Karumuthil <[email protected]>

Signed-off-by: Harish Karumuthil <[email protected]>
(cherry picked from commit b96a490)
  • Loading branch information
harish2704 authored and kemingy committed Oct 15, 2022
1 parent 8280050 commit 86fd888
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion spectree/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def _generate_spec(self) -> Dict[str, Any]:

routes[path][method.lower()] = {
"summary": summary or f"{name} <{method}>",
"operationId": f"{method.lower()}_{path}",
"operationId": f"{method.lower()}_{path.replace('/', '_')}",
"description": desc or "",
"tags": [str(x) for x in getattr(func, "tags", ())],
"parameters": parse_params(func, parameters[:], self.models),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_plugin_spec(api):
assert ping["parameters"][0]["in"] == "header"
assert ping["summary"] == "summary"
assert ping["description"] == "description"
assert ping["operationId"] == "get_/ping"
assert ping["operationId"] == "get__ping"

user = api.spec["paths"]["/api/user/{name}"]["post"]
assert user["tags"] == ["API", "test"]
Expand Down

0 comments on commit 86fd888

Please sign in to comment.