Browse Source

specs,nextcloud: Fix empty objects

pull/90/head
jld3103 2 years ago
parent
commit
4461b0ceb4
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 76
      packages/nextcloud/lib/src/nextcloud.openapi.dart
  2. 12
      packages/nextcloud/lib/src/nextcloud.openapi.g.dart
  3. 34
      packages/nextcloud/lib/src/nextcloud.openapi.json
  4. 8
      packages/nextcloud/test/notifications_test.dart
  5. 22
      specs/notifications.json
  6. 12
      specs/user_status.json

76
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -2461,6 +2461,58 @@ class NotesClient {
} }
} }
class NotificationsNotificationSubjectRichParameters {
NotificationsNotificationSubjectRichParameters(
this._data, {
this.mapStringDynamic,
});
factory NotificationsNotificationSubjectRichParameters.fromJson(dynamic data) {
Map<String, dynamic>? mapStringDynamic;
try {
mapStringDynamic = data as Map<String, dynamic>;
} catch (_) {}
return NotificationsNotificationSubjectRichParameters(
data,
mapStringDynamic: mapStringDynamic,
);
}
final dynamic _data;
final Map<String, dynamic>? mapStringDynamic;
// coverage:ignore-start
dynamic toJson() => _data;
// coverage:ignore-end
}
class NotificationsNotificationMessageRichParameters {
NotificationsNotificationMessageRichParameters(
this._data, {
this.mapStringDynamic,
});
factory NotificationsNotificationMessageRichParameters.fromJson(dynamic data) {
Map<String, dynamic>? mapStringDynamic;
try {
mapStringDynamic = data as Map<String, dynamic>;
} catch (_) {}
return NotificationsNotificationMessageRichParameters(
data,
mapStringDynamic: mapStringDynamic,
);
}
final dynamic _data;
final Map<String, dynamic>? mapStringDynamic;
// coverage:ignore-start
dynamic toJson() => _data;
// coverage:ignore-end
}
@JsonSerializable() @JsonSerializable()
class NotificationsNotificationAction { class NotificationsNotificationAction {
NotificationsNotificationAction({ NotificationsNotificationAction({
@ -2531,11 +2583,11 @@ class NotificationsNotification {
final String? subjectRich; final String? subjectRich;
final List<String>? subjectRichParameters; final NotificationsNotificationSubjectRichParameters? subjectRichParameters;
final String? messageRich; final String? messageRich;
final List<String>? messageRichParameters; final NotificationsNotificationMessageRichParameters? messageRichParameters;
final String? icon; final String? icon;
@ -3317,7 +3369,6 @@ class UserStatusFindStatusOcsData {
UserStatusFindStatusOcsData( UserStatusFindStatusOcsData(
this._data, { this._data, {
this.userStatusPublicUserStatus, this.userStatusPublicUserStatus,
this.list,
}); });
factory UserStatusFindStatusOcsData.fromJson(dynamic data) { factory UserStatusFindStatusOcsData.fromJson(dynamic data) {
@ -3325,15 +3376,9 @@ class UserStatusFindStatusOcsData {
try { try {
userStatusPublicUserStatus = UserStatusPublicUserStatus.fromJson(data as Map<String, dynamic>); userStatusPublicUserStatus = UserStatusPublicUserStatus.fromJson(data as Map<String, dynamic>);
} catch (_) {} } catch (_) {}
List? list;
try {
list = data as List;
} catch (_) {}
assert([userStatusPublicUserStatus, list].where((final x) => x != null).length == 1, 'Need oneOf');
return UserStatusFindStatusOcsData( return UserStatusFindStatusOcsData(
data, data,
userStatusPublicUserStatus: userStatusPublicUserStatus, userStatusPublicUserStatus: userStatusPublicUserStatus,
list: list,
); );
} }
@ -3341,9 +3386,6 @@ class UserStatusFindStatusOcsData {
final UserStatusPublicUserStatus? userStatusPublicUserStatus; final UserStatusPublicUserStatus? userStatusPublicUserStatus;
/// Only happens when the user has never set a status
final List? list;
// coverage:ignore-start // coverage:ignore-start
dynamic toJson() => _data; dynamic toJson() => _data;
// coverage:ignore-end // coverage:ignore-end
@ -3420,7 +3462,6 @@ class UserStatusGetUserStatusOcsData {
UserStatusGetUserStatusOcsData( UserStatusGetUserStatusOcsData(
this._data, { this._data, {
this.userStatus, this.userStatus,
this.list,
}); });
factory UserStatusGetUserStatusOcsData.fromJson(dynamic data) { factory UserStatusGetUserStatusOcsData.fromJson(dynamic data) {
@ -3428,15 +3469,9 @@ class UserStatusGetUserStatusOcsData {
try { try {
userStatus = UserStatus.fromJson(data as Map<String, dynamic>); userStatus = UserStatus.fromJson(data as Map<String, dynamic>);
} catch (_) {} } catch (_) {}
List? list;
try {
list = data as List;
} catch (_) {}
assert([userStatus, list].where((final x) => x != null).length == 1, 'Need oneOf');
return UserStatusGetUserStatusOcsData( return UserStatusGetUserStatusOcsData(
data, data,
userStatus: userStatus, userStatus: userStatus,
list: list,
); );
} }
@ -3444,9 +3479,6 @@ class UserStatusGetUserStatusOcsData {
final UserStatus? userStatus; final UserStatus? userStatus;
/// Only happens when the user has never set a status
final List? list;
// coverage:ignore-start // coverage:ignore-start
dynamic toJson() => _data; dynamic toJson() => _data;
// coverage:ignore-end // coverage:ignore-end

12
packages/nextcloud/lib/src/nextcloud.openapi.g.dart

@ -1234,9 +1234,13 @@ NotificationsNotification _$NotificationsNotificationFromJson(Map<String, dynami
message: json['message'] as String?, message: json['message'] as String?,
link: json['link'] as String?, link: json['link'] as String?,
subjectRich: json['subjectRich'] as String?, subjectRich: json['subjectRich'] as String?,
subjectRichParameters: (json['subjectRichParameters'] as List<dynamic>?)?.map((e) => e as String).toList(), subjectRichParameters: json['subjectRichParameters'] == null
? null
: NotificationsNotificationSubjectRichParameters.fromJson(json['subjectRichParameters']),
messageRich: json['messageRich'] as String?, messageRich: json['messageRich'] as String?,
messageRichParameters: (json['messageRichParameters'] as List<dynamic>?)?.map((e) => e as String).toList(), messageRichParameters: json['messageRichParameters'] == null
? null
: NotificationsNotificationMessageRichParameters.fromJson(json['messageRichParameters']),
icon: json['icon'] as String?, icon: json['icon'] as String?,
actions: (json['actions'] as List<dynamic>?) actions: (json['actions'] as List<dynamic>?)
?.map((e) => NotificationsNotificationAction.fromJson(e as Map<String, dynamic>)) ?.map((e) => NotificationsNotificationAction.fromJson(e as Map<String, dynamic>))
@ -1254,9 +1258,9 @@ Map<String, dynamic> _$NotificationsNotificationToJson(NotificationsNotification
'message': instance.message, 'message': instance.message,
'link': instance.link, 'link': instance.link,
'subjectRich': instance.subjectRich, 'subjectRich': instance.subjectRich,
'subjectRichParameters': instance.subjectRichParameters, 'subjectRichParameters': instance.subjectRichParameters?.toJson(),
'messageRich': instance.messageRich, 'messageRich': instance.messageRich,
'messageRichParameters': instance.messageRichParameters, 'messageRichParameters': instance.messageRichParameters?.toJson(),
'icon': instance.icon, 'icon': instance.icon,
'actions': instance.actions?.map((e) => e.toJson()).toList(), 'actions': instance.actions?.map((e) => e.toJson()).toList(),
}; };

34
packages/nextcloud/lib/src/nextcloud.openapi.json

@ -1057,21 +1057,23 @@
"type": "string" "type": "string"
}, },
"subjectRichParameters": { "subjectRichParameters": {
"type": "array", "anyOf": [
"items": { {
"description": "TODO", "type": "object",
"type": "string" "properties": {}
} }
]
}, },
"messageRich": { "messageRich": {
"type": "string" "type": "string"
}, },
"messageRichParameters": { "messageRichParameters": {
"type": "array", "anyOf": [
"items": { {
"description": "TODO", "type": "object",
"type": "string" "properties": {}
} }
]
}, },
"icon": { "icon": {
"type": "string" "type": "string"
@ -1478,13 +1480,9 @@
"$ref": "#/components/schemas/OCSMeta" "$ref": "#/components/schemas/OCSMeta"
}, },
"data": { "data": {
"oneOf": [ "anyOf": [
{ {
"$ref": "#/components/schemas/UserStatus" "$ref": "#/components/schemas/UserStatus"
},
{
"type": "array",
"description": "Only happens when the user has never set a status"
} }
] ]
} }
@ -1521,13 +1519,9 @@
"$ref": "#/components/schemas/OCSMeta" "$ref": "#/components/schemas/OCSMeta"
}, },
"data": { "data": {
"oneOf": [ "anyOf": [
{ {
"$ref": "#/components/schemas/UserStatusPublicUserStatus" "$ref": "#/components/schemas/UserStatusPublicUserStatus"
},
{
"type": "array",
"description": "Only happens when the user has never set a status"
} }
] ]
} }

8
packages/nextcloud/test/notifications_test.dart

@ -49,9 +49,9 @@ Future main() async {
expect(response.ocs!.data![0].message, '456'); expect(response.ocs!.data![0].message, '456');
expect(response.ocs!.data![0].link, ''); expect(response.ocs!.data![0].link, '');
expect(response.ocs!.data![0].subjectRich, ''); expect(response.ocs!.data![0].subjectRich, '');
expect(response.ocs!.data![0].subjectRichParameters, hasLength(0)); expect(response.ocs!.data![0].subjectRichParameters!.mapStringDynamic, null);
expect(response.ocs!.data![0].messageRich, ''); expect(response.ocs!.data![0].messageRich, '');
expect(response.ocs!.data![0].messageRichParameters, hasLength(0)); expect(response.ocs!.data![0].messageRichParameters!.mapStringDynamic, null);
expect(response.ocs!.data![0].icon, isNotEmpty); expect(response.ocs!.data![0].icon, isNotEmpty);
expect(response.ocs!.data![0].actions, hasLength(0)); expect(response.ocs!.data![0].actions, hasLength(0));
}); });
@ -71,9 +71,9 @@ Future main() async {
expect(response.ocs!.data!.message, '456'); expect(response.ocs!.data!.message, '456');
expect(response.ocs!.data!.link, ''); expect(response.ocs!.data!.link, '');
expect(response.ocs!.data!.subjectRich, ''); expect(response.ocs!.data!.subjectRich, '');
expect(response.ocs!.data!.subjectRichParameters, hasLength(0)); expect(response.ocs!.data!.subjectRichParameters!.mapStringDynamic, null);
expect(response.ocs!.data!.messageRich, ''); expect(response.ocs!.data!.messageRich, '');
expect(response.ocs!.data!.messageRichParameters, hasLength(0)); expect(response.ocs!.data!.messageRichParameters!.mapStringDynamic, null);
expect(response.ocs!.data!.icon, isNotEmpty); expect(response.ocs!.data!.icon, isNotEmpty);
expect(response.ocs!.data!.actions, hasLength(0)); expect(response.ocs!.data!.actions, hasLength(0));
}); });

22
specs/notifications.json

@ -107,21 +107,23 @@
"type": "string" "type": "string"
}, },
"subjectRichParameters": { "subjectRichParameters": {
"type": "array", "anyOf": [
"items": { {
"description": "TODO", "type": "object",
"type": "string" "properties": {}
} }
]
}, },
"messageRich": { "messageRich": {
"type": "string" "type": "string"
}, },
"messageRichParameters": { "messageRichParameters": {
"type": "array", "anyOf": [
"items": { {
"description": "TODO", "type": "object",
"type": "string" "properties": {}
} }
]
}, },
"icon": { "icon": {
"type": "string" "type": "string"

12
specs/user_status.json

@ -148,13 +148,9 @@
"$ref": "#/components/schemas/OCSMeta" "$ref": "#/components/schemas/OCSMeta"
}, },
"data": { "data": {
"oneOf": [ "anyOf": [
{ {
"$ref": "#/components/schemas/UserStatus" "$ref": "#/components/schemas/UserStatus"
},
{
"type": "array",
"description": "Only happens when the user has never set a status"
} }
] ]
} }
@ -191,13 +187,9 @@
"$ref": "#/components/schemas/OCSMeta" "$ref": "#/components/schemas/OCSMeta"
}, },
"data": { "data": {
"oneOf": [ "anyOf": [
{ {
"$ref": "#/components/schemas/UserStatusPublicUserStatus" "$ref": "#/components/schemas/UserStatusPublicUserStatus"
},
{
"type": "array",
"description": "Only happens when the user has never set a status"
} }
] ]
} }

Loading…
Cancel
Save