fix(server): Document HTTP 200 response for duplicate uploads in OpenAPI (#25148)

* fix(server): Document HTTP 200 response for duplicate uploads in OpenAPI

* fix 201

* rename
This commit is contained in:
Timon 2026-01-09 05:52:31 +01:00 committed by GitHub
parent 520b825511
commit 3cdece4945
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 3 deletions

View file

@ -2528,6 +2528,16 @@
"required": true "required": true
}, },
"responses": { "responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AssetMediaResponseDto"
}
}
},
"description": "Asset is a duplicate"
},
"201": { "201": {
"content": { "content": {
"application/json": { "application/json": {
@ -2536,7 +2546,7 @@
} }
} }
}, },
"description": "" "description": "Asset uploaded successfully"
} }
}, },
"security": [ "security": [
@ -3743,7 +3753,7 @@
} }
} }
}, },
"description": "" "description": "Asset replaced successfully"
} }
}, },
"security": [ "security": [

View file

@ -2390,6 +2390,9 @@ export function uploadAsset({ key, slug, xImmichChecksum, assetMediaCreateDto }:
assetMediaCreateDto: AssetMediaCreateDto; assetMediaCreateDto: AssetMediaCreateDto;
}, opts?: Oazapfts.RequestOpts) { }, opts?: Oazapfts.RequestOpts) {
return oazapfts.ok(oazapfts.fetchJson<{ return oazapfts.ok(oazapfts.fetchJson<{
status: 200;
data: AssetMediaResponseDto;
} | {
status: 201; status: 201;
data: AssetMediaResponseDto; data: AssetMediaResponseDto;
}>(`/assets${QS.query(QS.explode({ }>(`/assets${QS.query(QS.explode({

View file

@ -15,7 +15,7 @@ import {
UploadedFiles, UploadedFiles,
UseInterceptors, UseInterceptors,
} from '@nestjs/common'; } from '@nestjs/common';
import { ApiBody, ApiConsumes, ApiHeader, ApiTags } from '@nestjs/swagger'; import { ApiBody, ApiConsumes, ApiHeader, ApiResponse, ApiTags } from '@nestjs/swagger';
import { NextFunction, Request, Response } from 'express'; import { NextFunction, Request, Response } from 'express';
import { Endpoint, HistoryBuilder } from 'src/decorators'; import { Endpoint, HistoryBuilder } from 'src/decorators';
import { import {
@ -62,6 +62,16 @@ export class AssetMediaController {
required: false, required: false,
}) })
@ApiBody({ description: 'Asset Upload Information', type: AssetMediaCreateDto }) @ApiBody({ description: 'Asset Upload Information', type: AssetMediaCreateDto })
@ApiResponse({
status: 200,
description: 'Asset is a duplicate',
type: AssetMediaResponseDto,
})
@ApiResponse({
status: 201,
description: 'Asset uploaded successfully',
type: AssetMediaResponseDto,
})
@Endpoint({ @Endpoint({
summary: 'Upload asset', summary: 'Upload asset',
description: 'Uploads a new asset to the server.', description: 'Uploads a new asset to the server.',
@ -103,6 +113,11 @@ export class AssetMediaController {
@Put(':id/original') @Put(':id/original')
@UseInterceptors(FileUploadInterceptor) @UseInterceptors(FileUploadInterceptor)
@ApiConsumes('multipart/form-data') @ApiConsumes('multipart/form-data')
@ApiResponse({
status: 200,
description: 'Asset replaced successfully',
type: AssetMediaResponseDto,
})
@Endpoint({ @Endpoint({
summary: 'Replace asset', summary: 'Replace asset',
description: 'Replace the asset with new file, without changing its id.', description: 'Replace the asset with new file, without changing its id.',