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 .xml suffix or ?format=xml

HTTP + XML

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

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

<HelloWithEnumList xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Test.ServiceModel">
  <EnumFlags>
    <EnumFlags>Value0</EnumFlags>
  </EnumFlags>
  <EnumProp>
    <EnumType>Value1</EnumType>
  </EnumProp>
  <EnumStyle>
    <EnumStyle>lower</EnumStyle>
  </EnumStyle>
  <EnumWithValues>
    <EnumWithValues>None</EnumWithValues>
  </EnumWithValues>
  <NullableEnumProp xmlns:d2p1="http://schemas.datacontract.org/2004/07/System">
    <d2p1:EnumType>Value1</d2p1:EnumType>
  </NullableEnumProp>
</HelloWithEnumList>