| GET | /posts/{category} |
|---|
import 'package:servicestack/servicestack.dart';
class PagingRequest implements IConvertible
{
int? page;
int? limit;
int? offSet;
PagingRequest({this.page,this.limit,this.offSet});
PagingRequest.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
page = json['page'];
limit = json['limit'];
offSet = json['offSet'];
return this;
}
Map<String, dynamic> toJson() => {
'page': page,
'limit': limit,
'offSet': offSet
};
getTypeName() => "PagingRequest";
TypeContext? context = _ctx;
}
class CategoryResponse implements IConvertible
{
int? id;
String? name;
String? slug;
CategoryResponse({this.id,this.name,this.slug});
CategoryResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
slug = json['slug'];
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'name': name,
'slug': slug
};
getTypeName() => "CategoryResponse";
TypeContext? context = _ctx;
}
class PostResponse implements IConvertible
{
int? id;
String? title;
String? slug;
String? description;
String? body;
int? categoryId;
CategoryResponse? category;
String? imageUrl;
int? viewCount;
bool? isPublished;
DateTime? publishedDate;
DateTime? createdDate;
DateTime? updatedDate;
PostResponse({this.id,this.title,this.slug,this.description,this.body,this.categoryId,this.category,this.imageUrl,this.viewCount,this.isPublished,this.publishedDate,this.createdDate,this.updatedDate});
PostResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
id = json['id'];
title = json['title'];
slug = json['slug'];
description = json['description'];
body = json['body'];
categoryId = json['categoryId'];
category = JsonConverters.fromJson(json['category'],'CategoryResponse',context!);
imageUrl = json['imageUrl'];
viewCount = json['viewCount'];
isPublished = json['isPublished'];
publishedDate = JsonConverters.fromJson(json['publishedDate'],'DateTime',context!);
createdDate = JsonConverters.fromJson(json['createdDate'],'DateTime',context!);
updatedDate = JsonConverters.fromJson(json['updatedDate'],'DateTime',context!);
return this;
}
Map<String, dynamic> toJson() => {
'id': id,
'title': title,
'slug': slug,
'description': description,
'body': body,
'categoryId': categoryId,
'category': JsonConverters.toJson(category,'CategoryResponse',context!),
'imageUrl': imageUrl,
'viewCount': viewCount,
'isPublished': isPublished,
'publishedDate': JsonConverters.toJson(publishedDate,'DateTime',context!),
'createdDate': JsonConverters.toJson(createdDate,'DateTime',context!),
'updatedDate': JsonConverters.toJson(updatedDate,'DateTime',context!)
};
getTypeName() => "PostResponse";
TypeContext? context = _ctx;
}
class GetPostByCategoryRequest extends PagingRequest implements IConvertible
{
String? category;
GetPostByCategoryRequest({this.category});
GetPostByCategoryRequest.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
super.fromMap(json);
category = json['category'];
return this;
}
Map<String, dynamic> toJson() => super.toJson()..addAll({
'category': category
});
getTypeName() => "GetPostByCategoryRequest";
TypeContext? context = _ctx;
}
class Pagination implements IConvertible
{
int? total;
int? pages;
int? offset;
int? limit;
int? currentPage;
Pagination({this.total,this.pages,this.offset,this.limit,this.currentPage});
Pagination.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
total = json['total'];
pages = json['pages'];
offset = json['offset'];
limit = json['limit'];
currentPage = json['currentPage'];
return this;
}
Map<String, dynamic> toJson() => {
'total': total,
'pages': pages,
'offset': offset,
'limit': limit,
'currentPage': currentPage
};
getTypeName() => "Pagination";
TypeContext? context = _ctx;
}
class PageResponse<PostResponse> implements IResponseRequest, IConvertible
{
int? code;
String? message;
List<PostResponse>? data;
Pagination? pagination;
PageResponse({this.code,this.message,this.data,this.pagination});
PageResponse.fromJson(Map<String, dynamic> json) { fromMap(json); }
fromMap(Map<String, dynamic> json) {
code = json['code'];
message = json['message'];
data = JsonConverters.fromJson(json['data'],'List<${runtimeGenericTypeDefs(this,[0]).join(",")}>',context!);
pagination = JsonConverters.fromJson(json['pagination'],'Pagination',context!);
return this;
}
Map<String, dynamic> toJson() => {
'code': code,
'message': message,
'data': JsonConverters.toJson(data,'List<PostResponse>',context!),
'pagination': JsonConverters.toJson(pagination,'Pagination',context!)
};
getTypeName() => "PageResponse<$PostResponse>";
TypeContext? context = _ctx;
}
TypeContext _ctx = TypeContext(library: 'tanchinhdo_api_sandbox.adnx.vn', types: <String, TypeInfo> {
'PagingRequest': TypeInfo(TypeOf.Class, create:() => PagingRequest()),
'CategoryResponse': TypeInfo(TypeOf.Class, create:() => CategoryResponse()),
'PostResponse': TypeInfo(TypeOf.Class, create:() => PostResponse()),
'GetPostByCategoryRequest': TypeInfo(TypeOf.Class, create:() => GetPostByCategoryRequest()),
'Pagination': TypeInfo(TypeOf.Class, create:() => Pagination()),
'PageResponse<PostResponse>': TypeInfo(TypeOf.Class, create:() => PageResponse<PostResponse>()),
});
Dart GetPostByCategoryRequest 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.
GET /posts/{category} HTTP/1.1
Host: tanchinhdo-api-sandbox.adnx.vn
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
code: 0,
message: String,
data:
[
{
id: 0,
title: String,
slug: String,
description: String,
body: String,
categoryId: 0,
category:
{
id: 0,
name: String,
slug: String
},
imageUrl: String,
viewCount: 0,
isPublished: False
}
]
}