mirror of
https://github.com/immich-app/immich.git
synced 2025-01-07 00:50:23 -05:00
fix: no floats (replace with doubles) (#10218)
* fix: no floats (replace with doubles) * Update server/src/utils/misc.ts Co-authored-by: Zack Pollard <zackpollard@ymail.com> --------- Co-authored-by: Zack Pollard <zackpollard@ymail.com>
This commit is contained in:
parent
10aa00af21
commit
3d82005797
7 changed files with 31 additions and 13 deletions
BIN
mobile/openapi/lib/model/duplicate_detection_config.dart
generated
BIN
mobile/openapi/lib/model/duplicate_detection_config.dart
generated
Binary file not shown.
BIN
mobile/openapi/lib/model/facial_recognition_config.dart
generated
BIN
mobile/openapi/lib/model/facial_recognition_config.dart
generated
Binary file not shown.
Binary file not shown.
|
@ -8146,7 +8146,7 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"maxDistance": {
|
"maxDistance": {
|
||||||
"format": "float",
|
"format": "double",
|
||||||
"maximum": 0.1,
|
"maximum": 0.1,
|
||||||
"minimum": 0.001,
|
"minimum": 0.001,
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
@ -8347,7 +8347,7 @@
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
"maxDistance": {
|
"maxDistance": {
|
||||||
"format": "float",
|
"format": "double",
|
||||||
"maximum": 2,
|
"maximum": 2,
|
||||||
"minimum": 0,
|
"minimum": 0,
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
@ -8357,7 +8357,7 @@
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
"minScore": {
|
"minScore": {
|
||||||
"format": "float",
|
"format": "double",
|
||||||
"maximum": 1,
|
"maximum": 1,
|
||||||
"minimum": 0,
|
"minimum": 0,
|
||||||
"type": "number"
|
"type": "number"
|
||||||
|
@ -9797,7 +9797,7 @@
|
||||||
"type": "integer"
|
"type": "integer"
|
||||||
},
|
},
|
||||||
"diskUsagePercentage": {
|
"diskUsagePercentage": {
|
||||||
"format": "float",
|
"format": "double",
|
||||||
"type": "number"
|
"type": "number"
|
||||||
},
|
},
|
||||||
"diskUse": {
|
"diskUse": {
|
||||||
|
|
|
@ -21,7 +21,7 @@ export class DuplicateDetectionConfig extends TaskConfig {
|
||||||
@Min(0.001)
|
@Min(0.001)
|
||||||
@Max(0.1)
|
@Max(0.1)
|
||||||
@Type(() => Number)
|
@Type(() => Number)
|
||||||
@ApiProperty({ type: 'number', format: 'float' })
|
@ApiProperty({ type: 'number', format: 'double' })
|
||||||
maxDistance!: number;
|
maxDistance!: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,14 +30,14 @@ export class FacialRecognitionConfig extends ModelConfig {
|
||||||
@Min(0)
|
@Min(0)
|
||||||
@Max(1)
|
@Max(1)
|
||||||
@Type(() => Number)
|
@Type(() => Number)
|
||||||
@ApiProperty({ type: 'number', format: 'float' })
|
@ApiProperty({ type: 'number', format: 'double' })
|
||||||
minScore!: number;
|
minScore!: number;
|
||||||
|
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
@Min(0)
|
@Min(0)
|
||||||
@Max(2)
|
@Max(2)
|
||||||
@Type(() => Number)
|
@Type(() => Number)
|
||||||
@ApiProperty({ type: 'number', format: 'float' })
|
@ApiProperty({ type: 'number', format: 'double' })
|
||||||
maxDistance!: number;
|
maxDistance!: number;
|
||||||
|
|
||||||
@IsNumber()
|
@IsNumber()
|
||||||
|
|
|
@ -21,7 +21,7 @@ export class ServerStorageResponseDto {
|
||||||
@ApiProperty({ type: 'integer', format: 'int64' })
|
@ApiProperty({ type: 'integer', format: 'int64' })
|
||||||
diskAvailableRaw!: number;
|
diskAvailableRaw!: number;
|
||||||
|
|
||||||
@ApiProperty({ type: 'number', format: 'float' })
|
@ApiProperty({ type: 'number', format: 'double' })
|
||||||
diskUsagePercentage!: number;
|
diskUsagePercentage!: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import {
|
||||||
SwaggerDocumentOptions,
|
SwaggerDocumentOptions,
|
||||||
SwaggerModule,
|
SwaggerModule,
|
||||||
} from '@nestjs/swagger';
|
} from '@nestjs/swagger';
|
||||||
import { SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
|
import { ReferenceObject, SchemaObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { writeFileSync } from 'node:fs';
|
import { writeFileSync } from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
|
@ -111,6 +111,14 @@ function sortKeys<T>(target: T): T {
|
||||||
export const routeToErrorMessage = (methodName: string) =>
|
export const routeToErrorMessage = (methodName: string) =>
|
||||||
'Failed to ' + methodName.replaceAll(/[A-Z]+/g, (letter) => ` ${letter.toLowerCase()}`);
|
'Failed to ' + methodName.replaceAll(/[A-Z]+/g, (letter) => ` ${letter.toLowerCase()}`);
|
||||||
|
|
||||||
|
const isSchema = (schema: string | ReferenceObject | SchemaObject): schema is SchemaObject => {
|
||||||
|
if (typeof schema === 'string' || '$ref' in schema) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
const patchOpenAPI = (document: OpenAPIObject) => {
|
const patchOpenAPI = (document: OpenAPIObject) => {
|
||||||
document.paths = sortKeys(document.paths);
|
document.paths = sortKeys(document.paths);
|
||||||
|
|
||||||
|
@ -119,13 +127,23 @@ const patchOpenAPI = (document: OpenAPIObject) => {
|
||||||
|
|
||||||
document.components.schemas = sortKeys(schemas);
|
document.components.schemas = sortKeys(schemas);
|
||||||
|
|
||||||
for (const schema of Object.values(schemas)) {
|
for (const [schemaName, schema] of Object.entries(schemas)) {
|
||||||
if (schema.properties) {
|
if (schema.properties) {
|
||||||
schema.properties = sortKeys(schema.properties);
|
schema.properties = sortKeys(schema.properties);
|
||||||
}
|
|
||||||
|
|
||||||
if (schema.required) {
|
for (const [key, value] of Object.entries(schema.properties)) {
|
||||||
schema.required = schema.required.sort();
|
if (typeof value === 'string') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSchema(value) && value.type === 'number' && value.format === 'float') {
|
||||||
|
throw new Error(`Invalid number format: ${schemaName}.${key}=float (use double instead). `);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (schema.required) {
|
||||||
|
schema.required = schema.required.sort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue