Fix swagger docs for /api/v1/photos/{id}/thumbnail

This commit is contained in:
Eugene Burmakin 2024-12-03 16:05:38 +01:00
parent ba2a95233c
commit 93e91e7944
4 changed files with 75 additions and 308 deletions

View file

@ -38,7 +38,7 @@ class Api::V1::PhotosController < ApiController
end
def unauthorized_integration
render json: { error: "#{params[:source].capitalize} integration not configured" },
render json: { error: "#{params[:source]&.capitalize} integration not configured" },
status: :unauthorized
end
end

View file

@ -17,7 +17,8 @@ RSpec.describe Import, type: :model do
google_phone_takeout: 3,
gpx: 4,
immich_api: 5,
geojson: 6
geojson: 6,
photoprism_api: 7
)
end
end

View file

@ -102,60 +102,29 @@ RSpec.describe 'Api::V1::PhotosController', type: :request do
items: {
type: :object,
properties: {
# {
# id: id,
# latitude: latitude,
# longitude: longitude,
# localDateTime: local_date_time,
# originalFileName: original_file_name,
# city: city,
# state: state,
# country: country,
# type: type,
# source: source
id: { type: :string },
deviceAssetId: { type: :string },
ownerId: { type: :string },
type: { type: :string },
originalPath: { type: :string },
originalFileName: { type: :string },
originalMimeType: { type: :string },
thumbhash: { type: :string },
fileCreatedAt: { type: :string, format: 'date-time' },
fileModifiedAt: { type: :string, format: 'date-time' },
latitude: { type: :number, format: :float },
longitude: { type: :number, format: :float },
localDateTime: { type: :string, format: 'date-time' },
updatedAt: { type: :string, format: 'date-time' },
isFavorite: { type: :boolean },
isArchived: { type: :boolean },
isTrashed: { type: :boolean },
duration: { type: :string },
exifInfo: {
type: :object,
properties: {
make: { type: :string },
model: { type: :string },
exifImageWidth: { type: :integer },
exifImageHeight: { type: :integer },
fileSizeInByte: { type: :integer },
orientation: { type: :string },
dateTimeOriginal: { type: :string, format: 'date-time' },
modifyDate: { type: :string, format: 'date-time' },
timeZone: { type: :string },
lensModel: { type: :string },
fNumber: { type: :number, format: :float },
focalLength: { type: :number, format: :float },
iso: { type: :integer },
exposureTime: { type: :string },
latitude: { type: :number, format: :float },
longitude: { type: :number, format: :float },
city: { type: :string },
state: { type: :string },
country: { type: :string },
description: { type: :string },
projectionType: { type: %i[string null] },
rating: { type: %i[integer null] }
}
},
checksum: { type: :string },
isOffline: { type: :boolean },
hasMetadata: { type: :boolean },
duplicateId: { type: :string },
resized: { type: :boolean }
originalFileName: { type: :string },
city: { type: :string },
state: { type: :string },
country: { type: :string },
type: { type: :string },
source: { type: :string }
},
required: %w[id deviceAssetId ownerId type originalPath
originalFileName originalMimeType thumbhash
fileCreatedAt fileModifiedAt localDateTime
updatedAt isFavorite isArchived isTrashed duration
exifInfo checksum isOffline hasMetadata duplicateId resized]
required: %w[id latitude longitude localDateTime originalFileName city state country type source]
}
run_test! do |response|
@ -172,61 +141,24 @@ RSpec.describe 'Api::V1::PhotosController', type: :request do
produces 'application/json'
parameter name: :id, in: :path, type: :string, required: true
parameter name: :api_key, in: :query, type: :string, required: true
parameter name: :source, in: :query, type: :string, required: true
response '200', 'photo found' do
schema type: :object,
properties: {
id: { type: :string },
deviceAssetId: { type: :string },
ownerId: { type: :string },
type: { type: :string },
originalPath: { type: :string },
originalFileName: { type: :string },
originalMimeType: { type: :string },
thumbhash: { type: :string },
fileCreatedAt: { type: :string, format: 'date-time' },
fileModifiedAt: { type: :string, format: 'date-time' },
latitude: { type: :number, format: :float },
longitude: { type: :number, format: :float },
localDateTime: { type: :string, format: 'date-time' },
updatedAt: { type: :string, format: 'date-time' },
isFavorite: { type: :boolean },
isArchived: { type: :boolean },
isTrashed: { type: :boolean },
duration: { type: :string },
exifInfo: {
type: :object,
properties: {
make: { type: :string },
model: { type: :string },
exifImageWidth: { type: :integer },
exifImageHeight: { type: :integer },
fileSizeInByte: { type: :integer },
orientation: { type: :string },
dateTimeOriginal: { type: :string, format: 'date-time' },
modifyDate: { type: :string, format: 'date-time' },
timeZone: { type: :string },
lensModel: { type: :string },
fNumber: { type: :number, format: :float },
focalLength: { type: :number, format: :float },
iso: { type: :integer },
exposureTime: { type: :string },
latitude: { type: :number, format: :float },
longitude: { type: :number, format: :float },
city: { type: :string },
state: { type: :string },
country: { type: :string },
description: { type: :string },
projectionType: { type: %i[string null] },
rating: { type: %i[integer null] }
}
},
checksum: { type: :string },
isOffline: { type: :boolean },
hasMetadata: { type: :boolean },
duplicateId: { type: :string },
resized: { type: :boolean }
originalFileName: { type: :string },
city: { type: :string },
state: { type: :string },
country: { type: :string },
type: { type: :string },
source: { type: :string }
}
let(:id) { '7fe486e3-c3ba-4b54-bbf9-1281b39ed15c' }
let(:source) { 'immich' }
run_test! do |response|
data = JSON.parse(response.body)
@ -238,6 +170,7 @@ RSpec.describe 'Api::V1::PhotosController', type: :request do
response '404', 'photo not found' do
let(:id) { 'nonexistent' }
let(:api_key) { user.api_key }
let(:source) { 'immich' }
run_test! do |response|
data = JSON.parse(response.body)

