PHRAS-3153_Doc-to-Swagger

- add: finished searchraw
- change : using "additionalproperties" for key->values
[ci skip]
This commit is contained in:
jygaulier
2021-02-05 15:49:47 +01:00
parent 38d2639fca
commit 58f303547a
3 changed files with 732 additions and 121 deletions

View File

@@ -44,7 +44,7 @@ components:
description: ID of the record description: ID of the record
required: true required: true
schema: schema:
$ref: '#/components/parameters/sbas_id/schema' type: integer
paths: paths:
/me: /me:
get: get:
@@ -75,7 +75,6 @@ paths:
default: '' default: ''
- name: search_type - name: search_type
in: query in: query
description: 0 to search for records ; 1 to search for stories
required: false required: false
schema: schema:
type: integer type: integer
@@ -83,6 +82,8 @@ paths:
- 0 - 0
- 1 - 1
default: 0 default: 0
description: |
* `0` - search for records * `1` - search for stories
- name: page - name: page
in: query in: query
description: 'page number, from 1. Use along with "per_page"' description: 'page number, from 1. Use along with "per_page"'
@@ -184,7 +185,85 @@ paths:
type: array type: array
items: items:
allOf: allOf:
- $ref: '#/paths/~1records~1%7Bbase_id%7D/post/responses/200/content/application~1json/schema/properties/response/allOf/0' - type: object
properties:
databox_id:
type: integer
record_id:
type: integer
title:
type: string
original_name:
type: string
updated_on:
type: string
format: date-time
created_on:
type: string
format: date-time
collection_id:
type: integer
base_id:
type: integer
thumbnail:
type: object
properties:
name:
type: string
permalink:
type: object
properties:
created_on:
type: string
format: date-time
id:
type: integer
is_activated:
type: boolean
label:
type: string
updated_on:
type: string
format: date-time
page_url:
type: string
download_url:
type: string
url:
type: string
height:
type: integer
width:
type: integer
filesize:
type: integer
devices:
type: array
items:
type: string
enum:
- screen
- printer ?
player_type:
type: string
enum:
- IMAGE
mime_type:
type: string
substituted:
type: boolean
created_on:
type: string
format: date-time
updated_on:
type: string
format: date-time
url:
type: string
url_ttl:
type: integer
uuid:
type: string
- type: object - type: object
properties: properties:
children_offset: children_offset:
@@ -204,11 +283,209 @@ paths:
items: items:
type: object type: object
items: items:
$ref: '#/paths/~1records~1%7Bbase_id%7D/post/responses/200/content/application~1json/schema/properties/response' allOf:
- type: object
properties:
databox_id:
type: integer
record_id:
type: integer
title:
type: string
original_name:
type: string
updated_on:
type: string
format: date-time
created_on:
type: string
format: date-time
collection_id:
type: integer
base_id:
type: integer
thumbnail:
type: object
properties:
name:
type: string
permalink:
type: object
properties:
created_on:
type: string
format: date-time
id:
type: integer
is_activated:
type: boolean
label:
type: string
updated_on:
type: string
format: date-time
page_url:
type: string
download_url:
type: string
url:
type: string
height:
type: integer
width:
type: integer
filesize:
type: integer
devices:
type: array
items:
type: string
enum:
- screen
- printer ?
player_type:
type: string
enum:
- IMAGE
mime_type:
type: string
substituted:
type: boolean
created_on:
type: string
format: date-time
updated_on:
type: string
format: date-time
url:
type: string
url_ttl:
type: integer
uuid:
type: string
- type: object
properties:
mime_type:
type: string
technical_informations:
type: array
items:
type: object
properties:
name:
type: string
value:
type: string
sha256:
type: string
phrasea_type:
type: string
enum:
- image
- video
records: records:
type: array type: array
items: items:
$ref: '#/paths/~1records~1%7Bbase_id%7D/post/responses/200/content/application~1json/schema/properties/response' allOf:
- type: object
properties:
databox_id:
type: integer
record_id:
type: integer
title:
type: string
original_name:
type: string
updated_on:
type: string
format: date-time
created_on:
type: string
format: date-time
collection_id:
type: integer
base_id:
type: integer
thumbnail:
type: object
properties:
name:
type: string
permalink:
type: object
properties:
created_on:
type: string
format: date-time
id:
type: integer
is_activated:
type: boolean
label:
type: string
updated_on:
type: string
format: date-time
page_url:
type: string
download_url:
type: string
url:
type: string
height:
type: integer
width:
type: integer
filesize:
type: integer
devices:
type: array
items:
type: string
enum:
- screen
- printer ?
player_type:
type: string
enum:
- IMAGE
mime_type:
type: string
substituted:
type: boolean
created_on:
type: string
format: date-time
updated_on:
type: string
format: date-time
url:
type: string
url_ttl:
type: integer
uuid:
type: string
- type: object
properties:
mime_type:
type: string
technical_informations:
type: array
items:
type: object
properties:
name:
type: string
value:
type: string
sha256:
type: string
phrasea_type:
type: string
enum:
- image
- video
facets: facets:
type: array type: array
items: items:
@@ -250,12 +527,11 @@ paths:
- searchraw - searchraw
description: | description: |
Fulltext search for records or stories; Returns raw es Fulltext search for records or stories; Returns raw es
- pagination: use (offset/limit) OR (page/per_page) - pagination: use (offset/limit) OR (page/per_page)
parameters: parameters:
- name: query - name: query
in: query in: query
description: The fulltext query (<empty> = search all) description: Fulltext query (<empty> = search all)
required: false required: false
schema: schema:
type: string type: string
@@ -263,7 +539,6 @@ paths:
default: '' default: ''
- name: search_type - name: search_type
in: query in: query
description: 0 to search for records ; 1 to search for stories
required: false required: false
schema: schema:
type: integer type: integer
@@ -271,6 +546,10 @@ paths:
- 0 - 0
- 1 - 1
default: 0 default: 0
description: |
search for records or stories
* `0` - search for records
* `1` - search for stories
- name: page - name: page
in: query in: query
description: 'page number, from 1. Use along with "per_page"' description: 'page number, from 1. Use along with "per_page"'
@@ -312,7 +591,22 @@ paths:
type: object type: object
properties: properties:
meta: meta:
$ref: '#/paths/~1search/post/responses/200/content/application~1json/schema/properties/meta' type: object
properties:
api_version:
type: string
request:
type: string
response_time:
type: string
format: date-time
http_code:
type: integer
format: int32
error_type:
type: string
error_message:
type: string
response: response:
type: object type: object
properties: properties:
@@ -346,9 +640,9 @@ paths:
type: object type: object
properties: properties:
record_id: record_id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
collection_id: collection_id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
uuid: uuid:
type: string type: string
example: dcee40ea-ee26-4d8b-b0c2-d61305b03bc0 example: dcee40ea-ee26-4d8b-b0c2-d61305b03bc0
@@ -359,7 +653,7 @@ paths:
example: 7fad283de349b903c850548cda65cf2d86d24c4e3856cdc2b97e47430494b8c8 example: 7fad283de349b903c850548cda65cf2d86d24c4e3856cdc2b97e47430494b8c8
original_name: original_name:
type: string type: string
example: test001.jpg example: 1134340545.jpg
mime: mime:
type: string type: string
example: image/jpeg example: image/jpeg
@@ -375,61 +669,110 @@ paths:
format: date-time format: date-time
example: '2021-01-01 15:30:00' example: '2021-01-01 15:30:00'
coll_id: coll_id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
collection_name: collection_name:
type: string type: string
example: collection de test example: collection de test
witdh: witdh:
type: integer type: integer
example: 300 example: 5616
height: height:
type: integer type: integer
example: 401 example: 3744
size: size:
type: integer type: integer
example: 31266 example: 5618218
base_id: base_id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
databox_id: databox_id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
databox_name: databox_name:
type: string type: string
example: db_databox1 example: db_databox1
record_type: record_type:
type: string
enum: enum:
- record - record
- story - story
title:
type: object
description: 'key->value list, where (key) is the lng, and (value) the title in this lng.'
additionalProperties: true
example:
fr: titre en Français
en: title in english
'': undefined-lng title ? To be fixed
metadata_tags: metadata_tags:
type: object type: object
properties: description: 'key->value list, where (key) is the name of the metadata, and (value) the value.'
Channels: additionalProperties: true
type: integer example:
example: 3 Channels: 3
ColorDepth: ColorDepth: 8
type: integer ColorSpace: 0
example: 8 FileSize: 5618218
ColorSpace: Height: 3744
type: integer MimeType: image/jpeg
example: 0 Width: 5616
FileSize: caption:
type: integer type: object
example: 31266 description: |
Height: 'key->value list, where (key) is the field name, and (value) the value(s).'
type: integer 'nb: mono-valued field value is a 1 element array.'
example: 401 additionalProperties:
MimeType: type: array
items:
type: string type: string
example: image/jpeg example:
Width: Artist:
type: integer - Bob
example: 300 Title:
- Cropped Hand Of Person Holding Computer Mouse
Keywords:
- Hand
- Mouse (computer)
caption_all:
type: array
items:
type: string
description: |
'all fields values in a single array'
example:
- Bob
- Cropped Hand Of Person Holding Computer Mouse
- Hand
- Mouse (computer)
flags: flags:
type: object
description: 'key->value list, where (key) is the name of the flag (=status bit), and (value) is the boolean value.'
additionalProperties:
type: boolean
example:
public: true
color_checked: true
embargo: false
subdefs:
type: object
description: 'key->value list, where (key) is the name of the subdef, and (value) is the subdef object.'
additionalProperties:
type: object
example:
document:
type: object type: object
properties: properties:
_a_flag_name_: width: 5616
type: boolean height: 3744
_another_flag_name_: size: 5618218
type: boolean mime: image/jpeg
permalink: 'http://localhost/permalink/v1/2/34/document/1134340545.jpg?token=xrdMnK6peB...'
thumbnail:
type: object
properties:
width: 1024
height: 683
size: 20011
mime: image/jpeg
permalink: 'http://localhost/permalink/v1/2/34/preview/1134340545.jpg?token=E5aSbXQTmAz...'
took: took:
type: integer type: integer
description: Search duration in msec description: Search duration in msec
@@ -443,9 +786,40 @@ paths:
description: Total number of results description: Total number of results
example: 1 example: 1
facets: facets:
$ref: '#/paths/~1search/post/responses/200/content/application~1json/schema/properties/response/properties/facets' type: array
items:
type: object
properties:
name:
type: string
description: Unique internal name (=key) for the facet
example: _base
field:
type: string
description: 'Source field (from db structure). Can be also virtual field like "database" '
example: database
values:
type: array
items:
type: object
properties:
value:
type: string
description: Human readable value for the value
example: Demo
raw_value:
type: string
description: 'Real value, to be used to query'
example: db_demo
count:
type: integer
description: Number of items matching this value
query:
type: string
description: Formulated query to search items matching this facet
example: 'database:db_demo'
default: default:
$ref: '#/paths/~1search/post/responses/default' description: Any (other) error
'/records/{base_id}': '/records/{base_id}':
post: post:
tags: tags:
@@ -459,7 +833,7 @@ paths:
description: ID of the base description: ID of the base
required: true required: true
schema: schema:
$ref: '#/components/parameters/sbas_id/schema' type: integer
requestBody: requestBody:
content: content:
multipart/form-data: multipart/form-data:
@@ -468,7 +842,41 @@ paths:
type: object type: object
properties: properties:
body: body:
$ref: '#/paths/~1records~1%7Bbase_id%7D/post/requestBody/content/application~1json/schema/allOf/0' description: 'Metadata, status, collection, etc to be set for a record'
type: object
properties:
metadatas:
type: array
items:
type: object
properties:
field_name:
type: string
meta_struct_id:
type: integer
action:
type: string
enum:
- set
- add
- delete
- replace
value:
type: string
status:
type: array
items:
type: object
required:
- bit
- state
properties:
bit:
type: integer
minimum: 4
maximum: 31
state:
type: boolean
file: file:
description: uploaded file description: uploaded file
type: string type: string
@@ -488,7 +896,7 @@ paths:
field_name: field_name:
type: string type: string
meta_struct_id: meta_struct_id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
action: action:
type: string type: string
enum: enum:
@@ -521,15 +929,30 @@ paths:
type: object type: object
properties: properties:
meta: meta:
$ref: '#/paths/~1search/post/responses/200/content/application~1json/schema/properties/meta' type: object
properties:
api_version:
type: string
request:
type: string
response_time:
type: string
format: date-time
http_code:
type: integer
format: int32
error_type:
type: string
error_message:
type: string
response: response:
allOf: allOf:
- type: object - type: object
properties: properties:
databox_id: databox_id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
record_id: record_id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
title: title:
type: string type: string
original_name: original_name:
@@ -541,9 +964,9 @@ paths:
type: string type: string
format: date-time format: date-time
collection_id: collection_id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
base_id: base_id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
thumbnail: thumbnail:
type: object type: object
properties: properties:
@@ -556,7 +979,7 @@ paths:
type: string type: string
format: date-time format: date-time
id: id:
$ref: '#/components/parameters/sbas_id/schema' type: integer
is_activated: is_activated:
type: boolean type: boolean
label: label:
@@ -624,7 +1047,7 @@ paths:
- image - image
- video - video
default: default:
$ref: '#/paths/~1search/post/responses/default' description: Any (other) error
'/records/{sbas_id}/{record_id}': '/records/{sbas_id}/{record_id}':
get: get:
tags: tags:
@@ -633,19 +1056,148 @@ paths:
description: Returns a single record description: Returns a single record
operationId: getRecordById operationId: getRecordById
parameters: parameters:
- $ref: '#/components/parameters/sbas_id' - name: sbas_id
- $ref: '#/components/parameters/record_id' in: path
description: ID of the databox
required: true
schema:
type: integer
- name: record_id
in: path
description: ID of the record
required: true
schema:
type: integer
responses: responses:
'200': '200':
description: ok description: ok
content: content:
application/json: application/json:
schema: schema:
$ref: '#/paths/~1records~1%7Bbase_id%7D/post/responses/200/content/application~1json/schema' type: object
properties:
meta:
type: object
properties:
api_version:
type: string
request:
type: string
response_time:
type: string
format: date-time
http_code:
type: integer
format: int32
error_type:
type: string
error_message:
type: string
response:
allOf:
- type: object
properties:
databox_id:
type: integer
record_id:
type: integer
title:
type: string
original_name:
type: string
updated_on:
type: string
format: date-time
created_on:
type: string
format: date-time
collection_id:
type: integer
base_id:
type: integer
thumbnail:
type: object
properties:
name:
type: string
permalink:
type: object
properties:
created_on:
type: string
format: date-time
id:
type: integer
is_activated:
type: boolean
label:
type: string
updated_on:
type: string
format: date-time
page_url:
type: string
download_url:
type: string
url:
type: string
height:
type: integer
width:
type: integer
filesize:
type: integer
devices:
type: array
items:
type: string
enum:
- screen
- printer ?
player_type:
type: string
enum:
- IMAGE
mime_type:
type: string
substituted:
type: boolean
created_on:
type: string
format: date-time
updated_on:
type: string
format: date-time
url:
type: string
url_ttl:
type: integer
uuid:
type: string
- type: object
properties:
mime_type:
type: string
technical_informations:
type: array
items:
type: object
properties:
name:
type: string
value:
type: string
sha256:
type: string
phrasea_type:
type: string
enum:
- image
- video
'404': '404':
description: Record not found description: Record not found
default: default:
$ref: '#/paths/~1search/post/responses/default' description: Any (other) error
'/stories/{sbas_id}/{record_id}/children': '/stories/{sbas_id}/{record_id}/children':
get: get:
tags: tags:
@@ -654,8 +1206,18 @@ paths:
description: Returns children of a story description: Returns children of a story
operationId: getStoryChildren operationId: getStoryChildren
parameters: parameters:
- $ref: '#/components/parameters/sbas_id' - name: sbas_id
- $ref: '#/components/parameters/record_id' in: path
description: ID of the databox
required: true
schema:
type: integer
- name: record_id
in: path
description: ID of the record
required: true
schema:
type: integer
- name: page - name: page
in: query in: query
description: page number (default 1) description: page number (default 1)
@@ -677,7 +1239,22 @@ paths:
type: object type: object
properties: properties:
meta: meta:
$ref: '#/paths/~1search/post/responses/200/content/application~1json/schema/properties/meta' type: object
properties:
api_version:
type: string
request:
type: string
response_time:
type: string
format: date-time
http_code:
type: integer
format: int32
error_type:
type: string
error_message:
type: string
response: response:
type: array type: array
items: items:
@@ -686,4 +1263,4 @@ paths:
'404': '404':
description: Story (record) not found description: Story (record) not found
default: default:
$ref: '#/paths/~1search/post/responses/default' description: Any (other) error

