Browse Source

Merge pull request #164 from provokateurin/fix/request-response-object-names

Fix/request response object names
pull/165/head
Kate 2 years ago committed by GitHub
parent
commit
c4ee148934
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      packages/dynamite/lib/src/openapi_builder.dart
  2. 28
      packages/nextcloud/lib/src/nextcloud.openapi.dart
  3. 6
      packages/nextcloud/lib/src/nextcloud.openapi.g.dart
  4. 21
      packages/nextcloud/lib/src/nextcloud.openapi.json
  5. 21
      specs/news.json

7
packages/dynamite/lib/src/openapi_builder.dart

@ -651,7 +651,7 @@ class OpenAPIBuilder implements Builder {
final result = resolveType(
spec,
state,
_toDartName(methodName, uppercaseFirstCharacter: true),
_toDartName('$methodName-request-$mimeType', uppercaseFirstCharacter: true),
mediaType.schema!,
);
switch (mimeType) {
@ -764,7 +764,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) {

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

@ -376,7 +376,7 @@ class NewsClient {
final Client rootClient;
Future<GetSupportedApiVersions> getSupportedApiVersions() async {
Future<NewsSupportedAPIVersions> getSupportedApiVersions() async {
var path = '/index.php/apps/news/api';
final queryParameters = <String, dynamic>{};
final headers = <String, String>{};
@ -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<String, dynamic>);
}
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<String, dynamic> json) => _$GetSupportedApiVersionsFromJson(json);
factory NewsSupportedAPIVersions.fromJson(Map<String, dynamic> json) => _$NewsSupportedAPIVersionsFromJson(json);
// coverage:ignore-end
// coverage:ignore-start
factory GetSupportedApiVersions.fromJsonString(String data) =>
GetSupportedApiVersions.fromJson(json.decode(data) as Map<String, dynamic>);
factory NewsSupportedAPIVersions.fromJsonString(String data) =>
NewsSupportedAPIVersions.fromJson(json.decode(data) as Map<String, dynamic>);
// coverage:ignore-end
final List<String>? apiLevels;
// coverage:ignore-start
Map<String, dynamic> toJson() => _$GetSupportedApiVersionsToJson(this);
Map<String, dynamic> 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 = <Type, dynamic Function(dynamic)>{
CoreAutocompleteResult_Ocs_Data.fromJson(data as Map<String, dynamic>),
List<CoreAutocompleteResult_Ocs_Data>: (final data) =>
(data as List).map((final e) => CoreAutocompleteResult_Ocs_Data.fromJson(e as Map<String, dynamic>)).toList(),
GetSupportedApiVersions: (final data) => GetSupportedApiVersions.fromJson(data as Map<String, dynamic>),
List<GetSupportedApiVersions>: (final data) =>
(data as List).map((final e) => GetSupportedApiVersions.fromJson(e as Map<String, dynamic>)).toList(),
NewsSupportedAPIVersions: (final data) => NewsSupportedAPIVersions.fromJson(data as Map<String, dynamic>),
List<NewsSupportedAPIVersions>: (final data) =>
(data as List).map((final e) => NewsSupportedAPIVersions.fromJson(e as Map<String, dynamic>)).toList(),
NewsListFolders: (final data) => NewsListFolders.fromJson(data as Map<String, dynamic>),
List<NewsListFolders>: (final data) =>
(data as List).map((final e) => NewsListFolders.fromJson(e as Map<String, dynamic>)).toList(),
@ -5931,8 +5931,8 @@ final _serializers = <Type, dynamic Function(dynamic)>{
List<CoreAutocompleteResult_Ocs>: (final data) => data.map((final e) => e.toJson()).toList(),
CoreAutocompleteResult_Ocs_Data: (final data) => data.toJson(),
List<CoreAutocompleteResult_Ocs_Data>: (final data) => data.map((final e) => e.toJson()).toList(),
GetSupportedApiVersions: (final data) => data.toJson(),
List<GetSupportedApiVersions>: (final data) => data.map((final e) => e.toJson()).toList(),
NewsSupportedAPIVersions: (final data) => data.toJson(),
List<NewsSupportedAPIVersions>: (final data) => data.map((final e) => e.toJson()).toList(),
NewsListFolders: (final data) => data.toJson(),
List<NewsListFolders>: (final data) => data.map((final e) => e.toJson()).toList(),
NewsFolder: (final data) => data.toJson(),

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

@ -1198,17 +1198,17 @@ Map<String, dynamic> _$CoreAutocompleteResultToJson(CoreAutocompleteResult insta
'ocs': instance.ocs.toJson(),
};
GetSupportedApiVersions _$GetSupportedApiVersionsFromJson(Map<String, dynamic> json) {
NewsSupportedAPIVersions _$NewsSupportedAPIVersionsFromJson(Map<String, dynamic> json) {
$checkKeys(
json,
allowedKeys: const ['apiLevels'],
);
return GetSupportedApiVersions(
return NewsSupportedAPIVersions(
apiLevels: (json['apiLevels'] as List<dynamic>?)?.map((e) => e as String).toList(),
);
}
Map<String, dynamic> _$GetSupportedApiVersionsToJson(GetSupportedApiVersions instance) => <String, dynamic>{
Map<String, dynamic> _$NewsSupportedAPIVersionsToJson(NewsSupportedAPIVersions instance) => <String, dynamic>{
'apiLevels': instance.apiLevels,
};

21
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"
}
}
}

21
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"
}
}
}

Loading…
Cancel
Save