import 'package:servicestack/servicestack.dart';
import 'dart:typed_data';
import 'dart:collection';
abstract class IPoco
{
String? name;
}
abstract class IEmptyInterface
{
}
class EmptyClass implements IConvertible
{
EmptyClass();
EmptyClass.fromJson(Map<String, dynamic> json) : super();
fromMap(Map<String, dynamic> json) {
return this;
}
Map<String, dynamic> toJson() => {};
getTypeName() => "EmptyClass";
TypeContext? context = _ctx;
}
class HelloInterface implements IConvertible
{
IPoco? poco;
IEmptyInterface? emptyInterface;
EmptyClass? emptyClass;
HelloInterface({this.poco,this.emptyInterface,this.emptyClass});
HelloInterface.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
poco = JsonConverters.fromJson(json['poco'],'IPoco',context!);
emptyInterface = JsonConverters.fromJson(json['emptyInterface'],'IEmptyInterface',context!);
emptyClass = JsonConverters.fromJson(json['emptyClass'],'EmptyClass',context!);
return this;
}
Map<String, dynamic> toJson() => {
'poco': JsonConverters.toJson(poco,'IPoco',context!),
'emptyInterface': JsonConverters.toJson(emptyInterface,'IEmptyInterface',context!),
'emptyClass': JsonConverters.toJson(emptyClass,'EmptyClass',context!)
};
getTypeName() => "HelloInterface";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'test.servicestack.net', types: <String, TypeInfo> {
'IPoco': TypeInfo(TypeOf.Interface),
'IEmptyInterface': TypeInfo(TypeOf.Interface),
'EmptyClass': TypeInfo(TypeOf.Class, create:() => EmptyClass()),
'HelloInterface': TypeInfo(TypeOf.Class, create:() => HelloInterface()),
});
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/oneway/HelloInterface HTTP/1.1
Host: test.servicestack.net
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"emptyClass":{}}