View File

@@ -98,14 +98,14 @@ paths:
default: '' default: ''
- name: search_type - name: search_type
in: query in: query
description: 0 to search for records ; 1 to search for stories
required: false required: false
schema: schema:
type: integer type: integer
enum: enum: [0,1]
- 0
- 1
default: 0 default: 0
description: >
* `0` - search for records
* `1` - search for stories
- name: page - name: page
in: query in: query
description: page number, from 1. Use along with "per_page" description: page number, from 1. Use along with "per_page"
@@ -175,14 +175,14 @@ paths:
post: post:
tags: tags:
- searchraw - searchraw
description: | description: >
Fulltext search for records or stories; Returns raw es Fulltext search for records or stories; Returns raw es
- pagination: use (offset/limit) OR (page/per_page) - pagination: use (offset/limit) OR (page/per_page)
parameters: parameters:
- name: query - name: query
in: query in: query
description: 'The fulltext query (<empty> = search all)' description: 'Fulltext query (<empty> = search all)'
required: false required: false
schema: schema:
type: string type: string
@@ -190,14 +190,15 @@ paths:
default: '' default: ''
- name: search_type - name: search_type
in: query in: query
description: 0 to search for records ; 1 to search for stories
required: false required: false
schema: schema:
type: integer type: integer
enum: enum: [0,1]
- 0
- 1
default: 0 default: 0
description: >
search for records or stories
* `0` - search for records
* `1` - search for stories
- name: page - name: page
in: query in: query
description: page number, from 1. Use along with "per_page" description: page number, from 1. Use along with "per_page"

