From ee89b0a431fedfa930624edc114f6731450f1ddf Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 21 Dec 2022 08:34:31 +0100 Subject: [PATCH 1/2] specs,nextcloud: Fix news supported api versions response --- .../nextcloud/lib/src/nextcloud.openapi.dart | 28 +++++++++---------- .../lib/src/nextcloud.openapi.g.dart | 6 ++-- .../nextcloud/lib/src/nextcloud.openapi.json | 21 ++++++++------ specs/news.json | 21 ++++++++------ 4 files changed, 41 insertions(+), 35 deletions(-) diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.dart b/packages/nextcloud/lib/src/nextcloud.openapi.dart index 867e109f..76b75470 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.dart +++ b/packages/nextcloud/lib/src/nextcloud.openapi.dart @@ -376,7 +376,7 @@ class NewsClient { final Client rootClient; - Future getSupportedApiVersions() async { + Future getSupportedApiVersions() async { var path = '/index.php/apps/news/api'; final queryParameters = {}; final headers = {}; @@ -388,7 +388,7 @@ class NewsClient { body, ); if (response.statusCode == 200) { - return GetSupportedApiVersions.fromJson( + return NewsSupportedAPIVersions.fromJson( json.decode(utf8.decode(response.body) as String) as Map); } throw ApiException.fromResponse(response); // coverage:ignore-line @@ -3520,25 +3520,25 @@ class CoreAutocompleteResult { } @JsonSerializable() -class GetSupportedApiVersions { - GetSupportedApiVersions({this.apiLevels}); +class NewsSupportedAPIVersions { + NewsSupportedAPIVersions({this.apiLevels}); // coverage:ignore-start - factory GetSupportedApiVersions.fromJson(Map json) => _$GetSupportedApiVersionsFromJson(json); + factory NewsSupportedAPIVersions.fromJson(Map json) => _$NewsSupportedAPIVersionsFromJson(json); // coverage:ignore-end // coverage:ignore-start - factory GetSupportedApiVersions.fromJsonString(String data) => - GetSupportedApiVersions.fromJson(json.decode(data) as Map); + factory NewsSupportedAPIVersions.fromJsonString(String data) => + NewsSupportedAPIVersions.fromJson(json.decode(data) as Map); // coverage:ignore-end final List? apiLevels; // coverage:ignore-start - Map toJson() => _$GetSupportedApiVersionsToJson(this); + Map toJson() => _$NewsSupportedAPIVersionsToJson(this); // coverage:ignore-end // coverage:ignore-start - static String toJsonString(GetSupportedApiVersions data) => json.encode(data.toJson()); + static String toJsonString(NewsSupportedAPIVersions data) => json.encode(data.toJson()); // coverage:ignore-end } @@ -5635,9 +5635,9 @@ final _deserializers = { CoreAutocompleteResult_Ocs_Data.fromJson(data as Map), List: (final data) => (data as List).map((final e) => CoreAutocompleteResult_Ocs_Data.fromJson(e as Map)).toList(), - GetSupportedApiVersions: (final data) => GetSupportedApiVersions.fromJson(data as Map), - List: (final data) => - (data as List).map((final e) => GetSupportedApiVersions.fromJson(e as Map)).toList(), + NewsSupportedAPIVersions: (final data) => NewsSupportedAPIVersions.fromJson(data as Map), + List: (final data) => + (data as List).map((final e) => NewsSupportedAPIVersions.fromJson(e as Map)).toList(), NewsListFolders: (final data) => NewsListFolders.fromJson(data as Map), List: (final data) => (data as List).map((final e) => NewsListFolders.fromJson(e as Map)).toList(), @@ -5931,8 +5931,8 @@ final _serializers = { List: (final data) => data.map((final e) => e.toJson()).toList(), CoreAutocompleteResult_Ocs_Data: (final data) => data.toJson(), List: (final data) => data.map((final e) => e.toJson()).toList(), - GetSupportedApiVersions: (final data) => data.toJson(), - List: (final data) => data.map((final e) => e.toJson()).toList(), + NewsSupportedAPIVersions: (final data) => data.toJson(), + List: (final data) => data.map((final e) => e.toJson()).toList(), NewsListFolders: (final data) => data.toJson(), List: (final data) => data.map((final e) => e.toJson()).toList(), NewsFolder: (final data) => data.toJson(), diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.g.dart b/packages/nextcloud/lib/src/nextcloud.openapi.g.dart index 978348df..941a3f3d 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.g.dart +++ b/packages/nextcloud/lib/src/nextcloud.openapi.g.dart @@ -1198,17 +1198,17 @@ Map _$CoreAutocompleteResultToJson(CoreAutocompleteResult insta 'ocs': instance.ocs.toJson(), }; -GetSupportedApiVersions _$GetSupportedApiVersionsFromJson(Map json) { +NewsSupportedAPIVersions _$NewsSupportedAPIVersionsFromJson(Map json) { $checkKeys( json, allowedKeys: const ['apiLevels'], ); - return GetSupportedApiVersions( + return NewsSupportedAPIVersions( apiLevels: (json['apiLevels'] as List?)?.map((e) => e as String).toList(), ); } -Map _$GetSupportedApiVersionsToJson(GetSupportedApiVersions instance) => { +Map _$NewsSupportedAPIVersionsToJson(NewsSupportedAPIVersions instance) => { 'apiLevels': instance.apiLevels, }; diff --git a/packages/nextcloud/lib/src/nextcloud.openapi.json b/packages/nextcloud/lib/src/nextcloud.openapi.json index a4c105e1..80300cb0 100644 --- a/packages/nextcloud/lib/src/nextcloud.openapi.json +++ b/packages/nextcloud/lib/src/nextcloud.openapi.json @@ -1193,6 +1193,17 @@ } } }, + "NewsSupportedAPIVersions": { + "type": "object", + "properties": { + "apiLevels": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, "NotesNote": { "type": "object", "required": [ @@ -2349,15 +2360,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "apiLevels": { - "type": "array", - "items": { - "type": "string" - } - } - } + "$ref": "#/components/schemas/NewsSupportedAPIVersions" } } } diff --git a/specs/news.json b/specs/news.json index 2e3d8256..053b5992 100644 --- a/specs/news.json +++ b/specs/news.json @@ -294,6 +294,17 @@ } } } + }, + "NewsSupportedAPIVersions": { + "type": "object", + "properties": { + "apiLevels": { + "type": "array", + "items": { + "type": "string" + } + } + } } }, "securitySchemes": { @@ -316,15 +327,7 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "apiLevels": { - "type": "array", - "items": { - "type": "string" - } - } - } + "$ref": "#/components/schemas/NewsSupportedAPIVersions" } } } From e42ea0d9832ae9d59ed3f097dc0d720cdc2c241f Mon Sep 17 00:00:00 2001 From: jld3103 Date: Mon, 19 Dec 2022 20:34:54 +0100 Subject: [PATCH 2/2] dynamite: Fix request and response object names --- packages/dynamite/lib/src/openapi_builder.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/dynamite/lib/src/openapi_builder.dart b/packages/dynamite/lib/src/openapi_builder.dart index e0cdd428..44084ea9 100644 --- a/packages/dynamite/lib/src/openapi_builder.dart +++ b/packages/dynamite/lib/src/openapi_builder.dart @@ -649,7 +649,7 @@ class OpenAPIBuilder implements Builder { final result = resolveType( spec, state, - _toDartName(methodName, uppercaseFirstCharacter: true), + _toDartName('$methodName-request-$mimeType', uppercaseFirstCharacter: true), mediaType.schema!, ); switch (mimeType) { @@ -761,7 +761,10 @@ class OpenAPIBuilder implements Builder { final result = resolveType( spec, state, - _toDartName(methodName, uppercaseFirstCharacter: true), + _toDartName( + '$methodName-response-$statusCode-$mimeType', + uppercaseFirstCharacter: true, + ), mediaType.schema!, ); switch (mimeType) {