Skip to content

Commit 70b27a4

Browse files
committed
fix(PRO-2634): add unknown default case for enums
this prevents the SDK from erroring when new values are being added.
1 parent 54d377b commit 70b27a4

391 files changed

Lines changed: 85 additions & 25360 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/check.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,11 @@ jobs:
113113
env:
114114
OPENAPI_VERSION: ${{ steps.version_check.outputs.openapi_version }}
115115
run: |
116-
# Move generated files to the correct locations and clean up
116+
# Move generated files to the correct locations and clean up.
117+
# Tests are intentionally not regenerated (apiTests/modelTests are disabled);
118+
# the manual tests under test/ are preserved across SDK updates.
117119
rm -Rf docs && mv python-client/docs .
118120
rm -Rf revengai && mv python-client/revengai .
119-
rm -Rf test && mv python-client/test .
120121
rm -Rf README.md && mv python-client/README.md .
121122
rm -Rf python-client
122123

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,6 @@ target/
6565
.ipynb_checkpoints
6666

6767
.idea
68-
.openapi-generator
68+
.openapi-generator
69+
# Templates
70+
out

config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
packageName: revengai
22
packageUrl: https://github.com/RevEngAI/sdk-python
3-
generateSourceCodeOnly: false
3+
generateSourceCodeOnly: false
4+
enumUnknownDefaultCase: true

templates/model_enum.mustache

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from __future__ import annotations
2+
import json
3+
from enum import Enum
4+
{{#vendorExtensions.x-py-other-imports}}
5+
{{{.}}}
6+
{{/vendorExtensions.x-py-other-imports}}
7+
from typing_extensions import Self
8+
9+
10+
class {{classname}}({{vendorExtensions.x-py-enum-type}}, Enum):
11+
"""
12+
{{{description}}}{{^description}}{{{classname}}}{{/description}}
13+
"""
14+
15+
"""
16+
allowed enum values
17+
"""
18+
{{#allowableValues}}
19+
{{#enumVars}}
20+
{{{name}}} = {{{value}}}
21+
{{/enumVars}}
22+
23+
@classmethod
24+
def from_json(cls, json_str: str) -> Self:
25+
"""Create an instance of {{classname}} from a JSON string"""
26+
return cls(json.loads(json_str))
27+
28+
@classmethod
29+
def _missing_(cls, value):
30+
"""Fall back to the unknown default for values not defined in the SDK."""
31+
return cls.__members__.get("UNKNOWN_DEFAULT_OPEN_API")
32+
33+
{{#defaultValue}}
34+
35+
#
36+
@classmethod
37+
def _missing_value_(cls, value):
38+
if value is no_arg:
39+
return cls.{{{.}}}
40+
{{/defaultValue}}
41+
{{/allowableValues}}

test/test_additional_details_status_response.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

test/test_addr.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

test/test_agent_api.py

Lines changed: 0 additions & 93 deletions
This file was deleted.

test/test_ai_decompilation_rating.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

test/test_ai_decompilation_task_status.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

test/test_ai_unstrip_request.py

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)