Test

<back to all web services

HelloWithEnumMap

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 HelloWithEnumMap:
    enum_prop: Optional[Dict[str, EnumType]] = None
    enum_with_values: Optional[Dict[str, EnumWithValues]] = None
    nullable_enum_prop: Optional[Dict[str, EnumType]] = None
    enum_flags: Optional[Dict[str, EnumFlags]] = None
    enum_style: Optional[Dict[str, EnumStyle]] = None

Python HelloWithEnumMap 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/HelloWithEnumMap HTTP/1.1 
Host: test.servicestack.net 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

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