You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.7 KiB
Dart

import 'package:freezed_annotation/freezed_annotation.dart';
part 'parse.freezed.dart';
part 'parse.g.dart';
@freezed
class MWParseCategoryInfo with _$MWParseCategoryInfo {
factory MWParseCategoryInfo({
required String category,
@Default("") String sortkey,
}) = _MWParseCategoryInfo;
factory MWParseCategoryInfo.fromJson(Map<String, dynamic> json) =>
_$MWParseCategoryInfoFromJson(json);
}
@freezed
class MWParseLangLinkInfo with _$MWParseLangLinkInfo {
factory MWParseLangLinkInfo({
required String lang,
required String title,
@Default("") String url,
@Default("") String langname,
@Default("") autonym,
}) = _MWParseLangLinkInfo;
factory MWParseLangLinkInfo.fromJson(Map<String, dynamic> json) =>
_$MWParseLangLinkInfoFromJson(json);
}
@freezed
class MWParsePageLinkInfo with _$MWParsePageLinkInfo {
factory MWParsePageLinkInfo({
required int ns,
required String title,
@Default(false) bool exists,
}) = _MWParsePageLinkInfo;
factory MWParsePageLinkInfo.fromJson(Map<String, dynamic> json) =>
_$MWParsePageLinkInfoFromJson(json);
}
@freezed
class MWParseSectionInfo with _$MWParseSectionInfo {
factory MWParseSectionInfo({
required int toclevel,
required String level,
required String line,
@Default("") String number,
@Default("") String index,
@Default("") String fromtitle,
@Default(-1) int byteoffset,
@Default("") String anchor,
}) = _MWParseSectionInfo;
factory MWParseSectionInfo.fromJson(Map<String, dynamic> json) =>
_$MWParseSectionInfoFromJson(json);
}
@freezed
class MWParseInfo with _$MWParseInfo {
factory MWParseInfo({
required String title,
required int pageid,
required int revid,
required String text,
String? displaytitle,
@Default([]) List<MWParseLangLinkInfo> langlink,
@Default([]) List<MWParseCategoryInfo> categories,
@Default([]) List<MWParsePageLinkInfo> links,
@Default([]) List<MWParsePageLinkInfo> templates,
@Default([]) List<String> images,
@Default([]) List<String> externallinks,
@Default([]) List<MWParseSectionInfo> sections,
@Default(true) bool showtoc,
@Default([]) List<String> modules,
@Default([]) List<String> modulescripts,
@Default([]) List<String> modulestyles,
@Default([]) List<dynamic> iwlinks,
@Default({}) Map<String, dynamic> jsconfigvars,
@Default({}) Map<String, dynamic> properties,
}) = _MWParseInfo;
factory MWParseInfo.fromJson(Map<String, dynamic> json) => _$MWParseInfoFromJson(json);
}
@freezed
class MWParseResponse with _$MWParseResponse {
factory MWParseResponse({required MWParseInfo parse}) = _MWParseResponse;
factory MWParseResponse.fromJson(Map<String, dynamic> json) => _$MWParseResponseFromJson(json);
}