View File

@@ -84,7 +84,7 @@ ApiResponse_searchraw_response:
description: 'Search duration in msec' description: 'Search duration in msec'
example: example:
12 12
# offset: # offset:
# type: integer # type: integer
# description: 'Pagination offset as passed (or computed from "page/per_page") in request' # description: 'Pagination offset as passed (or computed from "page/per_page") in request'
# limit: # limit:
@@ -239,10 +239,6 @@ _Record_:
uuid: uuid:
type: string type: string
ESRecordsArray:
type: array
items:
$ref: '#/ESRecord'
ESRecord: ESRecord:
description: 'Raw response from es search on "record" index/mapping' description: 'Raw response from es search on "record" index/mapping'
type: object type: object
@@ -295,7 +291,7 @@ ESRecordSource:
original_name: original_name:
type: string type: string
example: example:
'test001.jpg' '1134340545.jpg'
mime: mime:
type: string type: string
example: example:
@@ -323,15 +319,15 @@ ESRecordSource:
witdh: witdh:
type: integer type: integer
example: example:
300 5616
height: height:
type: integer type: integer
example: example:
401 3744
size: size:
type: integer type: integer
example: example:
31266 5618218
base_id: base_id:
$ref: '#/ID' $ref: '#/ID'
databox_id: databox_id:
@@ -341,47 +337,84 @@ ESRecordSource:
example: example:
'db_databox1' 'db_databox1'
record_type: record_type:
enum: type: string
- 'record' enum: ['record','story']
- 'story' title:
type: object
description: 'key->value list, where (key) is the lng, and (value) the title in this lng.'
additionalProperties: true
example:
fr: 'titre en Français'
en: 'title in english'
'': 'undefined-lng title ? To be fixed'
metadata_tags: metadata_tags:
type: object type: object
properties: description: 'key->value list, where (key) is the name of the metadata, and (value) the value.'
Channels: additionalProperties: true
type: integer
example: example:
3 Channels: 3
ColorDepth: ColorDepth: 8
type: integer ColorSpace: 0
example: FileSize: 5618218
8 Height: 3744
ColorSpace: MimeType: 'image/jpeg'
type: integer Width: 5616
example: caption:
0 type: object
FileSize: description: >
type: integer 'key->value list, where (key) is the field name, and (value) the value(s).'
example:
31266 'nb: mono-valued field value is a 1 element array.'
Height: additionalProperties:
type: integer type: array
example: items:
401
MimeType:
type: string type: string
example: example:
'image/jpeg' Artist: ['Bob']
Width: Title: ['Cropped Hand Of Person Holding Computer Mouse']
type: integer Keywords: ['Hand', 'Mouse (computer)']
example: caption_all:
300 type: array
items:
type: string
description: >
'all fields values in a single array'
example: ['Bob','Cropped Hand Of Person Holding Computer Mouse','Hand','Mouse (computer)']
flags: flags:
$ref: '#/Flags'
subdefs:
type: object
description: 'key->value list, where (key) is the name of the subdef, and (value) is the subdef object.'
additionalProperties:
type: object
example:
document:
type: object type: object
properties: properties:
_a_flag_name_: width: 5616
type: boolean height: 3744
_another_flag_name_: size: 5618218
mime: 'image/jpeg'
permalink: 'http://localhost/permalink/v1/2/34/document/1134340545.jpg?token=xrdMnK6peB...'
thumbnail:
type: object
properties:
width: 1024
height: 683
size: 20011
mime: 'image/jpeg'
permalink: 'http://localhost/permalink/v1/2/34/preview/1134340545.jpg?token=E5aSbXQTmAz...'
Flags:
type: object
description: 'key->value list, where (key) is the name of the flag (=status bit), and (value) is the boolean value.'
additionalProperties:
type: boolean type: boolean
example:
public: true
color_checked: true
embargo: false
Record: Record:
allOf: # Combines the basic _Record_ and the records-only properties allOf: # Combines the basic _Record_ and the records-only properties
- $ref: '#/_Record_' - $ref: '#/_Record_'