Skip to content

Commit

Permalink
enabled inline enum generation for python client/server
Browse files Browse the repository at this point in the history
  • Loading branch information
wkarwacki committed Jul 31, 2024
1 parent f7350f2 commit a38574c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/gen/python/client/templates/dto.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{/each}}

{{key}} = {{>union}} {{else if (and (isAlias val) tl)}}{{key}} = {{fmtType val key}}{{else if (or val.vars adtParent)}}class {{adtParent}}{{fmtClass key}}({{#if (parents val)}}{{#each (parents val)}}{{fmtType this}}{{#unless @last}}, {{/unless}}{{/each}}{{else if adtParent}}{{adtParent}}Base{{else}}Dto{{/if}}){{>typeParams val=val}}:
{{indent}}{{#unless val.vars}} pass{{/unless}}{{#each val.vars}}{{#if (or (eq this.type "obj") this.item this.val)}} {{>dto key=(fmtClass @key) val=this dtoFormLike=(or ../formLike ../dtoFormLike) indent=(add ../indent " ")}}{{/if}}{{/each}}{{#each val.vars}}{{#if (or (not ../this.formLike) (not (eq @key "file")))}}
{{indent}}{{#unless val.vars}} pass{{/unless}}{{#each val.vars}}{{#if (or (or (eq this.type "obj") (eq this.type "enum")) this.item this.val)}} {{>dto key=(fmtClass @key) val=this dtoFormLike=(or ../formLike ../dtoFormLike) indent=(add ../indent " ")}}{{/if}}{{/each}}{{#each val.vars}}{{#if (or (not ../this.formLike) (not (eq @key "file")))}}
{{../indent}}{{>var}}{{/if}}{{/each}}{{else if (eq val.type "enum")}}class {{key}}({{#with (valueDef val.vars.[0])}}{{#if (eq type "int")}}IntEnum{{else}}str, Enum{{/if}}{{/with}}):{{#each val.vals}}
{{fmtEnum this}} = {{json this}}{{/each}}{{/if}}{{#if (and (and (hasKey this "tl") (not tl)) (and dtoFormLike (eq val.type "obj")))}}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/gen/python/server/templates/dto.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{{/each}}

{{key}} = {{>union}} {{else if (and (isAlias val) tl)}}{{key}} = {{fmtType val key}}{{else if (or val.vars adtParent)}}class {{adtParent}}{{fmtClass key}}({{#each (parents val)}}{{fmtType this}}{{#unless @last}}, {{/unless}}{{/each}}{{#if adtParent}}{{#if (parents val)}}, {{/if}}{{adtParent}}Base{{/if}}{{#unless (or (parents val) adtParent)}}Dto{{/unless}}){{>typeParams val=val}}:
{{indent}}{{#unless val.vars}} pass{{/unless}}{{#each val.vars}}{{#if (or (eq this.type "obj") this.item this.val)}} {{>dto key=(fmtClass @key) val=this indent=(add ../indent " ")}}{{/if}}{{/each}}{{#each val.vars}}
{{indent}}{{#unless val.vars}} pass{{/unless}}{{#each val.vars}}{{#if (or (or (eq this.type "obj") (eq this.type "enum")) this.item this.val)}} {{>dto key=(fmtClass @key) val=this indent=(add ../indent " ")}}{{/if}}{{/each}}{{#each val.vars}}
{{../indent}}{{>var}}{{/each}}{{else if (eq val.type "enum")}}class {{key}}({{#with (valueDef val.vars.[0])}}{{#if (eq type "int")}}IntEnum{{else}}str, Enum{{/if}}{{/with}}):{{#each val.vals}}
{{fmtEnum this}} = {{json this}}{{/each}}{{/if}}
{{#if formLike}} @classmethod
Expand Down

0 comments on commit a38574c

Please sign in to comment.