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

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

@ -376,7 +376,7 @@ class NewsClient {
final Client rootClient; final Client rootClient;
Future<GetSupportedApiVersions> getSupportedApiVersions() async { Future<NewsSupportedAPIVersions> getSupportedApiVersions() async {
var path = '/index.php/apps/news/api'; var path = '/index.php/apps/news/api';
final queryParameters = <String, dynamic>{}; final queryParameters = <String, dynamic>{};
final headers = <String, String>{}; final headers = <String, String>{};
@ -388,7 +388,7 @@ class NewsClient {
body, body,
); );
if (response.statusCode == 200) { if (response.statusCode == 200) {
return GetSupportedApiVersions.fromJson( return NewsSupportedAPIVersions.fromJson(
json.decode(utf8.decode(response.body) as String) as Map<String, dynamic>); json.decode(utf8.decode(response.body) as String) as Map<String, dynamic>);
} }
throw ApiException.fromResponse(response); // coverage:ignore-line throw ApiException.fromResponse(response); // coverage:ignore-line
@ -3520,25 +3520,25 @@ class CoreAutocompleteResult {
} }
@JsonSerializable() @JsonSerializable()
class GetSupportedApiVersions { class NewsSupportedAPIVersions {
GetSupportedApiVersions({this.apiLevels}); NewsSupportedAPIVersions({this.apiLevels});
// coverage:ignore-start // 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-end
// coverage:ignore-start // coverage:ignore-start
factory GetSupportedApiVersions.fromJsonString(String data) => factory NewsSupportedAPIVersions.fromJsonString(String data) =>
GetSupportedApiVersions.fromJson(json.decode(data) as Map<String, dynamic>); NewsSupportedAPIVersions.fromJson(json.decode(data) as Map<String, dynamic>);
// coverage:ignore-end // coverage:ignore-end
final List<String>? apiLevels; final List<String>? apiLevels;
// coverage:ignore-start // coverage:ignore-start
Map<String, dynamic> toJson() => _$GetSupportedApiVersionsToJson(this); Map<String, dynamic> toJson() => _$NewsSupportedAPIVersionsToJson(this);
// coverage:ignore-end // coverage:ignore-end
// coverage:ignore-start // coverage:ignore-start
static String toJsonString(GetSupportedApiVersions data) => json.encode(data.toJson()); static String toJsonString(NewsSupportedAPIVersions data) => json.encode(data.toJson());
// coverage:ignore-end // coverage:ignore-end
} }
@ -5635,9 +5635,9 @@ final _deserializers = <Type, dynamic Function(dynamic)>{
CoreAutocompleteResult_Ocs_Data.fromJson(data as Map<String, dynamic>), CoreAutocompleteResult_Ocs_Data.fromJson(data as Map<String, dynamic>),
List<CoreAutocompleteResult_Ocs_Data>: (final data) => List<CoreAutocompleteResult_Ocs_Data>: (final data) =>
(data as List).map((final e) => CoreAutocompleteResult_Ocs_Data.fromJson(e as Map<String, dynamic>)).toList(), (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>), NewsSupportedAPIVersions: (final data) => NewsSupportedAPIVersions.fromJson(data as Map<String, dynamic>),
List<GetSupportedApiVersions>: (final data) => List<NewsSupportedAPIVersions>: (final data) =>
(data as List).map((final e) => GetSupportedApiVersions.fromJson(e as Map<String, dynamic>)).toList(), (data as List).map((final e) => NewsSupportedAPIVersions.fromJson(e as Map<String, dynamic>)).toList(),
NewsListFolders: (final data) => NewsListFolders.fromJson(data as Map<String, dynamic>), NewsListFolders: (final data) => NewsListFolders.fromJson(data as Map<String, dynamic>),
List<NewsListFolders>: (final data) => List<NewsListFolders>: (final data) =>
(data as List).map((final e) => NewsListFolders.fromJson(e as Map<String, dynamic>)).toList(), (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(), List<CoreAutocompleteResult_Ocs>: (final data) => data.map((final e) => e.toJson()).toList(),
CoreAutocompleteResult_Ocs_Data: (final data) => data.toJson(), CoreAutocompleteResult_Ocs_Data: (final data) => data.toJson(),
List<CoreAutocompleteResult_Ocs_Data>: (final data) => data.map((final e) => e.toJson()).toList(), List<CoreAutocompleteResult_Ocs_Data>: (final data) => data.map((final e) => e.toJson()).toList(),
GetSupportedApiVersions: (final data) => data.toJson(), NewsSupportedAPIVersions: (final data) => data.toJson(),
List<GetSupportedApiVersions>: (final data) => data.map((final e) => e.toJson()).toList(), List<NewsSupportedAPIVersions>: (final data) => data.map((final e) => e.toJson()).toList(),
NewsListFolders: (final data) => data.toJson(), NewsListFolders: (final data) => data.toJson(),
List<NewsListFolders>: (final data) => data.map((final e) => e.toJson()).toList(), List<NewsListFolders>: (final data) => data.map((final e) => e.toJson()).toList(),
NewsFolder: (final data) => data.toJson(), 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(), 'ocs': instance.ocs.toJson(),
}; };
GetSupportedApiVersions _$GetSupportedApiVersionsFromJson(Map<String, dynamic> json) { NewsSupportedAPIVersions _$NewsSupportedAPIVersionsFromJson(Map<String, dynamic> json) {
$checkKeys( $checkKeys(
json, json,
allowedKeys: const ['apiLevels'], allowedKeys: const ['apiLevels'],
); );
return GetSupportedApiVersions( return NewsSupportedAPIVersions(
apiLevels: (json['apiLevels'] as List<dynamic>?)?.map((e) => e as String).toList(), 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, '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": { "NotesNote": {
"type": "object", "type": "object",
"required": [ "required": [
@ -2349,15 +2360,7 @@
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"type": "object", "$ref": "#/components/schemas/NewsSupportedAPIVersions"
"properties": {
"apiLevels": {
"type": "array",
"items": {
"type": "string"
}
}
}
} }
} }
} }

21
specs/news.json

@ -294,6 +294,17 @@
} }
} }
} }
},
"NewsSupportedAPIVersions": {
"type": "object",
"properties": {
"apiLevels": {
"type": "array",
"items": {
"type": "string"
}
}
}
} }
}, },
"securitySchemes": { "securitySchemes": {
@ -316,15 +327,7 @@
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"type": "object", "$ref": "#/components/schemas/NewsSupportedAPIVersions"
"properties": {
"apiLevels": {
"type": "array",
"items": {
"type": "string"
}
}
}
} }
} }
} }

Loading…
Cancel
Save