Test

<back to all web services

HelloWithEnumList

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'


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 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'


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class HelloWithEnumList:
    enum_prop: Optional[List[EnumType]] = None
    enum_with_values: Optional[List[EnumWithValues]] = None
    nullable_enum_prop: Optional[List[EnumType]] = None
    enum_flags: Optional[List[EnumFlags]] = None
    enum_style: Optional[List[EnumStyle]] = None

Python HelloWithEnumList DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /jsv/oneway/HelloWithEnumList HTTP/1.1 
Host: test.servicestack.net 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	enumProp: 
	[
		Value1
	],
	enumWithValues: 
	[
		None
	],
	nullableEnumProp: 
	[
		Value1
	],
	enumFlags: 
	[
		0
	],
	enumStyle: 
	[
		lower
	]
}