View file

@ -347,130 +347,38 @@ paths:
properties:
id:
type: string
deviceAssetId:
type: string
ownerId:
type: string
type:
type: string
originalPath:
type: string
originalFileName:
type: string
originalMimeType:
type: string
thumbhash:
type: string
fileCreatedAt:
type: string
format: date-time
fileModifiedAt:
type: string
format: date-time
latitude:
type: number
format: float
longitude:
type: number
format: float
localDateTime:
type: string
format: date-time
updatedAt:
originalFileName:
type: string
format: date-time
isFavorite:
type: boolean
isArchived:
type: boolean
isTrashed:
type: boolean
duration:
city:
type: string
exifInfo:
type: object
properties:
make:
type: string
model:
type: string
exifImageWidth:
type: integer
exifImageHeight:
type: integer
fileSizeInByte:
type: integer
orientation:
type: string
dateTimeOriginal:
type: string
format: date-time
modifyDate:
type: string
format: date-time
timeZone:
type: string
lensModel:
type: string
fNumber:
type: number
format: float
focalLength:
type: number
format: float
iso:
type: integer
exposureTime:
type: string
latitude:
type: number
format: float
longitude:
type: number
format: float
city:
type: string
state:
type: string
country:
type: string
description:
type: string
projectionType:
type:
- string
- 'null'
rating:
type:
- integer
- 'null'
checksum:
state:
type: string
isOffline:
type: boolean
hasMetadata:
type: boolean
duplicateId:
country:
type: string
type:
type: string
source:
type: string
resized:
type: boolean
required:
- id
- deviceAssetId
- ownerId
- type
- originalPath
- originalFileName
- originalMimeType
- thumbhash
- fileCreatedAt
- fileModifiedAt
- latitude
- longitude
- localDateTime
- updatedAt
- isFavorite
- isArchived
- isTrashed
- duration
- exifInfo
- checksum
- isOffline
- hasMetadata
- duplicateId
- resized
- originalFileName
- city
- state
- country
- type
- source
"/api/v1/photos/{id}/thumbnail":
get:
summary: Retrieves a photo
@ -487,6 +395,11 @@ paths:
required: true
schema:
type: string
- name: source
in: query
required: true
schema:
type: string
responses:
'200':
description: photo found
@ -497,107 +410,27 @@ paths:
properties:
id:
type: string
deviceAssetId:
type: string
ownerId:
type: string
type:
type: string
originalPath:
type: string
originalFileName:
type: string
originalMimeType:
type: string
thumbhash:
type: string
fileCreatedAt:
type: string
format: date-time
fileModifiedAt:
type: string
format: date-time
latitude:
type: number
format: float
longitude:
type: number
format: float
localDateTime:
type: string
format: date-time
updatedAt:
originalFileName:
type: string
format: date-time
isFavorite:
type: boolean
isArchived:
type: boolean
isTrashed:
type: boolean
duration:
city:
type: string
exifInfo:
type: object
properties:
make:
type: string
model:
type: string
exifImageWidth:
type: integer
exifImageHeight:
type: integer
fileSizeInByte:
type: integer
orientation:
type: string
dateTimeOriginal:
type: string
format: date-time
modifyDate:
type: string
format: date-time
timeZone:
type: string
lensModel:
type: string
fNumber:
type: number
format: float
focalLength:
type: number
format: float
iso:
type: integer
exposureTime:
type: string
latitude:
type: number
format: float
longitude:
type: number
format: float
city:
type: string
state:
type: string
country:
type: string
description:
type: string
projectionType:
type:
- string
- 'null'
rating:
type:
- integer
- 'null'
checksum:
state:
type: string
isOffline:
type: boolean
hasMetadata:
type: boolean
duplicateId:
country:
type: string
type:
type: string
source:
type: string
resized:
type: boolean
'404':
description: photo not found
"/api/v1/points":