openapi battle

This commit is contained in:
Min Idzelis 2025-05-03 02:43:06 +00:00
parent 6e8993c6eb
commit bf0be6a655
13 changed files with 182 additions and 316 deletions

View File

@ -1,4 +1,4 @@
import { AssetMediaResponseDto, LoginResponseDto, SharedLinkType, TimeBucketSize } from '@immich/sdk';
import { AssetMediaResponseDto, LoginResponseDto, SharedLinkType } from '@immich/sdk';
import { DateTime } from 'luxon';
import { createUserDto } from 'src/fixtures';
import { errorDto } from 'src/responses';

View File

@ -478,11 +478,10 @@ Class | Method | HTTP request | Description
- [TemplateResponseDto](doc//TemplateResponseDto.md)
- [TestEmailResponseDto](doc//TestEmailResponseDto.md)
- [TimeBucketAssetResponseDto](doc//TimeBucketAssetResponseDto.md)
- [TimeBucketAssetResponseDtoDurationInner](doc//TimeBucketAssetResponseDtoDurationInner.md)
- [TimeBucketAssetResponseDtoStackInner](doc//TimeBucketAssetResponseDtoStackInner.md)
- [TimeBucketResponseDto](doc//TimeBucketResponseDto.md)
- [TimeBucketsResponseDto](doc//TimeBucketsResponseDto.md)
- [TimelineAssetDescriptionDto](doc//TimelineAssetDescriptionDto.md)
- [TimelineStackResponseDto](doc//TimelineStackResponseDto.md)
- [ToneMapping](doc//ToneMapping.md)
- [TranscodeHWAccel](doc//TranscodeHWAccel.md)
- [TranscodePolicy](doc//TranscodePolicy.md)

View File

@ -282,11 +282,10 @@ part 'model/template_dto.dart';
part 'model/template_response_dto.dart';
part 'model/test_email_response_dto.dart';
part 'model/time_bucket_asset_response_dto.dart';
part 'model/time_bucket_asset_response_dto_duration_inner.dart';
part 'model/time_bucket_asset_response_dto_stack_inner.dart';
part 'model/time_bucket_response_dto.dart';
part 'model/time_buckets_response_dto.dart';
part 'model/timeline_asset_description_dto.dart';
part 'model/timeline_stack_response_dto.dart';
part 'model/tone_mapping.dart';
part 'model/transcode_hw_accel.dart';
part 'model/transcode_policy.dart';

View File

@ -620,16 +620,14 @@ class ApiClient {
return TestEmailResponseDto.fromJson(value);
case 'TimeBucketAssetResponseDto':
return TimeBucketAssetResponseDto.fromJson(value);
case 'TimeBucketAssetResponseDtoDurationInner':
return TimeBucketAssetResponseDtoDurationInner.fromJson(value);
case 'TimeBucketAssetResponseDtoStackInner':
return TimeBucketAssetResponseDtoStackInner.fromJson(value);
case 'TimeBucketResponseDto':
return TimeBucketResponseDto.fromJson(value);
case 'TimeBucketsResponseDto':
return TimeBucketsResponseDto.fromJson(value);
case 'TimelineAssetDescriptionDto':
return TimelineAssetDescriptionDto.fromJson(value);
case 'TimelineStackResponseDto':
return TimelineStackResponseDto.fromJson(value);
case 'ToneMapping':
return ToneMappingTypeTransformer().decode(value);
case 'TranscodeHWAccel':

View File

@ -32,7 +32,7 @@ class TimeBucketAssetResponseDto {
List<TimelineAssetDescriptionDto> description;
List<TimeBucketAssetResponseDtoDurationInner> duration;
List<String> duration;
List<String> id;
@ -46,19 +46,19 @@ class TimeBucketAssetResponseDto {
List<num> isVideo;
List<TimeBucketAssetResponseDtoDurationInner> livePhotoVideoId;
List<String> livePhotoVideoId;
List<DateTime> localDateTime;
List<String> ownerId;
List<TimeBucketAssetResponseDtoDurationInner> projectionType;
List<String> projectionType;
List<num> ratio;
List<TimeBucketAssetResponseDtoStackInner> stack;
List<TimelineStackResponseDto> stack;
List<TimeBucketAssetResponseDtoDurationInner> thumbhash;
List<String> thumbhash;
@override
bool operator ==(Object other) => identical(this, other) || other is TimeBucketAssetResponseDto &&
@ -130,7 +130,9 @@ class TimeBucketAssetResponseDto {
return TimeBucketAssetResponseDto(
description: TimelineAssetDescriptionDto.listFromJson(json[r'description']),
duration: TimeBucketAssetResponseDtoDurationInner.listFromJson(json[r'duration']),
duration: json[r'duration'] is Iterable
? (json[r'duration'] as Iterable).cast<String>().toList(growable: false)
: const [],
id: json[r'id'] is Iterable
? (json[r'id'] as Iterable).cast<String>().toList(growable: false)
: const [],
@ -149,17 +151,23 @@ class TimeBucketAssetResponseDto {
isVideo: json[r'isVideo'] is Iterable
? (json[r'isVideo'] as Iterable).cast<num>().toList(growable: false)
: const [],
livePhotoVideoId: TimeBucketAssetResponseDtoDurationInner.listFromJson(json[r'livePhotoVideoId']),
livePhotoVideoId: json[r'livePhotoVideoId'] is Iterable
? (json[r'livePhotoVideoId'] as Iterable).cast<String>().toList(growable: false)
: const [],
localDateTime: DateTime.listFromJson(json[r'localDateTime']),
ownerId: json[r'ownerId'] is Iterable
? (json[r'ownerId'] as Iterable).cast<String>().toList(growable: false)
: const [],
projectionType: TimeBucketAssetResponseDtoDurationInner.listFromJson(json[r'projectionType']),
projectionType: json[r'projectionType'] is Iterable
? (json[r'projectionType'] as Iterable).cast<String>().toList(growable: false)
: const [],
ratio: json[r'ratio'] is Iterable
? (json[r'ratio'] as Iterable).cast<num>().toList(growable: false)
: const [],
stack: TimeBucketAssetResponseDtoStackInner.listFromJson(json[r'stack']),
thumbhash: TimeBucketAssetResponseDtoDurationInner.listFromJson(json[r'thumbhash']),
stack: TimelineStackResponseDto.listFromJson(json[r'stack']),
thumbhash: json[r'thumbhash'] is Iterable
? (json[r'thumbhash'] as Iterable).cast<String>().toList(growable: false)
: const [],
);
}
return null;

View File

@ -1,91 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// 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 TimeBucketAssetResponseDtoDurationInner {
/// Returns a new [TimeBucketAssetResponseDtoDurationInner] instance.
TimeBucketAssetResponseDtoDurationInner({
});
@override
bool operator ==(Object other) => identical(this, other) || other is TimeBucketAssetResponseDtoDurationInner &&
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
@override
String toString() => 'TimeBucketAssetResponseDtoDurationInner[]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
return json;
}
/// Returns a new [TimeBucketAssetResponseDtoDurationInner] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static TimeBucketAssetResponseDtoDurationInner? fromJson(dynamic value) {
upgradeDto(value, "TimeBucketAssetResponseDtoDurationInner");
if (value is Map) {
final json = value.cast<String, dynamic>();
return TimeBucketAssetResponseDtoDurationInner(
);
}
return null;
}
static List<TimeBucketAssetResponseDtoDurationInner> listFromJson(dynamic json, {bool growable = false,}) {
final result = <TimeBucketAssetResponseDtoDurationInner>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = TimeBucketAssetResponseDtoDurationInner.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, TimeBucketAssetResponseDtoDurationInner> mapFromJson(dynamic json) {
final map = <String, TimeBucketAssetResponseDtoDurationInner>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = TimeBucketAssetResponseDtoDurationInner.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of TimeBucketAssetResponseDtoDurationInner-objects as value to a dart map
static Map<String, List<TimeBucketAssetResponseDtoDurationInner>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<TimeBucketAssetResponseDtoDurationInner>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = TimeBucketAssetResponseDtoDurationInner.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
};
}

View File

@ -1,91 +0,0 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// 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 TimeBucketAssetResponseDtoStackInner {
/// Returns a new [TimeBucketAssetResponseDtoStackInner] instance.
TimeBucketAssetResponseDtoStackInner({
});
@override
bool operator ==(Object other) => identical(this, other) || other is TimeBucketAssetResponseDtoStackInner &&
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
@override
String toString() => 'TimeBucketAssetResponseDtoStackInner[]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
return json;
}
/// Returns a new [TimeBucketAssetResponseDtoStackInner] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static TimeBucketAssetResponseDtoStackInner? fromJson(dynamic value) {
upgradeDto(value, "TimeBucketAssetResponseDtoStackInner");
if (value is Map) {
final json = value.cast<String, dynamic>();
return TimeBucketAssetResponseDtoStackInner(
);
}
return null;
}
static List<TimeBucketAssetResponseDtoStackInner> listFromJson(dynamic json, {bool growable = false,}) {
final result = <TimeBucketAssetResponseDtoStackInner>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = TimeBucketAssetResponseDtoStackInner.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, TimeBucketAssetResponseDtoStackInner> mapFromJson(dynamic json) {
final map = <String, TimeBucketAssetResponseDtoStackInner>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = TimeBucketAssetResponseDtoStackInner.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of TimeBucketAssetResponseDtoStackInner-objects as value to a dart map
static Map<String, List<TimeBucketAssetResponseDtoStackInner>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<TimeBucketAssetResponseDtoStackInner>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = TimeBucketAssetResponseDtoStackInner.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
};
}

View File

@ -0,0 +1,115 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// 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 TimelineStackResponseDto {
/// Returns a new [TimelineStackResponseDto] instance.
TimelineStackResponseDto({
required this.assetCount,
required this.id,
required this.primaryAssetId,
});
num assetCount;
String id;
String primaryAssetId;
@override
bool operator ==(Object other) => identical(this, other) || other is TimelineStackResponseDto &&
other.assetCount == assetCount &&
other.id == id &&
other.primaryAssetId == primaryAssetId;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(assetCount.hashCode) +
(id.hashCode) +
(primaryAssetId.hashCode);
@override
String toString() => 'TimelineStackResponseDto[assetCount=$assetCount, id=$id, primaryAssetId=$primaryAssetId]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'assetCount'] = this.assetCount;
json[r'id'] = this.id;
json[r'primaryAssetId'] = this.primaryAssetId;
return json;
}
/// Returns a new [TimelineStackResponseDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static TimelineStackResponseDto? fromJson(dynamic value) {
upgradeDto(value, "TimelineStackResponseDto");
if (value is Map) {
final json = value.cast<String, dynamic>();
return TimelineStackResponseDto(
assetCount: num.parse('${json[r'assetCount']}'),
id: mapValueOfType<String>(json, r'id')!,
primaryAssetId: mapValueOfType<String>(json, r'primaryAssetId')!,
);
}
return null;
}
static List<TimelineStackResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <TimelineStackResponseDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = TimelineStackResponseDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, TimelineStackResponseDto> mapFromJson(dynamic json) {
final map = <String, TimelineStackResponseDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = TimelineStackResponseDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of TimelineStackResponseDto-objects as value to a dart map
static Map<String, List<TimelineStackResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<TimelineStackResponseDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = TimelineStackResponseDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'assetCount',
'id',
'primaryAssetId',
};
}

View File

@ -1,5 +1,5 @@
#!/usr/bin/env bash
OPENAPI_GENERATOR_VERSION=v7.8.0
OPENAPI_GENERATOR_VERSION=v7.12.0
# usage: ./bin/generate-open-api.sh

View File

@ -13571,14 +13571,7 @@
"duration": {
"default": [],
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"type": "string"
},
"type": "array"
},
@ -13627,14 +13620,7 @@
"livePhotoVideoId": {
"default": [],
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"type": "string"
},
"type": "array"
},
@ -13656,14 +13642,7 @@
"projectionType": {
"default": [],
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"type": "string"
},
"type": "array"
},
@ -13677,28 +13656,14 @@
"stack": {
"default": [],
"items": {
"oneOf": [
{
"type": "TimelineStackResponseDto"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/TimelineStackResponseDto"
},
"type": "array"
},
"thumbhash": {
"default": [],
"items": {
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"type": "string"
},
"type": "array"
}
@ -13769,6 +13734,25 @@
],
"type": "object"
},
"TimelineStackResponseDto": {
"properties": {
"assetCount": {
"type": "number"
},
"id": {
"type": "string"
},
"primaryAssetId": {
"type": "string"
}
},
"required": [
"assetCount",
"id",
"primaryAssetId"
],
"type": "object"
},
"ToneMapping": {
"enum": [
"hable",

View File

@ -1388,22 +1388,27 @@ export type TimelineAssetDescriptionDto = {
city: string | null;
country: string | null;
};
export type TimelineStackResponseDto = {
assetCount: number;
id: string;
primaryAssetId: string;
};
export type TimeBucketAssetResponseDto = {
description: TimelineAssetDescriptionDto[];
duration: (string | null)[];
duration: string[];
id: string[];
isArchived: number[];
isFavorite: number[];
isImage: number[];
isTrashed: number[];
isVideo: number[];
livePhotoVideoId: (string | null)[];
livePhotoVideoId: string[];
localDateTime: string[];
ownerId: string[];
projectionType: (string | null)[];
projectionType: string[];
ratio: number[];
stack: (any | null)[];
thumbhash: (string | null)[];
stack: TimelineStackResponseDto[];
thumbhash: string[];
};
export type TimeBucketResponseDto = {
bucketAssets: TimeBucketAssetResponseDto;

View File

@ -96,82 +96,22 @@ export class TimeBucketAssetResponseDto implements TimeBucketAssets {
@ApiProperty()
isVideo: number[] = [];
@ApiProperty({
type: 'array',
items: {
oneOf: [
{
type: 'string',
},
{
type: 'null',
},
],
},
})
@ApiProperty({ type: [String] })
thumbhash: (string | null)[] = [];
@ApiProperty()
localDateTime: Date[] = [];
@ApiProperty({
type: 'array',
items: {
oneOf: [
{
type: 'string',
},
{
type: 'null',
},
],
},
})
@ApiProperty({ type: [String] })
duration: (string | null)[] = [];
@ApiProperty({
type: 'array',
items: {
oneOf: [
{
type: 'TimelineStackResponseDto',
},
{
type: 'null',
},
],
},
})
@ApiProperty({ type: [TimelineStackResponseDto] })
stack: (TimelineStackResponseDto | null)[] = [];
@ApiProperty({
type: 'array',
items: {
oneOf: [
{
type: 'string',
},
{
type: 'null',
},
],
},
})
@ApiProperty({ type: [String] })
projectionType: (string | null)[] = [];
@ApiProperty({
type: 'array',
items: {
oneOf: [
{
type: 'string',
},
{
type: 'null',
},
],
},
})
@ApiProperty({ type: [String] })
livePhotoVideoId: (string | null)[] = [];
@ApiProperty()

View File

@ -75,20 +75,20 @@ export const toResponseDto = (...timelineAsset: TimelineAsset[]) => {
};
for (const asset of timelineAsset) {
bucketAssets.description.push(asset.description);
bucketAssets.duration.push(asset.duration || 0);
bucketAssets.duration.push(asset.duration);
bucketAssets.id.push(asset.id);
bucketAssets.isArchived.push(asset.isArchived ? 1 : 0);
bucketAssets.isFavorite.push(asset.isFavorite ? 1 : 0);
bucketAssets.isImage.push(asset.isImage ? 1 : 0);
bucketAssets.isTrashed.push(asset.isTrashed ? 1 : 0);
bucketAssets.isVideo.push(asset.isVideo ? 1 : 0);
bucketAssets.livePhotoVideoId.push(asset.livePhotoVideoId || 0);
bucketAssets.livePhotoVideoId.push(asset.livePhotoVideoId);
bucketAssets.localDateTime.push(asset.localDateTime);
bucketAssets.ownerId.push(asset.ownerId);
bucketAssets.projectionType.push(asset.projectionType || 0);
bucketAssets.projectionType.push(asset.projectionType);
bucketAssets.ratio.push(asset.ratio);
bucketAssets.stack.push(asset.stack as TimelineStackResponseDto);
bucketAssets.thumbhash.push(asset.thumbhash || 0);
bucketAssets.thumbhash.push(asset.thumbhash);
}
const response: TimeBucketResponseDto = {
bucketAssets,