This commit is contained in:
seb
2026-10-06 04:43:35 +02:00
parent 75ab6ce171
commit fe5990af9f
8 changed files with 571 additions and 104 deletions

View File

@@ -243,6 +243,152 @@ export function register(app, basePath = '') {
}
});
/**
* @openapi
* /brand/{id}/image:
* post:
* tags: [Brand]
* summary: Add or replace brand image
* description: |
* Uploads an image for the brand (AVIF, WebP, or octet-stream). Converted to AVIF full and thumbnail.
* Replaces any existing image for this brand.
* security:
* - cookieAuth: []
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: Brand id
* requestBody:
* required: true
* content:
* image/avif:
* schema:
* type: string
* format: binary
* image/webp:
* schema:
* type: string
* format: binary
* application/octet-stream:
* schema:
* type: string
* format: binary
* responses:
* 201:
* description: Image stored and linked
* content:
* application/json:
* schema:
* type: object
* properties:
* brand:
* type: object
* properties:
* id:
* type: integer
* fullHash:
* type: string
* thumbW:
* type: integer
* thumbH:
* type: integer
* thumbHash:
* type: string
* pics:
* type: array
* items:
* $ref: '#/components/schemas/BrandPic'
* 400:
* description: Missing body or invalid image
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 401:
* description: Unauthorized
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 403:
* description: Not authorized
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 404:
* description: Brand not found
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* delete:
* tags: [Brand]
* summary: Delete brand image
* description: Removes the brand's image. Sets thumbW, thumbH, thumbHash back to null.
* security:
* - cookieAuth: []
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: Brand id
* responses:
* 200:
* description: Image removed
* content:
* application/json:
* schema:
* type: object
* properties:
* brand:
* type: object
* properties:
* id:
* type: integer
* thumbW:
* type: integer
* nullable: true
* thumbH:
* type: integer
* nullable: true
* thumbHash:
* type: string
* nullable: true
* pics:
* type: array
* items:
* $ref: '#/components/schemas/BrandPic'
* 400:
* description: No company selected or invalid id
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 401:
* description: Unauthorized
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 403:
* description: Not authorized
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
* 404:
* description: Brand or image not found
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/Error'
*/
app.post(
`${basePath}/brand/:id/image`,
express.raw({ type: ['image/avif', 'image/webp', 'application/octet-stream'], limit: AVIF_BODY_LIMIT }),