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. 30
      packages/nextcloud/lib/src/nextcloud.openapi.json
  4. 8
      packages/nextcloud/test/notifications_test.dart
  5. 18
      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()
class NotificationsNotificationAction {
NotificationsNotificationAction({
@ -2531,11 +2583,11 @@ class NotificationsNotification {
final String? subjectRich;
final List<String>? subjectRichParameters;
final NotificationsNotificationSubjectRichParameters? subjectRichParameters;
final String? messageRich;
final List<String>? messageRichParameters;
final NotificationsNotificationMessageRichParameters? messageRichParameters;
final String? icon;
@ -3317,7 +3369,6 @@ class UserStatusFindStatusOcsData {
UserStatusFindStatusOcsData(
this._data, {
this.userStatusPublicUserStatus,
this.list,
});
factory UserStatusFindStatusOcsData.fromJson(dynamic data) {
@ -3325,15 +3376,9 @@ class UserStatusFindStatusOcsData {
try {
userStatusPublicUserStatus = UserStatusPublicUserStatus.fromJson(data as Map<String, dynamic>);
} catch (_) {}
List? list;
try {
list = data as List;
} catch (_) {}
assert([userStatusPublicUserStatus, list].where((final x) => x != null).length == 1, 'Need oneOf');
return UserStatusFindStatusOcsData(
data,
userStatusPublicUserStatus: userStatusPublicUserStatus,
list: list,
);
}
@ -3341,9 +3386,6 @@ class UserStatusFindStatusOcsData {
final UserStatusPublicUserStatus? userStatusPublicUserStatus;
/// Only happens when the user has never set a status
final List? list;
// coverage:ignore-start
dynamic toJson() => _data;
// coverage:ignore-end
@ -3420,7 +3462,6 @@ class UserStatusGetUserStatusOcsData {
UserStatusGetUserStatusOcsData(
this._data, {
this.userStatus,
this.list,
});
factory UserStatusGetUserStatusOcsData.fromJson(dynamic data) {
@ -3428,15 +3469,9 @@ class UserStatusGetUserStatusOcsData {
try {
userStatus = UserStatus.fromJson(data as Map<String, dynamic>);
} catch (_) {}
List? list;
try {
list = data as List;
} catch (_) {}
assert([userStatus, list].where((final x) => x != null).length == 1, 'Need oneOf');
return UserStatusGetUserStatusOcsData(
data,
userStatus: userStatus,
list: list,
);
}
@ -3444,9 +3479,6 @@ class UserStatusGetUserStatusOcsData {
final UserStatus? userStatus;
/// Only happens when the user has never set a status
final List? list;
// coverage:ignore-start
dynamic toJson() => _data;
// 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?,
link: json['link'] 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?,
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?,
actions: (json['actions'] as List<dynamic>?)
?.map((e) => NotificationsNotificationAction.fromJson(e as Map<String, dynamic>))
@ -1254,9 +1258,9 @@ Map<String, dynamic> _$NotificationsNotificationToJson(NotificationsNotification
'message': instance.message,
'link': instance.link,
'subjectRich': instance.subjectRich,
'subjectRichParameters': instance.subjectRichParameters,
'subjectRichParameters': instance.subjectRichParameters?.toJson(),
'messageRich': instance.messageRich,
'messageRichParameters': instance.messageRichParameters,
'messageRichParameters': instance.messageRichParameters?.toJson(),
'icon': instance.icon,
'actions': instance.actions?.map((e) => e.toJson()).toList(),
};

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

@ -1057,21 +1057,23 @@
"type": "string"
},
"subjectRichParameters": {
"type": "array",
"items": {
"description": "TODO",
"type": "string"
"anyOf": [
{
"type": "object",
"properties": {}
}
]
},
"messageRich": {
"type": "string"
},
"messageRichParameters": {
"type": "array",
"items": {
"description": "TODO",
"type": "string"
"anyOf": [
{
"type": "object",
"properties": {}
}
]
},
"icon": {
"type": "string"
@ -1478,13 +1480,9 @@
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"oneOf": [
"anyOf": [
{
"$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"
},
"data": {
"oneOf": [
"anyOf": [
{
"$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].link, '');
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].messageRichParameters, hasLength(0));
expect(response.ocs!.data![0].messageRichParameters!.mapStringDynamic, null);
expect(response.ocs!.data![0].icon, isNotEmpty);
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!.link, '');
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!.messageRichParameters, hasLength(0));
expect(response.ocs!.data!.messageRichParameters!.mapStringDynamic, null);
expect(response.ocs!.data!.icon, isNotEmpty);
expect(response.ocs!.data!.actions, hasLength(0));
});

18
specs/notifications.json

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

12
specs/user_status.json

@ -148,13 +148,9 @@
"$ref": "#/components/schemas/OCSMeta"
},
"data": {
"oneOf": [
"anyOf": [
{
"$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"
},
"data": {
"oneOf": [
"anyOf": [
{
"$ref": "#/components/schemas/UserStatusPublicUserStatus"
},
{
"type": "array",
"description": "Only happens when the user has never set a status"
}
]
}

Loading…
Cancel
Save