diff --git a/mobile/lib/entities/album.entity.dart b/mobile/lib/entities/album.entity.dart index 791aca182b..0007735158 100644 --- a/mobile/lib/entities/album.entity.dart +++ b/mobile/lib/entities/album.entity.dart @@ -163,8 +163,7 @@ class Album { dto.order == AssetOrder.asc ? SortOrder.asc : SortOrder.desc; } - if (dto.albumThumbnailAssetId != null && - dto.albumThumbnailAssetId!.isSome) { + if (dto.albumThumbnailAssetId?.unwrapOrNull() != null) { a.thumbnail.value = await db.assets .where() .remoteIdEqualTo(dto.albumThumbnailAssetId!.unwrap()) diff --git a/mobile/lib/services/search.service.dart b/mobile/lib/services/search.service.dart index 2a20ac8c0c..ca7ebe03c1 100644 --- a/mobile/lib/services/search.service.dart +++ b/mobile/lib/services/search.service.dart @@ -62,11 +62,11 @@ class SearchService { SmartSearchDto( query: filter.context!, language: filter.language, - country: Option.from(filter.location.country), - state: Option.from(filter.location.state), - city: Option.from(filter.location.city), + country: Some.tryFrom(filter.location.country), + state: Some.tryFrom(filter.location.state), + city: Some.tryFrom(filter.location.city), make: filter.camera.make, - model: Option.from(filter.camera.model), + model: Some.tryFrom(filter.camera.model), takenAfter: filter.date.takenAfter, takenBefore: filter.date.takenBefore, visibility: filter.display.isArchive @@ -87,15 +87,15 @@ class SearchService { filter.filename != null && filter.filename!.isNotEmpty ? filter.filename : null, - country: Option.from(filter.location.country), + country: Some.tryFrom(filter.location.country), description: filter.description != null && filter.description!.isNotEmpty ? filter.description : null, - state: Option.from(filter.location.state), - city: Option.from(filter.location.city), + state: Some.tryFrom(filter.location.state), + city: Some.tryFrom(filter.location.city), make: filter.camera.make, - model: Option.from(filter.camera.model), + model: Some.tryFrom(filter.camera.model), takenAfter: filter.date.takenAfter, takenBefore: filter.date.takenBefore, visibility: filter.display.isArchive diff --git a/mobile/lib/services/shared_link.service.dart b/mobile/lib/services/shared_link.service.dart index 83f0a5659b..2e6bc13da3 100644 --- a/mobile/lib/services/shared_link.service.dart +++ b/mobile/lib/services/shared_link.service.dart @@ -57,7 +57,7 @@ class SharedLinkService { showMetadata: showMeta, allowDownload: allowDownload, allowUpload: allowUpload, - expiresAt: Option.from(expiresAt), + expiresAt: Some.tryFrom(expiresAt), description: description, password: password, ); @@ -67,7 +67,7 @@ class SharedLinkService { showMetadata: showMeta, allowDownload: allowDownload, allowUpload: allowUpload, - expiresAt: Option.from(expiresAt), + expiresAt: Some.tryFrom(expiresAt), description: description, password: password, assetIds: assetIds, @@ -104,7 +104,7 @@ class SharedLinkService { showMetadata: showMeta, allowDownload: allowDownload, allowUpload: allowUpload, - expiresAt: Option.from(expiresAt), + expiresAt: Some.tryFrom(expiresAt), description: description, password: password, changeExpiryTime: changeExpiry, diff --git a/mobile/lib/utils/option.dart b/mobile/lib/utils/option.dart index 79e26a15c4..f09f18b253 100644 --- a/mobile/lib/utils/option.dart +++ b/mobile/lib/utils/option.dart @@ -66,6 +66,13 @@ class Some extends Option { final T value; const Some(this.value); + + static Some? tryFrom(U? value) { + if (value == null) { + return null; + } + return Some(value); + } } class None extends Option { diff --git a/mobile/openapi/lib/model/activity_response_dto.dart b/mobile/openapi/lib/model/activity_response_dto.dart index da6f0bc87a..76da4416e7 100644 --- a/mobile/openapi/lib/model/activity_response_dto.dart +++ b/mobile/openapi/lib/model/activity_response_dto.dart @@ -87,8 +87,8 @@ class ActivityResponseDto { final json = value.cast(); return ActivityResponseDto( - assetId: Option.from(mapValueOfType(json, r'assetId')), - comment: Option.from(mapValueOfType(json, r'comment')), + assetId: Some.tryFrom(mapValueOfType(json, r'assetId')), + comment: Some.tryFrom(mapValueOfType(json, r'comment')), createdAt: mapDateTime(json, r'createdAt', r'')!, id: mapValueOfType(json, r'id')!, type: ReactionType.fromJson(json[r'type'])!, diff --git a/mobile/openapi/lib/model/album_response_dto.dart b/mobile/openapi/lib/model/album_response_dto.dart index 5f03c3f09f..5a1235dfd5 100644 --- a/mobile/openapi/lib/model/album_response_dto.dart +++ b/mobile/openapi/lib/model/album_response_dto.dart @@ -194,7 +194,7 @@ class AlbumResponseDto { return AlbumResponseDto( albumName: mapValueOfType(json, r'albumName')!, - albumThumbnailAssetId: Option.from(mapValueOfType(json, r'albumThumbnailAssetId')), + albumThumbnailAssetId: Some.tryFrom(mapValueOfType(json, r'albumThumbnailAssetId')), albumUsers: AlbumUserResponseDto.listFromJson(json[r'albumUsers']), assetCount: mapValueOfType(json, r'assetCount')!, assets: AssetResponseDto.listFromJson(json[r'assets']), diff --git a/mobile/openapi/lib/model/asset_bulk_update_dto.dart b/mobile/openapi/lib/model/asset_bulk_update_dto.dart index 2fb0d05e2f..46296f6f65 100644 --- a/mobile/openapi/lib/model/asset_bulk_update_dto.dart +++ b/mobile/openapi/lib/model/asset_bulk_update_dto.dart @@ -156,7 +156,7 @@ class AssetBulkUpdateDto { return AssetBulkUpdateDto( dateTimeOriginal: mapValueOfType(json, r'dateTimeOriginal'), - duplicateId: Option.from(mapValueOfType(json, r'duplicateId')), + duplicateId: Some.tryFrom(mapValueOfType(json, r'duplicateId')), ids: json[r'ids'] is Iterable ? (json[r'ids'] as Iterable).cast().toList(growable: false) : const [], diff --git a/mobile/openapi/lib/model/asset_face_response_dto.dart b/mobile/openapi/lib/model/asset_face_response_dto.dart index 3ef83f80e3..fbc978933f 100644 --- a/mobile/openapi/lib/model/asset_face_response_dto.dart +++ b/mobile/openapi/lib/model/asset_face_response_dto.dart @@ -116,7 +116,7 @@ class AssetFaceResponseDto { id: mapValueOfType(json, r'id')!, imageHeight: mapValueOfType(json, r'imageHeight')!, imageWidth: mapValueOfType(json, r'imageWidth')!, - person: Option.from(PersonResponseDto.fromJson(json[r'person'])), + person: Some.tryFrom(PersonResponseDto.fromJson(json[r'person'])), sourceType: SourceType.fromJson(json[r'sourceType']), ); } diff --git a/mobile/openapi/lib/model/asset_response_dto.dart b/mobile/openapi/lib/model/asset_response_dto.dart index 0a2a4f1464..68c8969c04 100644 --- a/mobile/openapi/lib/model/asset_response_dto.dart +++ b/mobile/openapi/lib/model/asset_response_dto.dart @@ -301,7 +301,7 @@ class AssetResponseDto { checksum: mapValueOfType(json, r'checksum')!, deviceAssetId: mapValueOfType(json, r'deviceAssetId')!, deviceId: mapValueOfType(json, r'deviceId')!, - duplicateId: Option.from(mapValueOfType(json, r'duplicateId')), + duplicateId: Some.tryFrom(mapValueOfType(json, r'duplicateId')), duration: mapValueOfType(json, r'duration')!, exifInfo: ExifResponseDto.fromJson(json[r'exifInfo']), fileCreatedAt: mapDateTime(json, r'fileCreatedAt', r'')!, @@ -312,8 +312,8 @@ class AssetResponseDto { isFavorite: mapValueOfType(json, r'isFavorite')!, isOffline: mapValueOfType(json, r'isOffline')!, isTrashed: mapValueOfType(json, r'isTrashed')!, - libraryId: Option.from(mapValueOfType(json, r'libraryId')), - livePhotoVideoId: Option.from(mapValueOfType(json, r'livePhotoVideoId')), + libraryId: Some.tryFrom(mapValueOfType(json, r'libraryId')), + livePhotoVideoId: Some.tryFrom(mapValueOfType(json, r'livePhotoVideoId')), localDateTime: mapDateTime(json, r'localDateTime', r'')!, originalFileName: mapValueOfType(json, r'originalFileName')!, originalMimeType: mapValueOfType(json, r'originalMimeType'), @@ -322,9 +322,9 @@ class AssetResponseDto { ownerId: mapValueOfType(json, r'ownerId')!, people: PersonWithFacesResponseDto.listFromJson(json[r'people']), resized: mapValueOfType(json, r'resized'), - stack: Option.from(AssetStackResponseDto.fromJson(json[r'stack'])), + stack: Some.tryFrom(AssetStackResponseDto.fromJson(json[r'stack'])), tags: TagResponseDto.listFromJson(json[r'tags']), - thumbhash: Option.from(mapValueOfType(json, r'thumbhash')), + thumbhash: Some.tryFrom(mapValueOfType(json, r'thumbhash')), type: AssetTypeEnum.fromJson(json[r'type'])!, unassignedFaces: AssetFaceWithoutPersonResponseDto.listFromJson(json[r'unassignedFaces']), updatedAt: mapDateTime(json, r'updatedAt', r'')!, diff --git a/mobile/openapi/lib/model/exif_response_dto.dart b/mobile/openapi/lib/model/exif_response_dto.dart index d6449e40ef..1281529193 100644 --- a/mobile/openapi/lib/model/exif_response_dto.dart +++ b/mobile/openapi/lib/model/exif_response_dto.dart @@ -303,44 +303,44 @@ class ExifResponseDto { final json = value.cast(); return ExifResponseDto( - city: Option.from(mapValueOfType(json, r'city')), - country: Option.from(mapValueOfType(json, r'country')), - dateTimeOriginal: Option.from(mapDateTime(json, r'dateTimeOriginal', r'')), - description: Option.from(mapValueOfType(json, r'description')), - exifImageHeight: Option.from(json[r'exifImageHeight'] == null + city: Some.tryFrom(mapValueOfType(json, r'city')), + country: Some.tryFrom(mapValueOfType(json, r'country')), + dateTimeOriginal: Some.tryFrom(mapDateTime(json, r'dateTimeOriginal', r'')), + description: Some.tryFrom(mapValueOfType(json, r'description')), + exifImageHeight: Some.tryFrom(json[r'exifImageHeight'] == null ? null : num.parse('${json[r'exifImageHeight']}')), - exifImageWidth: Option.from(json[r'exifImageWidth'] == null + exifImageWidth: Some.tryFrom(json[r'exifImageWidth'] == null ? null : num.parse('${json[r'exifImageWidth']}')), - exposureTime: Option.from(mapValueOfType(json, r'exposureTime')), - fNumber: Option.from(json[r'fNumber'] == null + exposureTime: Some.tryFrom(mapValueOfType(json, r'exposureTime')), + fNumber: Some.tryFrom(json[r'fNumber'] == null ? null : num.parse('${json[r'fNumber']}')), - fileSizeInByte: Option.from(mapValueOfType(json, r'fileSizeInByte')), - focalLength: Option.from(json[r'focalLength'] == null + fileSizeInByte: Some.tryFrom(mapValueOfType(json, r'fileSizeInByte')), + focalLength: Some.tryFrom(json[r'focalLength'] == null ? null : num.parse('${json[r'focalLength']}')), - iso: Option.from(json[r'iso'] == null + iso: Some.tryFrom(json[r'iso'] == null ? null : num.parse('${json[r'iso']}')), - latitude: Option.from(json[r'latitude'] == null + latitude: Some.tryFrom(json[r'latitude'] == null ? null : num.parse('${json[r'latitude']}')), - lensModel: Option.from(mapValueOfType(json, r'lensModel')), - longitude: Option.from(json[r'longitude'] == null + lensModel: Some.tryFrom(mapValueOfType(json, r'lensModel')), + longitude: Some.tryFrom(json[r'longitude'] == null ? null : num.parse('${json[r'longitude']}')), - make: Option.from(mapValueOfType(json, r'make')), - model: Option.from(mapValueOfType(json, r'model')), - modifyDate: Option.from(mapDateTime(json, r'modifyDate', r'')), - orientation: Option.from(mapValueOfType(json, r'orientation')), - projectionType: Option.from(mapValueOfType(json, r'projectionType')), - rating: Option.from(json[r'rating'] == null + make: Some.tryFrom(mapValueOfType(json, r'make')), + model: Some.tryFrom(mapValueOfType(json, r'model')), + modifyDate: Some.tryFrom(mapDateTime(json, r'modifyDate', r'')), + orientation: Some.tryFrom(mapValueOfType(json, r'orientation')), + projectionType: Some.tryFrom(mapValueOfType(json, r'projectionType')), + rating: Some.tryFrom(json[r'rating'] == null ? null : num.parse('${json[r'rating']}')), - state: Option.from(mapValueOfType(json, r'state')), - timeZone: Option.from(mapValueOfType(json, r'timeZone')), + state: Some.tryFrom(mapValueOfType(json, r'state')), + timeZone: Some.tryFrom(mapValueOfType(json, r'timeZone')), ); } return null; diff --git a/mobile/openapi/lib/model/library_response_dto.dart b/mobile/openapi/lib/model/library_response_dto.dart index daf679fa84..6ec82c8d53 100644 --- a/mobile/openapi/lib/model/library_response_dto.dart +++ b/mobile/openapi/lib/model/library_response_dto.dart @@ -110,7 +110,7 @@ class LibraryResponseDto { : const [], name: mapValueOfType(json, r'name')!, ownerId: mapValueOfType(json, r'ownerId')!, - refreshedAt: Option.from(mapDateTime(json, r'refreshedAt', r'')), + refreshedAt: Some.tryFrom(mapDateTime(json, r'refreshedAt', r'')), updatedAt: mapDateTime(json, r'updatedAt', r'')!, ); } diff --git a/mobile/openapi/lib/model/map_marker_response_dto.dart b/mobile/openapi/lib/model/map_marker_response_dto.dart index 6fc6f4a163..b8a7ed0e9f 100644 --- a/mobile/openapi/lib/model/map_marker_response_dto.dart +++ b/mobile/openapi/lib/model/map_marker_response_dto.dart @@ -93,12 +93,12 @@ class MapMarkerResponseDto { final json = value.cast(); return MapMarkerResponseDto( - city: Option.from(mapValueOfType(json, r'city')), - country: Option.from(mapValueOfType(json, r'country')), + city: Some.tryFrom(mapValueOfType(json, r'city')), + country: Some.tryFrom(mapValueOfType(json, r'country')), id: mapValueOfType(json, r'id')!, lat: (mapValueOfType(json, r'lat')!).toDouble(), lon: (mapValueOfType(json, r'lon')!).toDouble(), - state: Option.from(mapValueOfType(json, r'state')), + state: Some.tryFrom(mapValueOfType(json, r'state')), ); } return null; diff --git a/mobile/openapi/lib/model/map_reverse_geocode_response_dto.dart b/mobile/openapi/lib/model/map_reverse_geocode_response_dto.dart index 824b667c6e..775ed1ecbe 100644 --- a/mobile/openapi/lib/model/map_reverse_geocode_response_dto.dart +++ b/mobile/openapi/lib/model/map_reverse_geocode_response_dto.dart @@ -75,9 +75,9 @@ class MapReverseGeocodeResponseDto { final json = value.cast(); return MapReverseGeocodeResponseDto( - city: Option.from(mapValueOfType(json, r'city')), - country: Option.from(mapValueOfType(json, r'country')), - state: Option.from(mapValueOfType(json, r'state')), + city: Some.tryFrom(mapValueOfType(json, r'city')), + country: Some.tryFrom(mapValueOfType(json, r'country')), + state: Some.tryFrom(mapValueOfType(json, r'state')), ); } return null; diff --git a/mobile/openapi/lib/model/metadata_search_dto.dart b/mobile/openapi/lib/model/metadata_search_dto.dart index 60871e9f10..c416c45d6c 100644 --- a/mobile/openapi/lib/model/metadata_search_dto.dart +++ b/mobile/openapi/lib/model/metadata_search_dto.dart @@ -663,8 +663,8 @@ class MetadataSearchDto { return MetadataSearchDto( checksum: mapValueOfType(json, r'checksum'), - city: Option.from(mapValueOfType(json, r'city')), - country: Option.from(mapValueOfType(json, r'country')), + city: Some.tryFrom(mapValueOfType(json, r'city')), + country: Some.tryFrom(mapValueOfType(json, r'country')), createdAfter: mapDateTime(json, r'createdAfter', r''), createdBefore: mapDateTime(json, r'createdBefore', r''), description: mapValueOfType(json, r'description'), @@ -677,10 +677,10 @@ class MetadataSearchDto { isMotion: mapValueOfType(json, r'isMotion'), isNotInAlbum: mapValueOfType(json, r'isNotInAlbum'), isOffline: mapValueOfType(json, r'isOffline'), - lensModel: Option.from(mapValueOfType(json, r'lensModel')), - libraryId: Option.from(mapValueOfType(json, r'libraryId')), + lensModel: Some.tryFrom(mapValueOfType(json, r'lensModel')), + libraryId: Some.tryFrom(mapValueOfType(json, r'libraryId')), make: mapValueOfType(json, r'make'), - model: Option.from(mapValueOfType(json, r'model')), + model: Some.tryFrom(mapValueOfType(json, r'model')), order: AssetOrder.fromJson(json[r'order']) ?? AssetOrder.desc, originalFileName: mapValueOfType(json, r'originalFileName'), originalPath: mapValueOfType(json, r'originalPath'), @@ -691,7 +691,7 @@ class MetadataSearchDto { previewPath: mapValueOfType(json, r'previewPath'), rating: num.parse('${json[r'rating']}'), size: num.parse('${json[r'size']}'), - state: Option.from(mapValueOfType(json, r'state')), + state: Some.tryFrom(mapValueOfType(json, r'state')), tagIds: json[r'tagIds'] is Iterable ? (json[r'tagIds'] as Iterable).cast().toList(growable: false) : const [], diff --git a/mobile/openapi/lib/model/notification_create_dto.dart b/mobile/openapi/lib/model/notification_create_dto.dart index a9a03fea3d..1799527254 100644 --- a/mobile/openapi/lib/model/notification_create_dto.dart +++ b/mobile/openapi/lib/model/notification_create_dto.dart @@ -124,9 +124,9 @@ class NotificationCreateDto { return NotificationCreateDto( data: mapValueOfType(json, r'data'), - description: Option.from(mapValueOfType(json, r'description')), + description: Some.tryFrom(mapValueOfType(json, r'description')), level: NotificationLevel.fromJson(json[r'level']), - readAt: Option.from(mapDateTime(json, r'readAt', r'')), + readAt: Some.tryFrom(mapDateTime(json, r'readAt', r'')), title: mapValueOfType(json, r'title')!, type: NotificationType.fromJson(json[r'type']), userId: mapValueOfType(json, r'userId')!, diff --git a/mobile/openapi/lib/model/notification_update_all_dto.dart b/mobile/openapi/lib/model/notification_update_all_dto.dart index 2228f22806..e08c251b9e 100644 --- a/mobile/openapi/lib/model/notification_update_all_dto.dart +++ b/mobile/openapi/lib/model/notification_update_all_dto.dart @@ -60,7 +60,7 @@ class NotificationUpdateAllDto { ids: json[r'ids'] is Iterable ? (json[r'ids'] as Iterable).cast().toList(growable: false) : const [], - readAt: Option.from(mapDateTime(json, r'readAt', r'')), + readAt: Some.tryFrom(mapDateTime(json, r'readAt', r'')), ); } return null; diff --git a/mobile/openapi/lib/model/notification_update_dto.dart b/mobile/openapi/lib/model/notification_update_dto.dart index 74e922c7f6..569b52e6b6 100644 --- a/mobile/openapi/lib/model/notification_update_dto.dart +++ b/mobile/openapi/lib/model/notification_update_dto.dart @@ -51,7 +51,7 @@ class NotificationUpdateDto { final json = value.cast(); return NotificationUpdateDto( - readAt: Option.from(mapDateTime(json, r'readAt', r'')), + readAt: Some.tryFrom(mapDateTime(json, r'readAt', r'')), ); } return null; diff --git a/mobile/openapi/lib/model/people_update_item.dart b/mobile/openapi/lib/model/people_update_item.dart index 43071e622a..c0a59103fb 100644 --- a/mobile/openapi/lib/model/people_update_item.dart +++ b/mobile/openapi/lib/model/people_update_item.dart @@ -138,8 +138,8 @@ class PeopleUpdateItem { final json = value.cast(); return PeopleUpdateItem( - birthDate: Option.from(mapDateTime(json, r'birthDate', r'')), - color: Option.from(mapValueOfType(json, r'color')), + birthDate: Some.tryFrom(mapDateTime(json, r'birthDate', r'')), + color: Some.tryFrom(mapValueOfType(json, r'color')), featureFaceAssetId: mapValueOfType(json, r'featureFaceAssetId'), id: mapValueOfType(json, r'id')!, isFavorite: mapValueOfType(json, r'isFavorite'), diff --git a/mobile/openapi/lib/model/person_create_dto.dart b/mobile/openapi/lib/model/person_create_dto.dart index 1b2a65bd95..be1f95de2b 100644 --- a/mobile/openapi/lib/model/person_create_dto.dart +++ b/mobile/openapi/lib/model/person_create_dto.dart @@ -114,8 +114,8 @@ class PersonCreateDto { final json = value.cast(); return PersonCreateDto( - birthDate: Option.from(mapDateTime(json, r'birthDate', r'')), - color: Option.from(mapValueOfType(json, r'color')), + birthDate: Some.tryFrom(mapDateTime(json, r'birthDate', r'')), + color: Some.tryFrom(mapValueOfType(json, r'color')), isFavorite: mapValueOfType(json, r'isFavorite'), isHidden: mapValueOfType(json, r'isHidden'), name: mapValueOfType(json, r'name'), diff --git a/mobile/openapi/lib/model/person_response_dto.dart b/mobile/openapi/lib/model/person_response_dto.dart index 8e3cf419fc..3ab1db9315 100644 --- a/mobile/openapi/lib/model/person_response_dto.dart +++ b/mobile/openapi/lib/model/person_response_dto.dart @@ -126,7 +126,7 @@ class PersonResponseDto { final json = value.cast(); return PersonResponseDto( - birthDate: Option.from(mapDateTime(json, r'birthDate', r'')), + birthDate: Some.tryFrom(mapDateTime(json, r'birthDate', r'')), color: mapValueOfType(json, r'color'), id: mapValueOfType(json, r'id')!, isFavorite: mapValueOfType(json, r'isFavorite'), diff --git a/mobile/openapi/lib/model/person_update_dto.dart b/mobile/openapi/lib/model/person_update_dto.dart index 92d9e88daf..18065dd94a 100644 --- a/mobile/openapi/lib/model/person_update_dto.dart +++ b/mobile/openapi/lib/model/person_update_dto.dart @@ -131,8 +131,8 @@ class PersonUpdateDto { final json = value.cast(); return PersonUpdateDto( - birthDate: Option.from(mapDateTime(json, r'birthDate', r'')), - color: Option.from(mapValueOfType(json, r'color')), + birthDate: Some.tryFrom(mapDateTime(json, r'birthDate', r'')), + color: Some.tryFrom(mapValueOfType(json, r'color')), featureFaceAssetId: mapValueOfType(json, r'featureFaceAssetId'), isFavorite: mapValueOfType(json, r'isFavorite'), isHidden: mapValueOfType(json, r'isHidden'), diff --git a/mobile/openapi/lib/model/person_with_faces_response_dto.dart b/mobile/openapi/lib/model/person_with_faces_response_dto.dart index 963c102a69..d7c9204d1b 100644 --- a/mobile/openapi/lib/model/person_with_faces_response_dto.dart +++ b/mobile/openapi/lib/model/person_with_faces_response_dto.dart @@ -132,7 +132,7 @@ class PersonWithFacesResponseDto { final json = value.cast(); return PersonWithFacesResponseDto( - birthDate: Option.from(mapDateTime(json, r'birthDate', r'')), + birthDate: Some.tryFrom(mapDateTime(json, r'birthDate', r'')), color: mapValueOfType(json, r'color'), faces: AssetFaceWithoutPersonResponseDto.listFromJson(json[r'faces']), id: mapValueOfType(json, r'id')!, diff --git a/mobile/openapi/lib/model/random_search_dto.dart b/mobile/openapi/lib/model/random_search_dto.dart index 1263c8a2b4..c244be6127 100644 --- a/mobile/openapi/lib/model/random_search_dto.dart +++ b/mobile/openapi/lib/model/random_search_dto.dart @@ -495,8 +495,8 @@ class RandomSearchDto { final json = value.cast(); return RandomSearchDto( - city: Option.from(mapValueOfType(json, r'city')), - country: Option.from(mapValueOfType(json, r'country')), + city: Some.tryFrom(mapValueOfType(json, r'city')), + country: Some.tryFrom(mapValueOfType(json, r'country')), createdAfter: mapDateTime(json, r'createdAfter', r''), createdBefore: mapDateTime(json, r'createdBefore', r''), deviceId: mapValueOfType(json, r'deviceId'), @@ -505,16 +505,16 @@ class RandomSearchDto { isMotion: mapValueOfType(json, r'isMotion'), isNotInAlbum: mapValueOfType(json, r'isNotInAlbum'), isOffline: mapValueOfType(json, r'isOffline'), - lensModel: Option.from(mapValueOfType(json, r'lensModel')), - libraryId: Option.from(mapValueOfType(json, r'libraryId')), + lensModel: Some.tryFrom(mapValueOfType(json, r'lensModel')), + libraryId: Some.tryFrom(mapValueOfType(json, r'libraryId')), make: mapValueOfType(json, r'make'), - model: Option.from(mapValueOfType(json, r'model')), + model: Some.tryFrom(mapValueOfType(json, r'model')), personIds: json[r'personIds'] is Iterable ? (json[r'personIds'] as Iterable).cast().toList(growable: false) : const [], rating: num.parse('${json[r'rating']}'), size: num.parse('${json[r'size']}'), - state: Option.from(mapValueOfType(json, r'state')), + state: Some.tryFrom(mapValueOfType(json, r'state')), tagIds: json[r'tagIds'] is Iterable ? (json[r'tagIds'] as Iterable).cast().toList(growable: false) : const [], diff --git a/mobile/openapi/lib/model/reverse_geocoding_state_response_dto.dart b/mobile/openapi/lib/model/reverse_geocoding_state_response_dto.dart index 132ce2ea12..a990f95e75 100644 --- a/mobile/openapi/lib/model/reverse_geocoding_state_response_dto.dart +++ b/mobile/openapi/lib/model/reverse_geocoding_state_response_dto.dart @@ -63,8 +63,8 @@ class ReverseGeocodingStateResponseDto { final json = value.cast(); return ReverseGeocodingStateResponseDto( - lastImportFileName: Option.from(mapValueOfType(json, r'lastImportFileName')), - lastUpdate: Option.from(mapValueOfType(json, r'lastUpdate')), + lastImportFileName: Some.tryFrom(mapValueOfType(json, r'lastImportFileName')), + lastUpdate: Some.tryFrom(mapValueOfType(json, r'lastUpdate')), ); } return null; diff --git a/mobile/openapi/lib/model/search_asset_response_dto.dart b/mobile/openapi/lib/model/search_asset_response_dto.dart index 7ad48d0064..9151f31b61 100644 --- a/mobile/openapi/lib/model/search_asset_response_dto.dart +++ b/mobile/openapi/lib/model/search_asset_response_dto.dart @@ -78,7 +78,7 @@ class SearchAssetResponseDto { count: mapValueOfType(json, r'count')!, facets: SearchFacetResponseDto.listFromJson(json[r'facets']), items: AssetResponseDto.listFromJson(json[r'items']), - nextPage: Option.from(mapValueOfType(json, r'nextPage')), + nextPage: Some.tryFrom(mapValueOfType(json, r'nextPage')), total: mapValueOfType(json, r'total')!, ); } diff --git a/mobile/openapi/lib/model/shared_link_create_dto.dart b/mobile/openapi/lib/model/shared_link_create_dto.dart index 18da5742f1..5d03f7b06b 100644 --- a/mobile/openapi/lib/model/shared_link_create_dto.dart +++ b/mobile/openapi/lib/model/shared_link_create_dto.dart @@ -146,7 +146,7 @@ class SharedLinkCreateDto { ? (json[r'assetIds'] as Iterable).cast().toList(growable: false) : const [], description: mapValueOfType(json, r'description'), - expiresAt: Option.from(mapDateTime(json, r'expiresAt', r'')), + expiresAt: Some.tryFrom(mapDateTime(json, r'expiresAt', r'')), password: mapValueOfType(json, r'password'), showMetadata: mapValueOfType(json, r'showMetadata') ?? true, type: SharedLinkType.fromJson(json[r'type'])!, diff --git a/mobile/openapi/lib/model/shared_link_edit_dto.dart b/mobile/openapi/lib/model/shared_link_edit_dto.dart index 2d28861e51..273c32fc7e 100644 --- a/mobile/openapi/lib/model/shared_link_edit_dto.dart +++ b/mobile/openapi/lib/model/shared_link_edit_dto.dart @@ -152,7 +152,7 @@ class SharedLinkEditDto { allowUpload: mapValueOfType(json, r'allowUpload'), changeExpiryTime: mapValueOfType(json, r'changeExpiryTime'), description: mapValueOfType(json, r'description'), - expiresAt: Option.from(mapDateTime(json, r'expiresAt', r'')), + expiresAt: Some.tryFrom(mapDateTime(json, r'expiresAt', r'')), password: mapValueOfType(json, r'password'), showMetadata: mapValueOfType(json, r'showMetadata'), ); diff --git a/mobile/openapi/lib/model/shared_link_response_dto.dart b/mobile/openapi/lib/model/shared_link_response_dto.dart index c68895997a..4a39ee92b0 100644 --- a/mobile/openapi/lib/model/shared_link_response_dto.dart +++ b/mobile/openapi/lib/model/shared_link_response_dto.dart @@ -162,13 +162,13 @@ class SharedLinkResponseDto { allowUpload: mapValueOfType(json, r'allowUpload')!, assets: AssetResponseDto.listFromJson(json[r'assets']), createdAt: mapDateTime(json, r'createdAt', r'')!, - description: Option.from(mapValueOfType(json, r'description')), - expiresAt: Option.from(mapDateTime(json, r'expiresAt', r'')), + description: Some.tryFrom(mapValueOfType(json, r'description')), + expiresAt: Some.tryFrom(mapDateTime(json, r'expiresAt', r'')), id: mapValueOfType(json, r'id')!, key: mapValueOfType(json, r'key')!, - password: Option.from(mapValueOfType(json, r'password')), + password: Some.tryFrom(mapValueOfType(json, r'password')), showMetadata: mapValueOfType(json, r'showMetadata')!, - token: Option.from(mapValueOfType(json, r'token')), + token: Some.tryFrom(mapValueOfType(json, r'token')), type: SharedLinkType.fromJson(json[r'type'])!, userId: mapValueOfType(json, r'userId')!, ); diff --git a/mobile/openapi/lib/model/smart_search_dto.dart b/mobile/openapi/lib/model/smart_search_dto.dart index 9463deb449..ad10f3e385 100644 --- a/mobile/openapi/lib/model/smart_search_dto.dart +++ b/mobile/openapi/lib/model/smart_search_dto.dart @@ -502,8 +502,8 @@ class SmartSearchDto { final json = value.cast(); return SmartSearchDto( - city: Option.from(mapValueOfType(json, r'city')), - country: Option.from(mapValueOfType(json, r'country')), + city: Some.tryFrom(mapValueOfType(json, r'city')), + country: Some.tryFrom(mapValueOfType(json, r'country')), createdAfter: mapDateTime(json, r'createdAfter', r''), createdBefore: mapDateTime(json, r'createdBefore', r''), deviceId: mapValueOfType(json, r'deviceId'), @@ -513,10 +513,10 @@ class SmartSearchDto { isNotInAlbum: mapValueOfType(json, r'isNotInAlbum'), isOffline: mapValueOfType(json, r'isOffline'), language: mapValueOfType(json, r'language'), - lensModel: Option.from(mapValueOfType(json, r'lensModel')), - libraryId: Option.from(mapValueOfType(json, r'libraryId')), + lensModel: Some.tryFrom(mapValueOfType(json, r'lensModel')), + libraryId: Some.tryFrom(mapValueOfType(json, r'libraryId')), make: mapValueOfType(json, r'make'), - model: Option.from(mapValueOfType(json, r'model')), + model: Some.tryFrom(mapValueOfType(json, r'model')), page: num.parse('${json[r'page']}'), personIds: json[r'personIds'] is Iterable ? (json[r'personIds'] as Iterable).cast().toList(growable: false) @@ -524,7 +524,7 @@ class SmartSearchDto { query: mapValueOfType(json, r'query')!, rating: num.parse('${json[r'rating']}'), size: num.parse('${json[r'size']}'), - state: Option.from(mapValueOfType(json, r'state')), + state: Some.tryFrom(mapValueOfType(json, r'state')), tagIds: json[r'tagIds'] is Iterable ? (json[r'tagIds'] as Iterable).cast().toList(growable: false) : const [], diff --git a/mobile/openapi/lib/model/sync_asset_exif_v1.dart b/mobile/openapi/lib/model/sync_asset_exif_v1.dart index b26ab4ca7c..46d004c493 100644 --- a/mobile/openapi/lib/model/sync_asset_exif_v1.dart +++ b/mobile/openapi/lib/model/sync_asset_exif_v1.dart @@ -334,30 +334,30 @@ class SyncAssetExifV1 { return SyncAssetExifV1( assetId: mapValueOfType(json, r'assetId')!, - city: Option.from(mapValueOfType(json, r'city')), - country: Option.from(mapValueOfType(json, r'country')), - dateTimeOriginal: Option.from(mapDateTime(json, r'dateTimeOriginal', r'')), - description: Option.from(mapValueOfType(json, r'description')), - exifImageHeight: Option.from(mapValueOfType(json, r'exifImageHeight')), - exifImageWidth: Option.from(mapValueOfType(json, r'exifImageWidth')), - exposureTime: Option.from(mapValueOfType(json, r'exposureTime')), - fNumber: Option.from(mapValueOfType(json, r'fNumber')), - fileSizeInByte: Option.from(mapValueOfType(json, r'fileSizeInByte')), - focalLength: Option.from(mapValueOfType(json, r'focalLength')), - fps: Option.from(mapValueOfType(json, r'fps')), - iso: Option.from(mapValueOfType(json, r'iso')), - latitude: Option.from(mapValueOfType(json, r'latitude')), - lensModel: Option.from(mapValueOfType(json, r'lensModel')), - longitude: Option.from(mapValueOfType(json, r'longitude')), - make: Option.from(mapValueOfType(json, r'make')), - model: Option.from(mapValueOfType(json, r'model')), - modifyDate: Option.from(mapDateTime(json, r'modifyDate', r'')), - orientation: Option.from(mapValueOfType(json, r'orientation')), - profileDescription: Option.from(mapValueOfType(json, r'profileDescription')), - projectionType: Option.from(mapValueOfType(json, r'projectionType')), - rating: Option.from(mapValueOfType(json, r'rating')), - state: Option.from(mapValueOfType(json, r'state')), - timeZone: Option.from(mapValueOfType(json, r'timeZone')), + city: Some.tryFrom(mapValueOfType(json, r'city')), + country: Some.tryFrom(mapValueOfType(json, r'country')), + dateTimeOriginal: Some.tryFrom(mapDateTime(json, r'dateTimeOriginal', r'')), + description: Some.tryFrom(mapValueOfType(json, r'description')), + exifImageHeight: Some.tryFrom(mapValueOfType(json, r'exifImageHeight')), + exifImageWidth: Some.tryFrom(mapValueOfType(json, r'exifImageWidth')), + exposureTime: Some.tryFrom(mapValueOfType(json, r'exposureTime')), + fNumber: Some.tryFrom(mapValueOfType(json, r'fNumber')), + fileSizeInByte: Some.tryFrom(mapValueOfType(json, r'fileSizeInByte')), + focalLength: Some.tryFrom(mapValueOfType(json, r'focalLength')), + fps: Some.tryFrom(mapValueOfType(json, r'fps')), + iso: Some.tryFrom(mapValueOfType(json, r'iso')), + latitude: Some.tryFrom(mapValueOfType(json, r'latitude')), + lensModel: Some.tryFrom(mapValueOfType(json, r'lensModel')), + longitude: Some.tryFrom(mapValueOfType(json, r'longitude')), + make: Some.tryFrom(mapValueOfType(json, r'make')), + model: Some.tryFrom(mapValueOfType(json, r'model')), + modifyDate: Some.tryFrom(mapDateTime(json, r'modifyDate', r'')), + orientation: Some.tryFrom(mapValueOfType(json, r'orientation')), + profileDescription: Some.tryFrom(mapValueOfType(json, r'profileDescription')), + projectionType: Some.tryFrom(mapValueOfType(json, r'projectionType')), + rating: Some.tryFrom(mapValueOfType(json, r'rating')), + state: Some.tryFrom(mapValueOfType(json, r'state')), + timeZone: Some.tryFrom(mapValueOfType(json, r'timeZone')), ); } return null; diff --git a/mobile/openapi/lib/model/sync_asset_v1.dart b/mobile/openapi/lib/model/sync_asset_v1.dart index a5d5dd36b1..df54dd290a 100644 --- a/mobile/openapi/lib/model/sync_asset_v1.dart +++ b/mobile/openapi/lib/model/sync_asset_v1.dart @@ -136,14 +136,14 @@ class SyncAssetV1 { return SyncAssetV1( checksum: mapValueOfType(json, r'checksum')!, - deletedAt: Option.from(mapDateTime(json, r'deletedAt', r'')), - fileCreatedAt: Option.from(mapDateTime(json, r'fileCreatedAt', r'')), - fileModifiedAt: Option.from(mapDateTime(json, r'fileModifiedAt', r'')), + deletedAt: Some.tryFrom(mapDateTime(json, r'deletedAt', r'')), + fileCreatedAt: Some.tryFrom(mapDateTime(json, r'fileCreatedAt', r'')), + fileModifiedAt: Some.tryFrom(mapDateTime(json, r'fileModifiedAt', r'')), id: mapValueOfType(json, r'id')!, isFavorite: mapValueOfType(json, r'isFavorite')!, - localDateTime: Option.from(mapDateTime(json, r'localDateTime', r'')), + localDateTime: Some.tryFrom(mapDateTime(json, r'localDateTime', r'')), ownerId: mapValueOfType(json, r'ownerId')!, - thumbhash: Option.from(mapValueOfType(json, r'thumbhash')), + thumbhash: Some.tryFrom(mapValueOfType(json, r'thumbhash')), type: SyncAssetV1TypeEnum.fromJson(json[r'type'])!, visibility: SyncAssetV1VisibilityEnum.fromJson(json[r'visibility'])!, ); diff --git a/mobile/openapi/lib/model/sync_user_v1.dart b/mobile/openapi/lib/model/sync_user_v1.dart index 1c3d4f7c2e..6bc1098727 100644 --- a/mobile/openapi/lib/model/sync_user_v1.dart +++ b/mobile/openapi/lib/model/sync_user_v1.dart @@ -69,7 +69,7 @@ class SyncUserV1 { final json = value.cast(); return SyncUserV1( - deletedAt: Option.from(mapDateTime(json, r'deletedAt', r'')), + deletedAt: Some.tryFrom(mapDateTime(json, r'deletedAt', r'')), email: mapValueOfType(json, r'email')!, id: mapValueOfType(json, r'id')!, name: mapValueOfType(json, r'name')!, diff --git a/mobile/openapi/lib/model/tag_create_dto.dart b/mobile/openapi/lib/model/tag_create_dto.dart index fb31670f6a..671e712064 100644 --- a/mobile/openapi/lib/model/tag_create_dto.dart +++ b/mobile/openapi/lib/model/tag_create_dto.dart @@ -75,7 +75,7 @@ class TagCreateDto { return TagCreateDto( color: mapValueOfType(json, r'color'), name: mapValueOfType(json, r'name')!, - parentId: Option.from(mapValueOfType(json, r'parentId')), + parentId: Some.tryFrom(mapValueOfType(json, r'parentId')), ); } return null; diff --git a/mobile/openapi/lib/model/tag_update_dto.dart b/mobile/openapi/lib/model/tag_update_dto.dart index 57ec3ca498..c2737b9297 100644 --- a/mobile/openapi/lib/model/tag_update_dto.dart +++ b/mobile/openapi/lib/model/tag_update_dto.dart @@ -51,7 +51,7 @@ class TagUpdateDto { final json = value.cast(); return TagUpdateDto( - color: Option.from(mapValueOfType(json, r'color')), + color: Some.tryFrom(mapValueOfType(json, r'color')), ); } return null; diff --git a/mobile/openapi/lib/model/update_asset_dto.dart b/mobile/openapi/lib/model/update_asset_dto.dart index a4ef9fb0c5..f15ca6a49d 100644 --- a/mobile/openapi/lib/model/update_asset_dto.dart +++ b/mobile/openapi/lib/model/update_asset_dto.dart @@ -169,7 +169,7 @@ class UpdateAssetDto { description: mapValueOfType(json, r'description'), isFavorite: mapValueOfType(json, r'isFavorite'), latitude: num.parse('${json[r'latitude']}'), - livePhotoVideoId: Option.from(mapValueOfType(json, r'livePhotoVideoId')), + livePhotoVideoId: Some.tryFrom(mapValueOfType(json, r'livePhotoVideoId')), longitude: num.parse('${json[r'longitude']}'), rating: num.parse('${json[r'rating']}'), visibility: AssetVisibility.fromJson(json[r'visibility']), diff --git a/mobile/openapi/lib/model/usage_by_user_dto.dart b/mobile/openapi/lib/model/usage_by_user_dto.dart index af5e1a4aee..a5fcc2e677 100644 --- a/mobile/openapi/lib/model/usage_by_user_dto.dart +++ b/mobile/openapi/lib/model/usage_by_user_dto.dart @@ -94,7 +94,7 @@ class UsageByUserDto { return UsageByUserDto( photos: mapValueOfType(json, r'photos')!, - quotaSizeInBytes: Option.from(mapValueOfType(json, r'quotaSizeInBytes')), + quotaSizeInBytes: Some.tryFrom(mapValueOfType(json, r'quotaSizeInBytes')), usage: mapValueOfType(json, r'usage')!, usagePhotos: mapValueOfType(json, r'usagePhotos')!, usageVideos: mapValueOfType(json, r'usageVideos')!, diff --git a/mobile/openapi/lib/model/user_admin_create_dto.dart b/mobile/openapi/lib/model/user_admin_create_dto.dart index 3ff06347d0..28d6da3ea6 100644 --- a/mobile/openapi/lib/model/user_admin_create_dto.dart +++ b/mobile/openapi/lib/model/user_admin_create_dto.dart @@ -126,14 +126,14 @@ class UserAdminCreateDto { final json = value.cast(); return UserAdminCreateDto( - avatarColor: Option.from(UserAvatarColor.fromJson(json[r'avatarColor'])), + avatarColor: Some.tryFrom(UserAvatarColor.fromJson(json[r'avatarColor'])), email: mapValueOfType(json, r'email')!, name: mapValueOfType(json, r'name')!, notify: mapValueOfType(json, r'notify'), password: mapValueOfType(json, r'password')!, - quotaSizeInBytes: Option.from(mapValueOfType(json, r'quotaSizeInBytes')), + quotaSizeInBytes: Some.tryFrom(mapValueOfType(json, r'quotaSizeInBytes')), shouldChangePassword: mapValueOfType(json, r'shouldChangePassword'), - storageLabel: Option.from(mapValueOfType(json, r'storageLabel')), + storageLabel: Some.tryFrom(mapValueOfType(json, r'storageLabel')), ); } return null; diff --git a/mobile/openapi/lib/model/user_admin_response_dto.dart b/mobile/openapi/lib/model/user_admin_response_dto.dart index 01faf2a2ff..d20addcaf8 100644 --- a/mobile/openapi/lib/model/user_admin_response_dto.dart +++ b/mobile/openapi/lib/model/user_admin_response_dto.dart @@ -173,20 +173,20 @@ class UserAdminResponseDto { return UserAdminResponseDto( avatarColor: UserAvatarColor.fromJson(json[r'avatarColor'])!, createdAt: mapDateTime(json, r'createdAt', r'')!, - deletedAt: Option.from(mapDateTime(json, r'deletedAt', r'')), + deletedAt: Some.tryFrom(mapDateTime(json, r'deletedAt', r'')), email: mapValueOfType(json, r'email')!, id: mapValueOfType(json, r'id')!, isAdmin: mapValueOfType(json, r'isAdmin')!, - license: Option.from(UserLicense.fromJson(json[r'license'])), + license: Some.tryFrom(UserLicense.fromJson(json[r'license'])), name: mapValueOfType(json, r'name')!, oauthId: mapValueOfType(json, r'oauthId')!, profileChangedAt: mapDateTime(json, r'profileChangedAt', r'')!, profileImagePath: mapValueOfType(json, r'profileImagePath')!, - quotaSizeInBytes: Option.from(mapValueOfType(json, r'quotaSizeInBytes')), - quotaUsageInBytes: Option.from(mapValueOfType(json, r'quotaUsageInBytes')), + quotaSizeInBytes: Some.tryFrom(mapValueOfType(json, r'quotaSizeInBytes')), + quotaUsageInBytes: Some.tryFrom(mapValueOfType(json, r'quotaUsageInBytes')), shouldChangePassword: mapValueOfType(json, r'shouldChangePassword')!, status: UserStatus.fromJson(json[r'status'])!, - storageLabel: Option.from(mapValueOfType(json, r'storageLabel')), + storageLabel: Some.tryFrom(mapValueOfType(json, r'storageLabel')), updatedAt: mapDateTime(json, r'updatedAt', r'')!, ); } diff --git a/mobile/openapi/lib/model/user_admin_update_dto.dart b/mobile/openapi/lib/model/user_admin_update_dto.dart index 66e1901b35..44f7c5ea86 100644 --- a/mobile/openapi/lib/model/user_admin_update_dto.dart +++ b/mobile/openapi/lib/model/user_admin_update_dto.dart @@ -152,14 +152,14 @@ class UserAdminUpdateDto { final json = value.cast(); return UserAdminUpdateDto( - avatarColor: Option.from(UserAvatarColor.fromJson(json[r'avatarColor'])), + avatarColor: Some.tryFrom(UserAvatarColor.fromJson(json[r'avatarColor'])), email: mapValueOfType(json, r'email'), name: mapValueOfType(json, r'name'), password: mapValueOfType(json, r'password'), - pinCode: Option.from(mapValueOfType(json, r'pinCode')), - quotaSizeInBytes: Option.from(mapValueOfType(json, r'quotaSizeInBytes')), + pinCode: Some.tryFrom(mapValueOfType(json, r'pinCode')), + quotaSizeInBytes: Some.tryFrom(mapValueOfType(json, r'quotaSizeInBytes')), shouldChangePassword: mapValueOfType(json, r'shouldChangePassword'), - storageLabel: Option.from(mapValueOfType(json, r'storageLabel')), + storageLabel: Some.tryFrom(mapValueOfType(json, r'storageLabel')), ); } return null; diff --git a/mobile/openapi/lib/model/user_update_me_dto.dart b/mobile/openapi/lib/model/user_update_me_dto.dart index b9d5135925..080d491263 100644 --- a/mobile/openapi/lib/model/user_update_me_dto.dart +++ b/mobile/openapi/lib/model/user_update_me_dto.dart @@ -99,7 +99,7 @@ class UserUpdateMeDto { final json = value.cast(); return UserUpdateMeDto( - avatarColor: Option.from(UserAvatarColor.fromJson(json[r'avatarColor'])), + avatarColor: Some.tryFrom(UserAvatarColor.fromJson(json[r'avatarColor'])), email: mapValueOfType(json, r'email'), name: mapValueOfType(json, r'name'), password: mapValueOfType(json, r'password'), diff --git a/open-api/templates/mobile/serialization/native/native_class.mustache b/open-api/templates/mobile/serialization/native/native_class.mustache index 43e53b0b46..500134e30d 100644 --- a/open-api/templates/mobile/serialization/native/native_class.mustache +++ b/open-api/templates/mobile/serialization/native/native_class.mustache @@ -120,10 +120,10 @@ class {{{classname}}} { return {{{classname}}}( {{#vars}} {{#isDateTime}} - {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, + {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, {{/isDateTime}} {{#isDate}} - {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, + {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, {{/isDate}} {{^isDateTime}} {{^isDate}} @@ -181,7 +181,7 @@ class {{{classname}}} { {{{name}}}: null, // No support for decoding binary content from JSON {{/isBinary}} {{^isBinary}} - {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}{{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, + {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}{{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, {{/isBinary}} {{/isMap}} {{/isArray}} @@ -203,20 +203,20 @@ class {{{classname}}} { {{/isMap}} {{^isMap}} {{#isNumber}} - {{{name}}}: {{#isNullable}}Option.from(json[r'{{{baseName}}}'] == null + {{{name}}}: {{#isNullable}}Some.tryFrom(json[r'{{{baseName}}}'] == null ? {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}} : {{/isNullable}}{{{datatypeWithEnum}}}.parse('${json[r'{{{baseName}}}']}'){{#isNullable}}){{/isNullable}}, {{/isNumber}} {{#isDouble}} - {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}(mapValueOfType(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}).toDouble(){{#isNullable}}){{/isNullable}}, + {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}(mapValueOfType(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}).toDouble(){{#isNullable}}){{/isNullable}}, {{/isDouble}} {{^isDouble}} {{^isNumber}} {{^isEnum}} - {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, + {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, {{/isEnum}} {{#isEnum}} - {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}{{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, + {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}{{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, {{/isEnum}} {{/isNumber}} {{/isDouble}} diff --git a/open-api/templates/mobile/serialization/native/native_class.mustache.patch b/open-api/templates/mobile/serialization/native/native_class.mustache.patch index 4ba338eeb1..efdc97316f 100644 --- a/open-api/templates/mobile/serialization/native/native_class.mustache.patch +++ b/open-api/templates/mobile/serialization/native/native_class.mustache.patch @@ -93,11 +93,11 @@ index 3a6c457..b1c8c5b 100644 {{#vars}} {{#isDateTime}} - {{{name}}}: mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}, -+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, ++ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, {{/isDateTime}} {{#isDate}} - {{{name}}}: mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}, -+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, ++ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapDateTime(json, r'{{{baseName}}}', r'{{{pattern}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, {{/isDate}} {{^isDateTime}} {{^isDate}} @@ -106,7 +106,7 @@ index 3a6c457..b1c8c5b 100644 {{/isBinary}} {{^isBinary}} - {{{name}}}: {{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}, -+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}{{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, ++ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}{{{complexType}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, {{/isBinary}} {{/isMap}} {{/isArray}} @@ -115,23 +115,23 @@ index 3a6c457..b1c8c5b 100644 {{^isMap}} {{#isNumber}} - {{{name}}}: {{#isNullable}}json[r'{{{baseName}}}'] == null -+ {{{name}}}: {{#isNullable}}Option.from(json[r'{{{baseName}}}'] == null ++ {{{name}}}: {{#isNullable}}Some.tryFrom(json[r'{{{baseName}}}'] == null ? {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}} - : {{/isNullable}}{{{datatypeWithEnum}}}.parse('${json[r'{{{baseName}}}']}'), + : {{/isNullable}}{{{datatypeWithEnum}}}.parse('${json[r'{{{baseName}}}']}'){{#isNullable}}){{/isNullable}}, {{/isNumber}} + {{#isDouble}} -+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}(mapValueOfType(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}).toDouble(){{#isNullable}}){{/isNullable}}, ++ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}(mapValueOfType(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}).toDouble(){{#isNullable}}){{/isNullable}}, + {{/isDouble}} + {{^isDouble}} {{^isNumber}} {{^isEnum}} - {{{name}}}: mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}, -+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, ++ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}mapValueOfType<{{{datatypeWithEnum}}}>(json, r'{{{baseName}}}'){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, {{/isEnum}} {{#isEnum}} - {{{name}}}: {{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}, -+ {{{name}}}: {{#isNullable}}Option.from({{/isNullable}}{{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, ++ {{{name}}}: {{#isNullable}}Some.tryFrom({{/isNullable}}{{{enumName}}}.fromJson(json[r'{{{baseName}}}']){{#required}}{{^isNullable}}!{{/isNullable}}{{/required}}{{^required}}{{#defaultValue}} ?? {{{.}}}{{/defaultValue}}{{/required}}{{#isNullable}}){{/isNullable}}, {{/isEnum}} {{/isNumber}} + {{/isDouble}}