namespace MyApp.ServiceModel
open System
open System.IO
open System.Collections
open System.Collections.Generic
open System.Runtime.Serialization
open ServiceStack
open ServiceStack.DataAnnotations
[<AllowNullLiteral>]
type SubType() =
member val Id:Int32 = new Int32() with get,set
member val Name:String = null with get,set
[<AllowNullLiteral>]
type AllTypes() =
interface IGet
member val Id:Int32 = new Int32() with get,set
member val NullableId:Nullable<Int32> = new Nullable<Int32>() with get,set
member val Byte:Byte = new Byte() with get,set
member val Short:Int16 = new Int16() with get,set
member val Int:Int32 = new Int32() with get,set
member val Long:Int64 = new Int64() with get,set
member val UShort:UInt16 = new UInt16() with get,set
member val UInt:UInt32 = new UInt32() with get,set
member val ULong:UInt64 = new UInt64() with get,set
member val Float:Single = new Single() with get,set
member val Double:Double = new Double() with get,set
member val Decimal:Decimal = new Decimal() with get,set
member val String:String = null with get,set
member val DateTime:DateTime = new DateTime() with get,set
member val TimeSpan:TimeSpan = new TimeSpan() with get,set
member val DateTimeOffset:DateTimeOffset = new DateTimeOffset() with get,set
member val Guid:Guid = new Guid() with get,set
member val Char:Char = new Char() with get,set
member val KeyValuePair:KeyValuePair<String, String> = new KeyValuePair<String, String>() with get,set
member val NullableDateTime:Nullable<DateTime> = new Nullable<DateTime>() with get,set
member val NullableTimeSpan:Nullable<TimeSpan> = new Nullable<TimeSpan>() with get,set
member val StringList:ResizeArray<String> = null with get,set
member val StringArray:String[] = null with get,set
member val StringMap:Dictionary<String, String> = null with get,set
member val IntStringMap:Dictionary<Int32, String> = null with get,set
member val SubType:SubType = null with get,set
member val Point:String = null with get,set
[<DataMember(Name="aliasedName")>]
member val OriginalName:String = null with get,set
[<AllowNullLiteral>]
type Poco() =
member val Name:String = null with get,set
[<AllowNullLiteral>]
type AllCollectionTypes() =
member val IntArray:Int32[] = null with get,set
member val IntList:ResizeArray<Int32> = null with get,set
member val StringArray:String[] = null with get,set
member val StringList:ResizeArray<String> = null with get,set
member val PocoArray:Poco[] = null with get,set
member val PocoList:ResizeArray<Poco> = null with get,set
member val NullableByteArray:Nullable<Byte> = null with get,set
member val NullableByteList:ResizeArray<Nullable<Byte>> = null with get,set
member val NullableDateTimeArray:Nullable<DateTime> = null with get,set
member val NullableDateTimeList:ResizeArray<Nullable<DateTime>> = null with get,set
member val PocoLookup:Dictionary<String, List<Poco>> = null with get,set
member val PocoLookupMap:Dictionary<String, List<Dictionary<String,Poco>>> = null with get,set
[<AllowNullLiteral>]
type HelloAllTypesResponse() =
member val Result:String = null with get,set
member val AllTypes:AllTypes = null with get,set
member val AllCollectionTypes:AllCollectionTypes = null with get,set
[<AllowNullLiteral>]
type HelloAllTypes() =
member val Name:String = null with get,set
member val AllTypes:AllTypes = null with get,set
member val AllCollectionTypes:AllCollectionTypes = null with get,set
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /csv/reply/HelloAllTypes HTTP/1.1
Host: blazor-gallery.servicestack.net
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"name":"String","allTypes":{"id":0,"nullableId":0,"byte":0,"short":0,"int":0,"long":0,"uShort":0,"uInt":0,"uLong":0,"float":0,"double":0,"decimal":0,"string":"String","dateTime":"0001-01-01T00:00:00","timeSpan":"PT0S","dateTimeOffset":"0001-01-01T00:00:00+00:00","guid":"00000000-0000-0000-0000-000000000000","char":"\u0000","keyValuePair":{"key":"String","value":"String"},"nullableDateTime":"0001-01-01T00:00:00","nullableTimeSpan":"PT0S","stringList":["String"],"stringArray":["String"],"stringMap":{"String":"String"},"intStringMap":{"0":"String"},"subType":{"id":0,"name":"String"},"point":"0,0","aliasedName":"String"},"allCollectionTypes":{"intArray":[0],"intList":[0],"stringArray":["String"],"stringList":["String"],"pocoArray":[{"name":"String"}],"pocoList":[{"name":"String"}],"nullableByteArray":[0],"nullableByteList":[0],"nullableDateTimeArray":["0001-01-01T00:00:00"],"nullableDateTimeList":["0001-01-01T00:00:00"],"pocoLookup":{"String":[{"name":"String"}]},"pocoLookupMap":{"String":[{"String":{"name":"String"}}]}}}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"result":"String","allTypes":{"id":0,"nullableId":0,"byte":0,"short":0,"int":0,"long":0,"uShort":0,"uInt":0,"uLong":0,"float":0,"double":0,"decimal":0,"string":"String","dateTime":"0001-01-01T00:00:00","timeSpan":"PT0S","dateTimeOffset":"0001-01-01T00:00:00+00:00","guid":"00000000-0000-0000-0000-000000000000","char":"\u0000","keyValuePair":{"key":"String","value":"String"},"nullableDateTime":"0001-01-01T00:00:00","nullableTimeSpan":"PT0S","stringList":["String"],"stringArray":["String"],"stringMap":{"String":"String"},"intStringMap":{"0":"String"},"subType":{"id":0,"name":"String"},"point":"0,0","aliasedName":"String"},"allCollectionTypes":{"intArray":[0],"intList":[0],"stringArray":["String"],"stringList":["String"],"pocoArray":[{"name":"String"}],"pocoList":[{"name":"String"}],"nullableByteArray":[0],"nullableByteList":[0],"nullableDateTimeArray":["0001-01-01T00:00:00"],"nullableDateTimeList":["0001-01-01T00:00:00"],"pocoLookup":{"String":[{"name":"String"}]},"pocoLookupMap":{"String":[{"String":{"name":"String"}}]}}}