[wiz-cli] duplicate dataclass schemas should be replaced with just one #59
Labels
bug
Something isn't working
good first issue
Good for newcomers
help wanted
Extra attention is needed
self-created
Opened by me!
Description
In certain cases - and especially in certain API responses, most notably for AWS Rekognition - the input JSON object can contain multiple definitions for the same field - for ex.
"element"
, all of which contain an identical schema.I'd like to eliminate those duplicate dataclass definitions in the output, so that the generated schema is a bit less verbose and we only have the data we care about.
For example, note the below sample input and output.
What I Did
I ran the following command from my mac terminal:
The generated output is a bit noisy in this scenario, as it contains duplicate definitions of the dataclass
Element
:I'd like to eliminate all the duplicate definitions - preferably trim any duplicates after the first dataclass schema for
Element
.Resolution
There are multiple ways to achieve this, but I think the easiest might be to store the generated string or
__repr__
for the schema in a dict with the class name as the key, and then lookup and compare if those string defintions are the same. If so, we just continue and return an empty__repr__
after the first time. If not, we generate all the field names and types for the dataclass as normal.The text was updated successfully, but these errors were encountered: