Test

<back to all web services

TestUploadWithDto

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


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class Poco:
    name: Optional[str] = None


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass
class TestUploadWithDto(IPost):
    int_: int = field(metadata=config(field_name='int'), default=0)
    nullable_id: Optional[int] = None
    long: int = 0
    double: float = 0.0
    string: Optional[str] = None
    date_time: datetime.datetime = datetime.datetime(1, 1, 1)
    int_array: Optional[List[int]] = None
    int_list: Optional[List[int]] = None
    string_array: Optional[List[str]] = None
    string_list: Optional[List[str]] = None
    poco_array: Optional[List[Poco]] = None
    poco_list: Optional[List[Poco]] = None
    nullable_byte_array: Optional[List[Optional[int]]] = None
    nullable_byte_list: Optional[List[int]] = None
    nullable_date_time_array: Optional[List[Optional[datetime.datetime]]] = None
    nullable_date_time_list: Optional[List[datetime.datetime]] = None
    poco_lookup: Optional[Dict[str, List[Poco]]] = None
    poco_lookup_map: Optional[Dict[str, List[Dict[str, Poco]]]] = None
    map_list: Optional[Dict[str, List[str]]] = None

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

{
	int: 0,
	nullableId: 0,
	long: 0,
	double: 0,
	string: String,
	dateTime: 0001-01-01,
	intArray: 
	[
		0
	],
	intList: 
	[
		0
	],
	stringArray: 
	[
		String
	],
	stringList: 
	[
		String
	],
	pocoArray: 
	[
		{
			name: String
		}
	],
	pocoList: 
	[
		{
			name: String
		}
	],
	nullableByteArray: 
	[
		0
	],
	nullableByteList: 
	[
		0
	],
	nullableDateTimeArray: 
	[
		0001-01-01
	],
	nullableDateTimeList: 
	[
		0001-01-01
	],
	pocoLookup: 
	{
		String: 
		[
			{
				name: String
			}
		]
	},
	pocoLookupMap: 
	{
		String: 
		[
			{
				String: 
				{
					name: String
				}
			}
		]
	},
	mapList: 
	{
		String: 
		[
			String
		]
	}
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	int: 0,
	nullableId: 0,
	long: 0,
	double: 0,
	string: String,
	dateTime: 0001-01-01,
	intArray: 
	[
		0
	],
	intList: 
	[
		0
	],
	stringArray: 
	[
		String
	],
	stringList: 
	[
		String
	],
	pocoArray: 
	[
		{
			name: String
		}
	],
	pocoList: 
	[
		{
			name: String
		}
	],
	nullableByteArray: 
	[
		0
	],
	nullableByteList: 
	[
		0
	],
	nullableDateTimeArray: 
	[
		0001-01-01
	],
	nullableDateTimeList: 
	[
		0001-01-01
	],
	pocoLookup: 
	{
		String: 
		[
			{
				name: String
			}
		]
	},
	pocoLookupMap: 
	{
		String: 
		[
			{
				String: 
				{
					name: String
				}
			}
		]
	},
	mapList: 
	{
		String: 
		[
			String
		]
	}
}