GET | /todos |
---|
import 'package:servicestack/servicestack.dart';
// @DataContract
class Todo implements IConvertible
{
// @DataMember(Order=1)
int? id;
// @DataMember(Order=2)
String? title;
// @DataMember(Order=3)
int? order;
// @DataMember(Order=4)
bool? completed;
Todo({this.id,this.title,this.order,this.completed});
Todo.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
title = json['title'];
order = json['order'];
completed = json['completed'];
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'title': title,
'order': order,
'completed': completed
};
getTypeName() => "Todo";
TypeContext? context = _ctx;
}
// @DataContract
class GetTodosResponse implements IConvertible
{
// @DataMember(Order=1)
List<Todo>? results;
// @DataMember(Order=2)
ResponseStatus? responseStatus;
GetTodosResponse({this.results,this.responseStatus});
GetTodosResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
results = JsonConverters.fromJson(json['results'],'List<Todo>',context!);
responseStatus = JsonConverters.fromJson(json['responseStatus'],'ResponseStatus',context!);
return this;
}
Map<String, dynamic> toJson() => {
'results': JsonConverters.toJson(results,'List<Todo>',context!),
'responseStatus': JsonConverters.toJson(responseStatus,'ResponseStatus',context!)
};
getTypeName() => "GetTodosResponse";
TypeContext? context = _ctx;
}
// @DataContract
class GetTodos implements IConvertible
{
GetTodos();
GetTodos.fromJson(Map<String, dynamic> json) : super();
fromMap(Map<String, dynamic> json) {
return this;
}
Map<String, dynamic> toJson() => {};
getTypeName() => "GetTodos";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'todoworld.servicestack.net', types: <String, TypeInfo> {
'Todo': TypeInfo(TypeOf.Class, create:() => Todo()),
'GetTodosResponse': TypeInfo(TypeOf.Class, create:() => GetTodosResponse()),
'List<Todo>': TypeInfo(TypeOf.Class, create:() => <Todo>[]),
'GetTodos': TypeInfo(TypeOf.Class, create:() => GetTodos()),
});
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.
GET /todos HTTP/1.1 Host: todoworld.servicestack.net Accept: text/jsv
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { results: [ { id: 0, title: String, order: 0, completed: False } ], responseStatus: { errorCode: String, message: String, stackTrace: String, errors: [ { errorCode: String, fieldName: String, message: String, meta: { String: String } } ], meta: { String: String } } }