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 .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /jsv/reply/HelloWithInheritance HTTP/1.1
Host: test.servicestack.net
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
name: String,
id: 0
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { result: String, refId: 0 }