import datetime
import decimal
from marshmallow.fields import *
from servicestack import *
from typing import *
from dataclasses import dataclass, field
from dataclasses_json import dataclass_json, LetterCase, Undefined, config
from enum import Enum, IntEnum
class EnumType(str, Enum):
VALUE1 = 'Value1'
VALUE2 = 'Value2'
VALUE3 = 'Value3'
# @Flags()
class EnumTypeFlags(IntEnum):
VALUE1 = 0
VALUE2 = 1
VALUE3 = 2
class EnumWithValues(str, Enum):
NONE = 'None'
VALUE1 = 'Member 1'
VALUE2 = 'Value2'
# @Flags()
class EnumFlags(IntEnum):
VALUE0 = 0
VALUE1 = 1
VALUE2 = 2
VALUE3 = 4
VALUE123 = 7
class EnumAsInt(IntEnum):
VALUE1 = 1000
VALUE2 = 2000
VALUE3 = 3000
class EnumStyle(str, Enum):
LOWER = 'lower'
UPPER = 'UPPER'
PASCAL_CASE = 'PascalCase'
CAMEL_CASE = 'camelCase'
CAMEL_U_P_P_E_R = 'camelUPPER'
PASCAL_U_P_P_E_R = 'PascalUPPER'
class EnumStyleMembers(str, Enum):
LOWER = 'lower'
UPPER = 'UPPER'
PASCAL_CASE = 'PascalCase'
CAMEL_CASE = 'camelCase'
CAMEL_UPPER = 'camelUPPER'
PASCAL_UPPER = 'PascalUPPER'
@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class HelloWithEnum:
enum_prop: Optional[EnumType] = None
enum_type_flags: Optional[EnumTypeFlags] = None
enum_with_values: Optional[EnumWithValues] = None
nullable_enum_prop: Optional[EnumType] = None
enum_flags: Optional[EnumFlags] = None
enum_as_int: Optional[EnumAsInt] = None
enum_style: Optional[EnumStyle] = None
enum_style_members: Optional[EnumStyleMembers] = None
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /jsonl/oneway/HelloWithEnum HTTP/1.1
Host: test.servicestack.net
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"enumProp":"Value1","enumTypeFlags":0,"enumWithValues":"None","nullableEnumProp":"Value1","enumFlags":0,"enumAsInt":"Value1","enumStyle":"lower","enumStyleMembers":"lower"}