From fbd6ae286b02768728e04d5216f59fb08d79d0b6 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Thu, 17 Nov 2022 15:53:03 +0100 Subject: [PATCH] tool,specs,nextcloud: Add empty ocs response --- .../nextcloud/lib/src/nextcloud.openapi.dart | 53 +++++++++---------- .../lib/src/nextcloud.openapi.g.dart | 12 ++--- .../nextcloud/lib/src/nextcloud.openapi.json | 53 +++++++++---------- specs/core.json | 23 ++++++++ specs/news.json | 23 ++++++++ specs/notes.json | 23 ++++++++ specs/notifications.json | 11 ++-- specs/provisioning_api.json | 23 ++++++++ specs/user_status.json | 23 ++++++++ tool/generate-nextcloud.sh | 24 +++++++++ 10 files changed, 199 insertions(+), 69 deletions(-) diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.dart b/packages/nextcloud/lib/src/nextcloud.openapi.dart index 171a72eb..6fc977bd 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.dart +++ b/packages/nextcloud/lib/src/nextcloud.openapi.dart @@ -2713,33 +2713,33 @@ class NotificationsGetNotification { } @JsonSerializable() -class NotificationsEmpty_Ocs { - NotificationsEmpty_Ocs({ +class EmptyOCS_Ocs { + EmptyOCS_Ocs({ required this.meta, required this.data, }); - factory NotificationsEmpty_Ocs.fromJson(Map json) => _$NotificationsEmpty_OcsFromJson(json); + factory EmptyOCS_Ocs.fromJson(Map json) => _$EmptyOCS_OcsFromJson(json); final OCSMeta meta; - final List data; + final List data; // coverage:ignore-start - Map toJson() => _$NotificationsEmpty_OcsToJson(this); + Map toJson() => _$EmptyOCS_OcsToJson(this); // coverage:ignore-end } @JsonSerializable() -class NotificationsEmpty { - NotificationsEmpty({required this.ocs}); +class EmptyOCS { + EmptyOCS({required this.ocs}); - factory NotificationsEmpty.fromJson(Map json) => _$NotificationsEmptyFromJson(json); + factory EmptyOCS.fromJson(Map json) => _$EmptyOCSFromJson(json); - final NotificationsEmpty_Ocs ocs; + final EmptyOCS_Ocs ocs; // coverage:ignore-start - Map toJson() => _$NotificationsEmptyToJson(this); + Map toJson() => _$EmptyOCSToJson(this); // coverage:ignore-end } @@ -2858,7 +2858,7 @@ class NotificationsClient { throw ApiException.fromResponse(response); // coverage:ignore-line } - Future deleteNotification({required int id}) async { + Future deleteNotification({required int id}) async { var path = '/ocs/v2.php/apps/notifications/api/v2/notifications/{id}'; final queryParameters = {}; final headers = {}; @@ -2871,7 +2871,7 @@ class NotificationsClient { body, ); if (response.statusCode == 200) { - return NotificationsEmpty.fromJson(json.decode(utf8.decode(response.body)) as Map); + return EmptyOCS.fromJson(json.decode(utf8.decode(response.body)) as Map); } throw ApiException.fromResponse(response); // coverage:ignore-line } @@ -2918,7 +2918,7 @@ class NotificationsClient { throw ApiException.fromResponse(response); // coverage:ignore-line } - Future sendAdminNotification({ + Future sendAdminNotification({ required String userId, required String shortMessage, String longMessage = '', @@ -2937,7 +2937,7 @@ class NotificationsClient { body, ); if (response.statusCode == 200) { - return NotificationsEmpty.fromJson(json.decode(utf8.decode(response.body)) as Map); + return EmptyOCS.fromJson(json.decode(utf8.decode(response.body)) as Map); } throw ApiException.fromResponse(response); // coverage:ignore-line } @@ -4342,14 +4342,12 @@ final _deserializers = { .map( (final e) => NotificationsGetNotification_Ocs.fromJson(e as Map)) .toList(), - NotificationsEmpty: (final data) => NotificationsEmpty.fromJson(data as Map), - List: (final data) => (data as List) - .map((final e) => NotificationsEmpty.fromJson(e as Map)) - .toList(), - NotificationsEmpty_Ocs: (final data) => NotificationsEmpty_Ocs.fromJson(data as Map), - List: (final data) => (data as List) - .map((final e) => NotificationsEmpty_Ocs.fromJson(e as Map)) - .toList(), + EmptyOCS: (final data) => EmptyOCS.fromJson(data as Map), + List: (final data) => + (data as List).map((final e) => EmptyOCS.fromJson(e as Map)).toList(), + EmptyOCS_Ocs: (final data) => EmptyOCS_Ocs.fromJson(data as Map), + List: (final data) => + (data as List).map((final e) => EmptyOCS_Ocs.fromJson(e as Map)).toList(), NotificationsPushServerRegistration: (final data) => NotificationsPushServerRegistration.fromJson(data as Map), List: (final data) => (data as List) @@ -4821,12 +4819,11 @@ final _serializers = { List: (final data) => (data as List) .map((final e) => (e as NotificationsGetNotification_Ocs).toJson()) .toList(), - NotificationsEmpty: (final data) => (data as NotificationsEmpty).toJson(), - List: (final data) => - (data as List).map((final e) => (e as NotificationsEmpty).toJson()).toList(), - NotificationsEmpty_Ocs: (final data) => (data as NotificationsEmpty_Ocs).toJson(), - List: (final data) => - (data as List).map((final e) => (e as NotificationsEmpty_Ocs).toJson()).toList(), + EmptyOCS: (final data) => (data as EmptyOCS).toJson(), + List: (final data) => (data as List).map((final e) => (e as EmptyOCS).toJson()).toList(), + EmptyOCS_Ocs: (final data) => (data as EmptyOCS_Ocs).toJson(), + List: (final data) => + (data as List).map((final e) => (e as EmptyOCS_Ocs).toJson()).toList(), NotificationsPushServerRegistration: (final data) => (data as NotificationsPushServerRegistration).toJson(), List: (final data) => (data as List) .map((final e) => (e as NotificationsPushServerRegistration).toJson()) diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.g.dart b/packages/nextcloud/lib/src/nextcloud.openapi.g.dart index a7785628..03ed51b5 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.g.dart +++ b/packages/nextcloud/lib/src/nextcloud.openapi.g.dart @@ -1260,21 +1260,21 @@ Map _$NotificationsGetNotificationToJson(NotificationsGetNotifi 'ocs': instance.ocs.toJson(), }; -NotificationsEmpty_Ocs _$NotificationsEmpty_OcsFromJson(Map json) => NotificationsEmpty_Ocs( +EmptyOCS_Ocs _$EmptyOCS_OcsFromJson(Map json) => EmptyOCS_Ocs( meta: OCSMeta.fromJson(json['meta'] as Map), - data: (json['data'] as List).map((e) => e as String).toList(), + data: json['data'] as List, ); -Map _$NotificationsEmpty_OcsToJson(NotificationsEmpty_Ocs instance) => { +Map _$EmptyOCS_OcsToJson(EmptyOCS_Ocs instance) => { 'meta': instance.meta.toJson(), 'data': instance.data, }; -NotificationsEmpty _$NotificationsEmptyFromJson(Map json) => NotificationsEmpty( - ocs: NotificationsEmpty_Ocs.fromJson(json['ocs'] as Map), +EmptyOCS _$EmptyOCSFromJson(Map json) => EmptyOCS( + ocs: EmptyOCS_Ocs.fromJson(json['ocs'] as Map), ); -Map _$NotificationsEmptyToJson(NotificationsEmpty instance) => { +Map _$EmptyOCSToJson(EmptyOCS instance) => { 'ocs': instance.ocs.toJson(), }; diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.json b/packages/nextcloud/lib/src/nextcloud.openapi.json index 5e04b98e..77d2646b 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.json +++ b/packages/nextcloud/lib/src/nextcloud.openapi.json @@ -72,6 +72,29 @@ } } }, + "EmptyOCS": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "array" + } + } + } + } + }, "CoreServerStatus": { "type": "object", "required": [ @@ -1360,32 +1383,6 @@ } } }, - "NotificationsEmpty": { - "type": "object", - "required": [ - "ocs" - ], - "properties": { - "ocs": { - "type": "object", - "required": [ - "meta", - "data" - ], - "properties": { - "meta": { - "$ref": "#/components/schemas/OCSMeta" - }, - "data": { - "type": "array", - "items": { - "type": "string" - } - } - } - } - } - }, "NotificationsNotification": { "type": "object", "required": [ @@ -3335,7 +3332,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NotificationsEmpty" + "$ref": "#/components/schemas/EmptyOCS" } } } @@ -3449,7 +3446,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NotificationsEmpty" + "$ref": "#/components/schemas/EmptyOCS" } } } diff --git a/specs/core.json b/specs/core.json index 0fdf2dd4..d8984683 100644 --- a/specs/core.json +++ b/specs/core.json @@ -58,6 +58,29 @@ } } }, + "EmptyOCS": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "array" + } + } + } + } + }, "CoreServerStatus": { "type": "object", "required": [ diff --git a/specs/news.json b/specs/news.json index f9c3d12d..74fa0fba 100644 --- a/specs/news.json +++ b/specs/news.json @@ -58,6 +58,29 @@ } } }, + "EmptyOCS": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "array" + } + } + } + } + }, "NewsListFeeds": { "type": "object", "required": [ diff --git a/specs/notes.json b/specs/notes.json index f8f39f6f..97b13ea5 100644 --- a/specs/notes.json +++ b/specs/notes.json @@ -58,6 +58,29 @@ } } }, + "EmptyOCS": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "array" + } + } + } + } + }, "NotesNote": { "type": "object", "required": [ diff --git a/specs/notifications.json b/specs/notifications.json index 1b737291..01e82cb4 100644 --- a/specs/notifications.json +++ b/specs/notifications.json @@ -58,7 +58,7 @@ } } }, - "NotificationsEmpty": { + "EmptyOCS": { "type": "object", "required": [ "ocs" @@ -75,10 +75,7 @@ "$ref": "#/components/schemas/OCSMeta" }, "data": { - "type": "array", - "items": { - "type": "string" - } + "type": "array" } } } @@ -416,7 +413,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NotificationsEmpty" + "$ref": "#/components/schemas/EmptyOCS" } } } @@ -530,7 +527,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NotificationsEmpty" + "$ref": "#/components/schemas/EmptyOCS" } } } diff --git a/specs/provisioning_api.json b/specs/provisioning_api.json index 1fcbc6c2..c4ec4e01 100644 --- a/specs/provisioning_api.json +++ b/specs/provisioning_api.json @@ -58,6 +58,29 @@ } } }, + "EmptyOCS": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "array" + } + } + } + } + }, "ProvisioningApiUser": { "type": "object", "required": [ diff --git a/specs/user_status.json b/specs/user_status.json index 9ff5fdf6..ff573921 100644 --- a/specs/user_status.json +++ b/specs/user_status.json @@ -58,6 +58,29 @@ } } }, + "EmptyOCS": { + "type": "object", + "required": [ + "ocs" + ], + "properties": { + "ocs": { + "type": "object", + "required": [ + "meta", + "data" + ], + "properties": { + "meta": { + "$ref": "#/components/schemas/OCSMeta" + }, + "data": { + "type": "array" + } + } + } + } + }, "UserStatusPredefinedStatuses": { "type": "object", "required": [ diff --git a/tool/generate-nextcloud.sh b/tool/generate-nextcloud.sh index 046f59b8..b8a8a5e3 100755 --- a/tool/generate-nextcloud.sh +++ b/tool/generate-nextcloud.sh @@ -92,6 +92,30 @@ for codename in ${codenames[*]}; do type: "string" } } + } | + .components.schemas.EmptyOCS = + { + type: "object", + required: [ + "ocs" + ], + properties: { + ocs: { + type: "object", + required: [ + "meta", + "data" + ], + properties: { + meta: { + "$ref": "#/components/schemas/OCSMeta" + }, + data: { + type: "array" + } + } + } + } } ' \ specs/templates/"$codename".json \