From bc1b9f96ccb71d29bc85d29e626d2b6e9972f435 Mon Sep 17 00:00:00 2001 From: jygaulier Date: Mon, 8 Feb 2021 21:18:17 +0100 Subject: [PATCH] PHRAS-3153_Doc-to-Swagger - add: json examples for post/patch record [ci skip] --- API_documentation/v3/_compiled.yaml | 975 ++++++++++++---------------- API_documentation/v3/api.yaml | 482 ++++++++++++-- API_documentation/v3/schemas.yaml | 2 + 3 files changed, 859 insertions(+), 600 deletions(-) diff --git a/API_documentation/v3/_compiled.yaml b/API_documentation/v3/_compiled.yaml index e8c0315ef4..1708095191 100644 --- a/API_documentation/v3/_compiled.yaml +++ b/API_documentation/v3/_compiled.yaml @@ -44,7 +44,7 @@ components: description: ID of the record required: true schema: - type: integer + $ref: '#/components/parameters/sbas_id/schema' paths: /me: get: @@ -185,85 +185,7 @@ paths: type: array items: 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 + - $ref: '#/paths/~1records~1%7Bbase_id%7D/post/responses/200/content/application~1json/schema/properties/response/allOf/0' - type: object properties: children_offset: @@ -283,209 +205,11 @@ paths: items: type: object items: - 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 + $ref: '#/paths/~1records~1%7Bbase_id%7D/post/responses/200/content/application~1json/schema/properties/response' records: type: array items: - 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 + $ref: '#/paths/~1records~1%7Bbase_id%7D/post/responses/200/content/application~1json/schema/properties/response' facets: type: array items: @@ -591,22 +315,7 @@ paths: 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 + $ref: '#/paths/~1search/post/responses/200/content/application~1json/schema/properties/meta' response: type: object properties: @@ -640,9 +349,9 @@ paths: type: object properties: record_id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' collection_id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' uuid: type: string example: dcee40ea-ee26-4d8b-b0c2-d61305b03bc0 @@ -669,7 +378,7 @@ paths: format: date-time example: '2021-01-01 15:30:00' coll_id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' collection_name: type: string example: collection de test @@ -683,9 +392,9 @@ paths: type: integer example: 5618218 base_id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' databox_id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' databox_name: type: string example: db_databox1 @@ -786,46 +495,49 @@ paths: description: Total number of results example: 1 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' + $ref: '#/paths/~1search/post/responses/200/content/application~1json/schema/properties/response/properties/facets' default: - description: Any (other) error + $ref: '#/paths/~1search/post/responses/default' + '/records/{sbas_id}/{record_id}': + get: + tags: + - record + summary: Find record by sbas_id and record_id + description: Returns a single record + operationId: getRecordById + parameters: + - $ref: '#/components/parameters/sbas_id' + - $ref: '#/components/parameters/record_id' + responses: + '200': + description: ok + content: + application/json: + schema: + $ref: '#/paths/~1records~1%7Bbase_id%7D/post/responses/200/content/application~1json/schema' + '404': + description: Record not found + default: + $ref: '#/paths/~1search/post/responses/default' '/records/{base_id}': post: tags: - record summary: Creates a record - description: 'Creates a single record, including document and/or data.' + description: | + Creates a single record, including document and/or data. + + ### To create a record __with__ a file (document) + + _Since multipart is required to pass a file, json data must be passed as a part named "body"_ + + ### To create a record __without__ file + + _Since no file is passed, data can be passed as plain body_ + + ### metadata / status-bits setting + + see "PATCH" method for examples, apply only relevant "set" operation on just created record with empty data. operationId: createRecord parameters: - name: base_id @@ -833,57 +545,23 @@ paths: description: ID of the base required: true schema: - type: integer + $ref: '#/components/parameters/sbas_id/schema' requestBody: content: multipart/form-data: schema: - description: to create a record with a file (document) + description: to create a record __with__ a file (document) type: object properties: body: - 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 + $ref: '#/paths/~1records~1%7Bbase_id%7D/post/requestBody/content/application~1json/schema/allOf/0' file: description: uploaded file type: string format: binary application/json: schema: - description: to create a record without file (document) + description: To create a record __without__ file allOf: - description: 'Metadata, status, collection, etc to be set for a record' type: object @@ -896,7 +574,7 @@ paths: field_name: type: string meta_struct_id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' action: type: string enum: @@ -929,30 +607,15 @@ paths: 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 + $ref: '#/paths/~1search/post/responses/200/content/application~1json/schema/properties/meta' response: allOf: - type: object properties: databox_id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' record_id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' title: type: string original_name: @@ -964,9 +627,9 @@ paths: type: string format: date-time collection_id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' base_id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' thumbnail: type: object properties: @@ -979,7 +642,7 @@ paths: type: string format: date-time id: - type: integer + $ref: '#/components/parameters/sbas_id/schema' is_activated: type: boolean label: @@ -1047,157 +710,382 @@ paths: - image - video default: - description: Any (other) error - '/records/{sbas_id}/{record_id}': - get: + $ref: '#/paths/~1search/post/responses/default' + '/records/{sbas_id}/{record_id}/setmetadatas': + patch: tags: - record - summary: Find record by sbas_id and record_id - description: Returns a single record - operationId: getRecordById + summary: Set or change metadata and/or status-bits of a record + description: | + Set or change metadata and/or status-bits of a record. + + Data is sent as json in the BODY of the request. + + * metadatas is an array of simple “actions” that are applied in the same order as defined into json. + * field can be specified by meta_struct_id or by name + * field value (when relevant) can be specified by meta_id or by actual value + * method to match a value can be (strict | ignore-case | regexp); default is “ignore-case” + * to act on multi-values we must set an “action” (set | add | delete | replace); default is “set” + * default action “set” and special value (null, arrays) allow to write simplified actions + * the “replace” action is useful to set/add values only if a value already exists + + # Body examples : + + ## mono-valued fields + + set a mono-value field by its meta_struct_id + + ```json + { + "metadatas": [ + { + "meta_struct_id": 1, + "action": "set", + "value": "A pretty string" + } + ] + } + ``` + + + same thing (because default action is “set”), by field name + + ``` + { + "metadatas": [ + { + "field_name": "Author", + "value": "John Doe" + } + ] + } + ``` + + delete a mono-valued field + + ``` + { + "metadatas": [ + { + "field_name": "Copyright", + "action": "delete" + } + ] + } + ``` + + same thing + + ``` + { + "metadatas": [ + { + "field_name": "Copyright", + "value": null + } + ] + } + ``` + + ## multi-valued + + replace a keyword __if we know its meta-id__ + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "meta_id": 678, + "value": "Dog" + } + ] + } + ``` + + delete a specific keyword by its meta-id (we could also set action : “delete”, omit value, …) + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "meta_id": 345, + "value": null + } + ] + } + ``` + + delete a specific keyword by its value. Since we must pass the value (not null), we must set the action “delete” + + _nb_ : the default matching method is “ignore-case” so we can write the actual value all small letters + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "delete", + "value": "doggy" + } + ] + } + ``` + + delete __all Keywords__ + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "value": null + } + ] + } + ``` + + add a keyword + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "add", + "value": "Cat" + } + ] + } + ``` + + replace all keywords by new ones + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "value": null + }, + { + "field_name": "Keywords", + "action": "add", + "value": "Cat" + }, + { + "field_name": "Keywords", + "action": "add", + "value": "Dog" + } + ] + } + ``` + + same thing using an array + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "value": [ + "Dog", + "Cat", + ] + } + ] + } + ``` + + simplification of multiple same actions with arrays as value + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "delete", + "value": [ + "cop", + "bobby", + "pig", + "nicks" + ] + }, + { + "field_name": "Keywords", + "action": "add", + "value": [ + "Policeman", + "Arrest" + ] + } + ] + } + ``` + + replacing a keyword by value can be 2 actions if we know that the bad value exists… + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "delete", + "value": "cop" + }, + { + "field_name": "Keywords", + "action": "add", + "value": "Policeman" + } + ] + } + ``` + + replace-if-exists + + …but we can also use the “replace” action if we are not sure + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "replace", + "value": "cop", + "replace_with": "Policeman" + } + ] + } + ``` + + fix spelling errors with regexp + + ``` + { + "metadatas": [ + { + "field_name": "Persons", + "action": "replace", + "match_method": "regexp", + "value": "/joh?nn?[i|y]\w+hall?[i|y]day/\w+in\w([0-9]{4})/i", + "replace_with": "Johnny Halliday in $1" + } + ] + } + ``` + + add translations for existing keywords (using “replace”) + + _nb_ : multi-values are kept unique so double replacement is not a pb. + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "replace", + "value": "dog", + "replace_with": [ + "Dog", + "Chien" + ] + }, + { + "field_name": "Keywords", + "action": "replace", + "value": "chien", + "replace_with": [ + "Dog", + "Chien" + ] + } + ] + } + ``` + + same thing using regexp + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "replace", + "value": "/cop|bobby|pig|flic/i", + "match_method": "regexp", + "replace_with": [ + "Policeman", + "Policier" + ] + } + ] + } + ``` + + ## Status-bits + + sb can be changed with the same api. + + To not get confused with "names", sb are referenced by bit number only 4…31 + + ``` + { + "metadatas": [ + ... + ], + "status": [ + { + "bit": 4, + "state": true + }, + { + "bit": 5, + "state": false + }, + { + "bit": 6, + "state": false + }, + { + "bit": 7, + "state": false + } + ] + } + ``` + operationId: patchRecord parameters: - name: sbas_id in: path - description: ID of the databox + description: ID of the sbas required: true schema: - type: integer + $ref: '#/components/parameters/sbas_id/schema' - name: record_id in: path description: ID of the record required: true schema: - type: integer + $ref: '#/components/parameters/sbas_id/schema' + requestBody: + content: + application/json: + schema: + allOf: + - $ref: '#/paths/~1records~1%7Bbase_id%7D/post/requestBody/content/application~1json/schema/allOf/0' responses: '200': description: ok content: application/json: 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': - description: Record not found + $ref: '#/paths/~1records~1%7Bbase_id%7D/post/responses/200/content/application~1json/schema' default: - description: Any (other) error + $ref: '#/paths/~1search/post/responses/default' '/stories/{sbas_id}/{record_id}/children': get: tags: @@ -1206,18 +1094,8 @@ paths: description: Returns children of a story operationId: getStoryChildren parameters: - - name: sbas_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 + - $ref: '#/components/parameters/sbas_id' + - $ref: '#/components/parameters/record_id' - name: page in: query description: page number (default 1) @@ -1239,22 +1117,7 @@ paths: 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 + $ref: '#/paths/~1search/post/responses/200/content/application~1json/schema/properties/meta' response: type: array items: @@ -1263,4 +1126,4 @@ paths: '404': description: Story (record) not found default: - description: Any (other) error + $ref: '#/paths/~1search/post/responses/default' diff --git a/API_documentation/v3/api.yaml b/API_documentation/v3/api.yaml index 637c5b4462..13d3083ca6 100644 --- a/API_documentation/v3/api.yaml +++ b/API_documentation/v3/api.yaml @@ -244,50 +244,6 @@ paths: $ref: 'responses.yaml#/error_response' # ------------ record ----------- - '/records/{base_id}': - post: - tags: - - record - summary: Creates a record - description: 'Creates a single record, including document and/or data.' - operationId: createRecord - parameters: - - name: base_id - in: path - description: ID of the base - required: true - schema: - $ref: schemas.yaml#/ID - requestBody: - content: - multipart/form-data: - schema: - description: 'to create a record with a file (document)' - type: object - properties: - body: - $ref: schemas.yaml#/RecordPatch - file: - description : 'uploaded file' - type: string - format: binary - application/json: - schema: - description: 'to create a record without file (document)' - allOf: - - $ref: schemas.yaml#/RecordPatch - responses: - 200: - description: ok - content: - application/json: - schema: - $ref: schemas.yaml#/ApiResponse_record - default: - $ref: 'responses.yaml#/error_response' - # security: - # - api_key: [] - '/records/{sbas_id}/{record_id}': get: tags: @@ -309,6 +265,444 @@ paths: description: Record not found default: $ref: 'responses.yaml#/error_response' + + '/records/{base_id}': + post: + tags: + - record + summary: Creates a record + description: | + Creates a single record, including document and/or data. + + ### To create a record __with__ a file (document) + + _Since multipart is required to pass a file, json data must be passed as a part named "body"_ + + ### To create a record __without__ file + + _Since no file is passed, data can be passed as plain body_ + + ### metadata / status-bits setting + + see "PATCH" method for examples, apply only relevant "set" operation on just created record with empty data. + + operationId: createRecord + parameters: + - name: base_id + in: path + description: ID of the base + required: true + schema: + $ref: schemas.yaml#/ID + requestBody: + content: + multipart/form-data: + schema: + description: to create a record __with__ a file (document) + type: object + properties: + body: + $ref: schemas.yaml#/RecordPatch + file: + description : 'uploaded file' + type: string + format: binary + application/json: + schema: + description: To create a record __without__ file + allOf: + - $ref: schemas.yaml#/RecordPatch + responses: + 200: + description: ok + content: + application/json: + schema: + $ref: schemas.yaml#/ApiResponse_record + default: + $ref: 'responses.yaml#/error_response' + # security: + # - api_key: [] + + '/records/{sbas_id}/{record_id}/setmetadatas': + patch: + tags: + - record + summary: Set or change metadata and/or status-bits of a record + description: | + Set or change metadata and/or status-bits of a record. + + Data is sent as json in the BODY of the request. + + * metadatas is an array of simple “actions” that are applied in the same order as defined into json. + * field can be specified by meta_struct_id or by name + * field value (when relevant) can be specified by meta_id or by actual value + * method to match a value can be (strict | ignore-case | regexp); default is “ignore-case” + * to act on multi-values we must set an “action” (set | add | delete | replace); default is “set” + * default action “set” and special value (null, arrays) allow to write simplified actions + * the “replace” action is useful to set/add values only if a value already exists + + # Body examples : + + ## mono-valued fields + + set a mono-value field by its meta_struct_id + + ```json + { + "metadatas": [ + { + "meta_struct_id": 1, + "action": "set", + "value": "A pretty string" + } + ] + } + ``` + + + same thing (because default action is “set”), by field name + + ``` + { + "metadatas": [ + { + "field_name": "Author", + "value": "John Doe" + } + ] + } + ``` + + delete a mono-valued field + + ``` + { + "metadatas": [ + { + "field_name": "Copyright", + "action": "delete" + } + ] + } + ``` + + same thing + + ``` + { + "metadatas": [ + { + "field_name": "Copyright", + "value": null + } + ] + } + ``` + + ## multi-valued + + replace a keyword __if we know its meta-id__ + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "meta_id": 678, + "value": "Dog" + } + ] + } + ``` + + delete a specific keyword by its meta-id (we could also set action : “delete”, omit value, …) + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "meta_id": 345, + "value": null + } + ] + } + ``` + + delete a specific keyword by its value. Since we must pass the value (not null), we must set the action “delete” + + _nb_ : the default matching method is “ignore-case” so we can write the actual value all small letters + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "delete", + "value": "doggy" + } + ] + } + ``` + + delete __all Keywords__ + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "value": null + } + ] + } + ``` + + add a keyword + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "add", + "value": "Cat" + } + ] + } + ``` + + replace all keywords by new ones + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "value": null + }, + { + "field_name": "Keywords", + "action": "add", + "value": "Cat" + }, + { + "field_name": "Keywords", + "action": "add", + "value": "Dog" + } + ] + } + ``` + + same thing using an array + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "value": [ + "Dog", + "Cat", + ] + } + ] + } + ``` + + simplification of multiple same actions with arrays as value + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "delete", + "value": [ + "cop", + "bobby", + "pig", + "nicks" + ] + }, + { + "field_name": "Keywords", + "action": "add", + "value": [ + "Policeman", + "Arrest" + ] + } + ] + } + ``` + + replacing a keyword by value can be 2 actions if we know that the bad value exists… + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "delete", + "value": "cop" + }, + { + "field_name": "Keywords", + "action": "add", + "value": "Policeman" + } + ] + } + ``` + + replace-if-exists + + …but we can also use the “replace” action if we are not sure + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "replace", + "value": "cop", + "replace_with": "Policeman" + } + ] + } + ``` + + fix spelling errors with regexp + + ``` + { + "metadatas": [ + { + "field_name": "Persons", + "action": "replace", + "match_method": "regexp", + "value": "/joh?nn?[i|y]\w+hall?[i|y]day/\w+in\w([0-9]{4})/i", + "replace_with": "Johnny Halliday in $1" + } + ] + } + ``` + + add translations for existing keywords (using “replace”) + + _nb_ : multi-values are kept unique so double replacement is not a pb. + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "replace", + "value": "dog", + "replace_with": [ + "Dog", + "Chien" + ] + }, + { + "field_name": "Keywords", + "action": "replace", + "value": "chien", + "replace_with": [ + "Dog", + "Chien" + ] + } + ] + } + ``` + + same thing using regexp + + ``` + { + "metadatas": [ + { + "field_name": "Keywords", + "action": "replace", + "value": "/cop|bobby|pig|flic/i", + "match_method": "regexp", + "replace_with": [ + "Policeman", + "Policier" + ] + } + ] + } + ``` + + ## Status-bits + + sb can be changed with the same api. + + To not get confused with "names", sb are referenced by bit number only 4…31 + + ``` + { + "metadatas": [ + ... + ], + "status": [ + { + "bit": 4, + "state": true + }, + { + "bit": 5, + "state": false + }, + { + "bit": 6, + "state": false + }, + { + "bit": 7, + "state": false + } + ] + } + ``` + + operationId: patchRecord + parameters: + - name: sbas_id + in: path + description: ID of the sbas + required: true + schema: + $ref: schemas.yaml#/ID + - name: record_id + in: path + description: ID of the record + required: true + schema: + $ref: schemas.yaml#/ID + + requestBody: + content: + application/json: + schema: + allOf: + - $ref: schemas.yaml#/RecordPatch + responses: + 200: + description: ok + content: + application/json: + schema: + $ref: schemas.yaml#/ApiResponse_record + default: + $ref: 'responses.yaml#/error_response' + + '/stories/{sbas_id}/{record_id}/children': get: tags: diff --git a/API_documentation/v3/schemas.yaml b/API_documentation/v3/schemas.yaml index 8da941b9a0..1c41793243 100644 --- a/API_documentation/v3/schemas.yaml +++ b/API_documentation/v3/schemas.yaml @@ -15,6 +15,8 @@ RecordPatch_metadata: value: # todo : change to string, int, number, array type: string + + RecordPatch_status: type: object required: