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 end
def unauthorized_integration def unauthorized_integration
render json: { error: "#{params[:source].capitalize} integration not configured" }, render json: { error: "#{params[:source]&.capitalize} integration not configured" },
status: :unauthorized status: :unauthorized
end end
end end

View file

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

View file

@ -102,60 +102,29 @@ RSpec.describe 'Api::V1::PhotosController', type: :request do
items: { items: {
type: :object, type: :object,
properties: { 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 }, id: { type: :string },
deviceAssetId: { type: :string }, latitude: { type: :number, format: :float },
ownerId: { type: :string }, longitude: { type: :number, format: :float },
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' },
localDateTime: { type: :string, format: 'date-time' }, localDateTime: { type: :string, format: 'date-time' },
updatedAt: { type: :string, format: 'date-time' }, originalFileName: { type: :string },
isFavorite: { type: :boolean }, city: { type: :string },
isArchived: { type: :boolean }, state: { type: :string },
isTrashed: { type: :boolean }, country: { type: :string },
duration: { type: :string }, type: { type: :string },
exifInfo: { source: { type: :string }
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 }
}, },
required: %w[id deviceAssetId ownerId type originalPath required: %w[id latitude longitude localDateTime originalFileName city state country type source]
originalFileName originalMimeType thumbhash
fileCreatedAt fileModifiedAt localDateTime
updatedAt isFavorite isArchived isTrashed duration
exifInfo checksum isOffline hasMetadata duplicateId resized]
} }
run_test! do |response| run_test! do |response|
@ -172,61 +141,24 @@ RSpec.describe 'Api::V1::PhotosController', type: :request do
produces 'application/json' produces 'application/json'
parameter name: :id, in: :path, type: :string, required: true parameter name: :id, in: :path, type: :string, required: true
parameter name: :api_key, in: :query, 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 response '200', 'photo found' do
schema type: :object, schema type: :object,
properties: { properties: {
id: { type: :string }, id: { type: :string },
deviceAssetId: { type: :string }, latitude: { type: :number, format: :float },
ownerId: { type: :string }, longitude: { type: :number, format: :float },
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' },
localDateTime: { type: :string, format: 'date-time' }, localDateTime: { type: :string, format: 'date-time' },
updatedAt: { type: :string, format: 'date-time' }, originalFileName: { type: :string },
isFavorite: { type: :boolean }, city: { type: :string },
isArchived: { type: :boolean }, state: { type: :string },
isTrashed: { type: :boolean }, country: { type: :string },
duration: { type: :string }, type: { type: :string },
exifInfo: { source: { type: :string }
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 }
} }
let(:id) { '7fe486e3-c3ba-4b54-bbf9-1281b39ed15c' } let(:id) { '7fe486e3-c3ba-4b54-bbf9-1281b39ed15c' }
let(:source) { 'immich' }
run_test! do |response| run_test! do |response|
data = JSON.parse(response.body) data = JSON.parse(response.body)
@ -238,6 +170,7 @@ RSpec.describe 'Api::V1::PhotosController', type: :request do
response '404', 'photo not found' do response '404', 'photo not found' do
let(:id) { 'nonexistent' } let(:id) { 'nonexistent' }
let(:api_key) { user.api_key } let(:api_key) { user.api_key }
let(:source) { 'immich' }
run_test! do |response| run_test! do |response|
data = JSON.parse(response.body) data = JSON.parse(response.body)

View file

@ -347,130 +347,38 @@ paths:
properties: properties:
id: id:
type: string type: string
deviceAssetId: latitude:
type: string type: number
ownerId: format: float
type: string longitude:
type: type: number
type: string format: float
originalPath:
type: string
originalFileName:
type: string
originalMimeType:
type: string
thumbhash:
type: string
fileCreatedAt:
type: string
format: date-time
fileModifiedAt:
type: string
format: date-time
localDateTime: localDateTime:
type: string type: string
format: date-time format: date-time
updatedAt: originalFileName:
type: string type: string
format: date-time city:
isFavorite:
type: boolean
isArchived:
type: boolean
isTrashed:
type: boolean
duration:
type: string type: string
exifInfo: state:
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:
type: string type: string
isOffline: country:
type: boolean type: string
hasMetadata: type:
type: boolean type: string
duplicateId: source:
type: string type: string
resized:
type: boolean
required: required:
- id - id
- deviceAssetId - latitude
- ownerId - longitude
- type
- originalPath
- originalFileName
- originalMimeType
- thumbhash
- fileCreatedAt
- fileModifiedAt
- localDateTime - localDateTime
- updatedAt - originalFileName
- isFavorite - city
- isArchived - state
- isTrashed - country
- duration - type
- exifInfo - source
- checksum
- isOffline
- hasMetadata
- duplicateId
- resized
"/api/v1/photos/{id}/thumbnail": "/api/v1/photos/{id}/thumbnail":
get: get:
summary: Retrieves a photo summary: Retrieves a photo
@ -487,6 +395,11 @@ paths:
required: true required: true
schema: schema:
type: string type: string
- name: source
in: query
required: true
schema:
type: string
responses: responses:
'200': '200':
description: photo found description: photo found
@ -497,107 +410,27 @@ paths:
properties: properties:
id: id:
type: string type: string
deviceAssetId: latitude:
type: string type: number
ownerId: format: float
type: string longitude:
type: type: number
type: string format: float
originalPath:
type: string
originalFileName:
type: string
originalMimeType:
type: string
thumbhash:
type: string
fileCreatedAt:
type: string
format: date-time
fileModifiedAt:
type: string
format: date-time
localDateTime: localDateTime:
type: string type: string
format: date-time format: date-time
updatedAt: originalFileName:
type: string type: string
format: date-time city:
isFavorite:
type: boolean
isArchived:
type: boolean
isTrashed:
type: boolean
duration:
type: string type: string
exifInfo: state:
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:
type: string type: string
isOffline: country:
type: boolean type: string
hasMetadata: type:
type: boolean type: string
duplicateId: source:
type: string type: string
resized:
type: boolean
'404': '404':
description: photo not found description: photo not found
"/api/v1/points": "/api/v1/points":