From 44a086c2f97ccbae24acee91deca9885e7d6234f Mon Sep 17 00:00:00 2001 From: mgabor <> Date: Fri, 12 Apr 2024 13:49:06 +0200 Subject: [PATCH] generate openapi --- mobile/openapi/.openapi-generator/FILES | 3 + mobile/openapi/README.md | 1 + .../openapi/doc/AlbumPermissionResponseDto.md | 16 +++ mobile/openapi/doc/AlbumResponseDto.md | 3 +- mobile/openapi/lib/api.dart | 1 + mobile/openapi/lib/api_client.dart | 2 + .../model/album_permission_response_dto.dart | 106 ++++++++++++++++++ .../openapi/lib/model/album_response_dto.dart | 11 +- .../album_permission_response_dto_test.dart | 32 ++++++ .../openapi/test/album_response_dto_test.dart | 6 + open-api/immich-openapi-specs.json | 24 ++++ open-api/typescript-sdk/src/fetch-client.ts | 42 ++++--- 12 files changed, 227 insertions(+), 20 deletions(-) create mode 100644 mobile/openapi/doc/AlbumPermissionResponseDto.md create mode 100644 mobile/openapi/lib/model/album_permission_response_dto.dart create mode 100644 mobile/openapi/test/album_permission_response_dto_test.dart diff --git a/mobile/openapi/.openapi-generator/FILES b/mobile/openapi/.openapi-generator/FILES index 263687549f..d2f865ba1e 100644 --- a/mobile/openapi/.openapi-generator/FILES +++ b/mobile/openapi/.openapi-generator/FILES @@ -15,6 +15,7 @@ doc/ActivityStatisticsResponseDto.md doc/AddUsersDto.md doc/AlbumApi.md doc/AlbumCountResponseDto.md +doc/AlbumPermissionResponseDto.md doc/AlbumResponseDto.md doc/AllJobStatusResponseDto.md doc/AssetApi.md @@ -236,6 +237,7 @@ lib/model/activity_response_dto.dart lib/model/activity_statistics_response_dto.dart lib/model/add_users_dto.dart lib/model/album_count_response_dto.dart +lib/model/album_permission_response_dto.dart lib/model/album_response_dto.dart lib/model/all_job_status_response_dto.dart lib/model/api_key_create_dto.dart @@ -413,6 +415,7 @@ test/activity_statistics_response_dto_test.dart test/add_users_dto_test.dart test/album_api_test.dart test/album_count_response_dto_test.dart +test/album_permission_response_dto_test.dart test/album_response_dto_test.dart test/all_job_status_response_dto_test.dart test/api_key_api_test.dart diff --git a/mobile/openapi/README.md b/mobile/openapi/README.md index 9a03fbd61c..4093a7f572 100644 --- a/mobile/openapi/README.md +++ b/mobile/openapi/README.md @@ -232,6 +232,7 @@ Class | Method | HTTP request | Description - [ActivityStatisticsResponseDto](doc//ActivityStatisticsResponseDto.md) - [AddUsersDto](doc//AddUsersDto.md) - [AlbumCountResponseDto](doc//AlbumCountResponseDto.md) + - [AlbumPermissionResponseDto](doc//AlbumPermissionResponseDto.md) - [AlbumResponseDto](doc//AlbumResponseDto.md) - [AllJobStatusResponseDto](doc//AllJobStatusResponseDto.md) - [AssetBulkDeleteDto](doc//AssetBulkDeleteDto.md) diff --git a/mobile/openapi/doc/AlbumPermissionResponseDto.md b/mobile/openapi/doc/AlbumPermissionResponseDto.md new file mode 100644 index 0000000000..b8c5e531a7 --- /dev/null +++ b/mobile/openapi/doc/AlbumPermissionResponseDto.md @@ -0,0 +1,16 @@ +# openapi.model.AlbumPermissionResponseDto + +## Load the model package +```dart +import 'package:openapi/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**readonly** | **bool** | | +**user** | [**UserResponseDto**](UserResponseDto.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/mobile/openapi/doc/AlbumResponseDto.md b/mobile/openapi/doc/AlbumResponseDto.md index dd4a94e883..1f6e4d2d65 100644 --- a/mobile/openapi/doc/AlbumResponseDto.md +++ b/mobile/openapi/doc/AlbumResponseDto.md @@ -9,6 +9,7 @@ import 'package:openapi/api.dart'; Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **albumName** | **String** | | +**albumPermissions** | [**List**](AlbumPermissionResponseDto.md) | | [default to const []] **albumThumbnailAssetId** | **String** | | **assetCount** | **int** | | **assets** | [**List**](AssetResponseDto.md) | | [default to const []] @@ -23,7 +24,7 @@ Name | Type | Description | Notes **owner** | [**UserResponseDto**](UserResponseDto.md) | | **ownerId** | **String** | | **shared** | **bool** | | -**sharedUsers** | [**List**](UserResponseDto.md) | | [default to const []] +**sharedUsers** | [**List**](UserResponseDto.md) | Deprecated in favor of albumPermissions | [default to const []] **startDate** | [**DateTime**](DateTime.md) | | [optional] **updatedAt** | [**DateTime**](DateTime.md) | | diff --git a/mobile/openapi/lib/api.dart b/mobile/openapi/lib/api.dart index ae458f5de1..a0fc9f3fc9 100644 --- a/mobile/openapi/lib/api.dart +++ b/mobile/openapi/lib/api.dart @@ -61,6 +61,7 @@ part 'model/activity_response_dto.dart'; part 'model/activity_statistics_response_dto.dart'; part 'model/add_users_dto.dart'; part 'model/album_count_response_dto.dart'; +part 'model/album_permission_response_dto.dart'; part 'model/album_response_dto.dart'; part 'model/all_job_status_response_dto.dart'; part 'model/asset_bulk_delete_dto.dart'; diff --git a/mobile/openapi/lib/api_client.dart b/mobile/openapi/lib/api_client.dart index 757f475683..982ede489d 100644 --- a/mobile/openapi/lib/api_client.dart +++ b/mobile/openapi/lib/api_client.dart @@ -200,6 +200,8 @@ class ApiClient { return AddUsersDto.fromJson(value); case 'AlbumCountResponseDto': return AlbumCountResponseDto.fromJson(value); + case 'AlbumPermissionResponseDto': + return AlbumPermissionResponseDto.fromJson(value); case 'AlbumResponseDto': return AlbumResponseDto.fromJson(value); case 'AllJobStatusResponseDto': diff --git a/mobile/openapi/lib/model/album_permission_response_dto.dart b/mobile/openapi/lib/model/album_permission_response_dto.dart new file mode 100644 index 0000000000..6c33ab7f74 --- /dev/null +++ b/mobile/openapi/lib/model/album_permission_response_dto.dart @@ -0,0 +1,106 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +part of openapi.api; + +class AlbumPermissionResponseDto { + /// Returns a new [AlbumPermissionResponseDto] instance. + AlbumPermissionResponseDto({ + required this.readonly, + required this.user, + }); + + bool readonly; + + UserResponseDto user; + + @override + bool operator ==(Object other) => identical(this, other) || other is AlbumPermissionResponseDto && + other.readonly == readonly && + other.user == user; + + @override + int get hashCode => + // ignore: unnecessary_parenthesis + (readonly.hashCode) + + (user.hashCode); + + @override + String toString() => 'AlbumPermissionResponseDto[readonly=$readonly, user=$user]'; + + Map toJson() { + final json = {}; + json[r'readonly'] = this.readonly; + json[r'user'] = this.user; + return json; + } + + /// Returns a new [AlbumPermissionResponseDto] instance and imports its values from + /// [value] if it's a [Map], null otherwise. + // ignore: prefer_constructors_over_static_methods + static AlbumPermissionResponseDto? fromJson(dynamic value) { + if (value is Map) { + final json = value.cast(); + + return AlbumPermissionResponseDto( + readonly: mapValueOfType(json, r'readonly')!, + user: UserResponseDto.fromJson(json[r'user'])!, + ); + } + return null; + } + + static List listFromJson(dynamic json, {bool growable = false,}) { + final result = []; + if (json is List && json.isNotEmpty) { + for (final row in json) { + final value = AlbumPermissionResponseDto.fromJson(row); + if (value != null) { + result.add(value); + } + } + } + return result.toList(growable: growable); + } + + static Map mapFromJson(dynamic json) { + final map = {}; + if (json is Map && json.isNotEmpty) { + json = json.cast(); // ignore: parameter_assignments + for (final entry in json.entries) { + final value = AlbumPermissionResponseDto.fromJson(entry.value); + if (value != null) { + map[entry.key] = value; + } + } + } + return map; + } + + // maps a json object with a list of AlbumPermissionResponseDto-objects as value to a dart map + static Map> mapListFromJson(dynamic json, {bool growable = false,}) { + final map = >{}; + if (json is Map && json.isNotEmpty) { + // ignore: parameter_assignments + json = json.cast(); + for (final entry in json.entries) { + map[entry.key] = AlbumPermissionResponseDto.listFromJson(entry.value, growable: growable,); + } + } + return map; + } + + /// The list of required keys that must be present in a JSON. + static const requiredKeys = { + 'readonly', + 'user', + }; +} + diff --git a/mobile/openapi/lib/model/album_response_dto.dart b/mobile/openapi/lib/model/album_response_dto.dart index d764028558..890cf4c008 100644 --- a/mobile/openapi/lib/model/album_response_dto.dart +++ b/mobile/openapi/lib/model/album_response_dto.dart @@ -14,6 +14,7 @@ class AlbumResponseDto { /// Returns a new [AlbumResponseDto] instance. AlbumResponseDto({ required this.albumName, + this.albumPermissions = const [], required this.albumThumbnailAssetId, required this.assetCount, this.assets = const [], @@ -35,6 +36,8 @@ class AlbumResponseDto { String albumName; + List albumPermissions; + String? albumThumbnailAssetId; int assetCount; @@ -81,6 +84,7 @@ class AlbumResponseDto { bool shared; + /// Deprecated in favor of albumPermissions List sharedUsers; /// @@ -96,6 +100,7 @@ class AlbumResponseDto { @override bool operator ==(Object other) => identical(this, other) || other is AlbumResponseDto && other.albumName == albumName && + _deepEquality.equals(other.albumPermissions, albumPermissions) && other.albumThumbnailAssetId == albumThumbnailAssetId && other.assetCount == assetCount && _deepEquality.equals(other.assets, assets) && @@ -118,6 +123,7 @@ class AlbumResponseDto { int get hashCode => // ignore: unnecessary_parenthesis (albumName.hashCode) + + (albumPermissions.hashCode) + (albumThumbnailAssetId == null ? 0 : albumThumbnailAssetId!.hashCode) + (assetCount.hashCode) + (assets.hashCode) + @@ -137,11 +143,12 @@ class AlbumResponseDto { (updatedAt.hashCode); @override - String toString() => 'AlbumResponseDto[albumName=$albumName, albumThumbnailAssetId=$albumThumbnailAssetId, assetCount=$assetCount, assets=$assets, createdAt=$createdAt, description=$description, endDate=$endDate, hasSharedLink=$hasSharedLink, id=$id, isActivityEnabled=$isActivityEnabled, lastModifiedAssetTimestamp=$lastModifiedAssetTimestamp, order=$order, owner=$owner, ownerId=$ownerId, shared=$shared, sharedUsers=$sharedUsers, startDate=$startDate, updatedAt=$updatedAt]'; + String toString() => 'AlbumResponseDto[albumName=$albumName, albumPermissions=$albumPermissions, albumThumbnailAssetId=$albumThumbnailAssetId, assetCount=$assetCount, assets=$assets, createdAt=$createdAt, description=$description, endDate=$endDate, hasSharedLink=$hasSharedLink, id=$id, isActivityEnabled=$isActivityEnabled, lastModifiedAssetTimestamp=$lastModifiedAssetTimestamp, order=$order, owner=$owner, ownerId=$ownerId, shared=$shared, sharedUsers=$sharedUsers, startDate=$startDate, updatedAt=$updatedAt]'; Map toJson() { final json = {}; json[r'albumName'] = this.albumName; + json[r'albumPermissions'] = this.albumPermissions; if (this.albumThumbnailAssetId != null) { json[r'albumThumbnailAssetId'] = this.albumThumbnailAssetId; } else { @@ -191,6 +198,7 @@ class AlbumResponseDto { return AlbumResponseDto( albumName: mapValueOfType(json, r'albumName')!, + albumPermissions: AlbumPermissionResponseDto.listFromJson(json[r'albumPermissions']), albumThumbnailAssetId: mapValueOfType(json, r'albumThumbnailAssetId'), assetCount: mapValueOfType(json, r'assetCount')!, assets: AssetResponseDto.listFromJson(json[r'assets']), @@ -256,6 +264,7 @@ class AlbumResponseDto { /// The list of required keys that must be present in a JSON. static const requiredKeys = { 'albumName', + 'albumPermissions', 'albumThumbnailAssetId', 'assetCount', 'assets', diff --git a/mobile/openapi/test/album_permission_response_dto_test.dart b/mobile/openapi/test/album_permission_response_dto_test.dart new file mode 100644 index 0000000000..b56ce52b14 --- /dev/null +++ b/mobile/openapi/test/album_permission_response_dto_test.dart @@ -0,0 +1,32 @@ +// +// AUTO-GENERATED FILE, DO NOT MODIFY! +// +// @dart=2.12 + +// ignore_for_file: unused_element, unused_import +// ignore_for_file: always_put_required_named_parameters_first +// ignore_for_file: constant_identifier_names +// ignore_for_file: lines_longer_than_80_chars + +import 'package:openapi/api.dart'; +import 'package:test/test.dart'; + +// tests for AlbumPermissionResponseDto +void main() { + // final instance = AlbumPermissionResponseDto(); + + group('test AlbumPermissionResponseDto', () { + // bool readonly + test('to test the property `readonly`', () async { + // TODO + }); + + // UserResponseDto user + test('to test the property `user`', () async { + // TODO + }); + + + }); + +} diff --git a/mobile/openapi/test/album_response_dto_test.dart b/mobile/openapi/test/album_response_dto_test.dart index 5c79e5d2fc..7426a6d84d 100644 --- a/mobile/openapi/test/album_response_dto_test.dart +++ b/mobile/openapi/test/album_response_dto_test.dart @@ -21,6 +21,11 @@ void main() { // TODO }); + // List albumPermissions (default value: const []) + test('to test the property `albumPermissions`', () async { + // TODO + }); + // String albumThumbnailAssetId test('to test the property `albumThumbnailAssetId`', () async { // TODO @@ -91,6 +96,7 @@ void main() { // TODO }); + // Deprecated in favor of albumPermissions // List sharedUsers (default value: const []) test('to test the property `sharedUsers`', () async { // TODO diff --git a/open-api/immich-openapi-specs.json b/open-api/immich-openapi-specs.json index 38df22f00e..4fbbeffb4b 100644 --- a/open-api/immich-openapi-specs.json +++ b/open-api/immich-openapi-specs.json @@ -7065,11 +7065,32 @@ ], "type": "object" }, + "AlbumPermissionResponseDto": { + "properties": { + "readonly": { + "type": "boolean" + }, + "user": { + "$ref": "#/components/schemas/UserResponseDto" + } + }, + "required": [ + "readonly", + "user" + ], + "type": "object" + }, "AlbumResponseDto": { "properties": { "albumName": { "type": "string" }, + "albumPermissions": { + "items": { + "$ref": "#/components/schemas/AlbumPermissionResponseDto" + }, + "type": "array" + }, "albumThumbnailAssetId": { "nullable": true, "type": "string" @@ -7120,6 +7141,8 @@ "type": "boolean" }, "sharedUsers": { + "deprecated": true, + "description": "Deprecated in favor of albumPermissions", "items": { "$ref": "#/components/schemas/UserResponseDto" }, @@ -7136,6 +7159,7 @@ }, "required": [ "albumName", + "albumPermissions", "albumThumbnailAssetId", "assetCount", "assets", diff --git a/open-api/typescript-sdk/src/fetch-client.ts b/open-api/typescript-sdk/src/fetch-client.ts index 999fa23fa6..f194953443 100644 --- a/open-api/typescript-sdk/src/fetch-client.ts +++ b/open-api/typescript-sdk/src/fetch-client.ts @@ -38,6 +38,28 @@ export type ActivityCreateDto = { export type ActivityStatisticsResponseDto = { comments: number; }; +export type UserResponseDto = { + avatarColor: UserAvatarColor; + createdAt: string; + deletedAt: string | null; + email: string; + id: string; + isAdmin: boolean; + memoriesEnabled?: boolean; + name: string; + oauthId: string; + profileImagePath: string; + quotaSizeInBytes: number | null; + quotaUsageInBytes: number | null; + shouldChangePassword: boolean; + status: UserStatus; + storageLabel: string | null; + updatedAt: string; +}; +export type AlbumPermissionResponseDto = { + "readonly": boolean; + user: UserResponseDto; +}; export type ExifResponseDto = { city?: string | null; country?: string | null; @@ -61,24 +83,6 @@ export type ExifResponseDto = { state?: string | null; timeZone?: string | null; }; -export type UserResponseDto = { - avatarColor: UserAvatarColor; - createdAt: string; - deletedAt: string | null; - email: string; - id: string; - isAdmin: boolean; - memoriesEnabled?: boolean; - name: string; - oauthId: string; - profileImagePath: string; - quotaSizeInBytes: number | null; - quotaUsageInBytes: number | null; - shouldChangePassword: boolean; - status: UserStatus; - storageLabel: string | null; - updatedAt: string; -}; export type AssetFaceWithoutPersonResponseDto = { boundingBoxX1: number; boundingBoxX2: number; @@ -143,6 +147,7 @@ export type AssetResponseDto = { }; export type AlbumResponseDto = { albumName: string; + albumPermissions: AlbumPermissionResponseDto[]; albumThumbnailAssetId: string | null; assetCount: number; assets: AssetResponseDto[]; @@ -157,6 +162,7 @@ export type AlbumResponseDto = { owner: UserResponseDto; ownerId: string; shared: boolean; + /** Deprecated in favor of albumPermissions */ sharedUsers: UserResponseDto[]; startDate?: string; updatedAt: string;