Skip to content

Commit

Permalink
include static ClassVar for discriminator property in both python cli…
Browse files Browse the repository at this point in the history
…ent and python server codegens
  • Loading branch information
wkarwacki committed Oct 8, 2024
1 parent 0e81f90 commit 99ac9c9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/lib/gen/python/client/templates/dto.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
{{#each val.adt.map}}
{{>dto key=(fmtClass @key) val=this adtParent=../key adtVar=../val.adt.var}}

{{fmtName ../val.adt.var}}: Literal[{{json @key}}] = {{json @key}}
{{fmtName ../val.adt.var}}_val: ClassVar[str] = {{json @key}}
{{fmtName ../val.adt.var}}: Literal[{{json @key}}] = {{fmtName ../val.adt.var}}_val


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

from enum import Enum
from pydantic import Field, model_validator
from typing import Annotated, Any, Literal
from typing import Annotated, Any, ClassVar, Literal

from trust import Dto

Expand Down
3 changes: 2 additions & 1 deletion src/lib/gen/python/server/templates/dto.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
{{#each val.adt.map}}
{{>dto key=(fmtClass @key) val=this adtParent=../key adtVar=../val.adt.var}}

{{fmtName ../val.adt.var}}: Literal[{{json @key}}] = {{json @key}}
{{fmtName ../val.adt.var}}_val: ClassVar[str] = {{json @key}}
{{fmtName ../val.adt.var}}: Literal[{{json @key}}] = {{fmtName ../val.adt.var}}_val


{{/each}}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/gen/python/server/templates/dtoFile.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import json
from enum import Enum
from fastapi import File, Form, UploadFile
from pydantic import Field
from typing import Annotated, Any, Literal
from typing import Annotated, Any, ClassVar, Literal

from trust import Dto

Expand Down

0 comments on commit 99ac9c9

Please sign in to comment.