import 'package:servicestack/servicestack.dart';
import 'dart:typed_data';
import 'dart:collection';
abstract class HelloBase
{
int? id;
HelloBase({this.id});
HelloBase.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
return this;
}
Map<String, dynamic> toJson() => {
'id': id
};
getTypeName() => "HelloBase";
TypeContext? context = _ctx;
}
class HelloWithInheritance extends HelloBase implements IConvertible
{
String? name;
HelloWithInheritance({this.name});
HelloWithInheritance.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
name = json['name'];
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'name': name
});
getTypeName() => "HelloWithInheritance";
TypeContext? context = _ctx;
}
abstract class HelloResponseBase
{
int? refId;
HelloResponseBase({this.refId});
HelloResponseBase.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
refId = json['refId'];
return this;
}
Map<String, dynamic> toJson() => {
'refId': refId
};
getTypeName() => "HelloResponseBase";
TypeContext? context = _ctx;
}
class HelloWithInheritanceResponse extends HelloResponseBase implements IConvertible
{
String? result;
HelloWithInheritanceResponse({this.result});
HelloWithInheritanceResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
result = json['result'];
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'result': result
});
getTypeName() => "HelloWithInheritanceResponse";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'test.servicestack.net', types: <String, TypeInfo> {
'HelloBase': TypeInfo(TypeOf.AbstractClass),
'HelloWithInheritance': TypeInfo(TypeOf.Class, create:() => HelloWithInheritance()),
'HelloResponseBase': TypeInfo(TypeOf.AbstractClass),
'HelloWithInheritanceResponse': TypeInfo(TypeOf.Class, create:() => HelloWithInheritanceResponse()),
});
Dart HelloWithInheritance DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /xml/reply/HelloWithInheritance HTTP/1.1
Host: test.servicestack.net
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<HelloWithInheritance xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Test.ServiceModel">
<Id xmlns="http://schemas.datacontract.org/2004/07/Test.ServiceModel.Types">0</Id>
<Name>String</Name>
</HelloWithInheritance>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <HelloWithInheritanceResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Test.ServiceModel"> <RefId xmlns="http://schemas.datacontract.org/2004/07/Test.ServiceModel.Types">0</RefId> <Result>String</Result> </HelloWithInheritanceResponse>