diff --git a/api-documentation/editor/swagger.yaml b/api-documentation/editor/swagger.yaml index b1ca229d..fb0a492f 100644 --- a/api-documentation/editor/swagger.yaml +++ b/api-documentation/editor/swagger.yaml @@ -31,6 +31,9 @@ tags: - name: Metadata description: Access metadata and documentation available for the studies in the catalog + - name: Templates + description: Templates + x-tagGroups: - name: Editor @@ -41,6 +44,7 @@ x-tagGroups: - External resources - Datafile - Variable + - Templates - name: Collections tags: @@ -50,7 +54,10 @@ x-tagGroups: - Catalog - name: Metadata tags: - - Metadata + - Metadata + - name: Templates + tags: + - Templates schemes: - http paths: @@ -552,6 +559,29 @@ paths: description: successful operation security: - ApiKeyAuth: [] + /collections/template: + post: + tags: + - Collections + - Templates + summary: Set template for collection + description: Set template for all projects in a collection + operationId: SetTemplateForCollection + consumes: + - application/json + produces: + - application/json + parameters: + - in: "body" + name: "body" + required: true + schema: + $ref: "#/definitions/TemplateForCollection" + responses: + '200': + description: successful operation + security: + - ApiKeyAuth: [] /resources/{projectId}: get: tags: @@ -851,8 +881,162 @@ paths: description: successful operation security: - ApiKeyAuth: [] + /templates: + get: + tags: + - Templates + summary: List templates + description: Get a list of all templates + operationId: listTemplates + consumes: + - application/json + produces: + - application/json + responses: + '200': + description: successful operation + security: + - ApiKeyAuth: [] + post: + tags: + - Templates + summary: Create template + description: Create a new template + operationId: createTemplate + consumes: + - application/json + produces: + - application/json + parameters: + - in: "body" + name: "body" + required: true + schema: + $ref: "template-schema.json" + responses: + '200': + description: successful operation + security: + - ApiKeyAuth: [] + /templates/{uid}: + get: + tags: + - Templates + summary: Get template by UID + description: Get template by UID + operationId: getTemplate + consumes: + - application/json + produces: + - application/json + parameters: + - in: "path" + name: "uid" + type: string + required: true + responses: + '200': + description: successful operation + security: + - ApiKeyAuth: [] + /templates/duplicate/{uid}: + post: + tags: + - Templates + summary: Duplicate template + description: Create duplicate template + operationId: duplicateTemplate + consumes: + - application/json + produces: + - application/json + parameters: + - in: "path" + name: "uid" + type: string + description: Template UID to create a duplicate + required: true + responses: + '200': + description: successful operation + security: + - ApiKeyAuth: [] + /templates/update/{uid}: + post: + tags: + - Templates + summary: Update template + description: Update template + operationId: updateTemplate + consumes: + - application/json + produces: + - application/json + parameters: + - in: "path" + name: "uid" + type: string + description: Template UID to update + required: true + - in: "body" + name: "body" + required: true + schema: + $ref: "#/definitions/Template" + responses: + '200': + description: successful operation + security: + - ApiKeyAuth: [] + /templates/delete/{uid}: + post: + tags: + - Templates + summary: Delete template + description: Delete template + operationId: deleteTemplate + consumes: + - application/json + produces: + - application/json + parameters: + - in: "path" + name: "uid" + type: string + description: Template UID to delete + required: true + responses: + '200': + description: successful operation + security: + - ApiKeyAuth: [] ############################################################### definitions: + Template: + type: object + properties: + type: + type: string + required: true + template: + type: object + xml: + name: template + TemplateForCollection: + type: object + properties: + collection_id: + type: integer + required: true + template_uid: + type: string + required: true + project_type: + type: string + required: true + description: survey, timeseries, table, document, geospatial, ... + xml: + name: TemplateForCollection Collection: type: object properties: diff --git a/api-documentation/editor/template-schema.json b/api-documentation/editor/template-schema.json new file mode 100644 index 00000000..7764cd90 --- /dev/null +++ b/api-documentation/editor/template-schema.json @@ -0,0 +1,133 @@ +{ + "$id": "http://ihsn.org/schemas/template", + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Template schema", + "description": "Template schema", + "type": "object", + "definitions":{ + "item": { + "type": "object", + "title": "Item", + "description": "Item", + "properties":{ + "key": { + "type": "string", + "title": "Key", + "description": "unique item key" + }, + "title": { + "type": "string", + "title": "Title", + "description": "Item title" + }, + "help_text": { + "type": "string", + "title": "Help text", + "description": "Help text for the item" + }, + "display_type": { + "type": "string", + "title": "Display type", + "description": "Display type for the item e.g. text, number, date, etc." + }, + "is_required": { + "type": "boolean", + "title": "Required", + "description": "Is the item required?" + }, + "is_recommend": { + "type": "boolean", + "title": "Recommend", + "description": "Is the item recommended?" + }, + "items": { + "type": "array", + "title": "Items", + "description": "Sub items", + "items": { + "$ref": "#/definitions/item" + } + } + + } + } + }, + "properties": { + + "uid": { + "type": "string", + "title": "Template unique identifier", + "description": "Unique identifier for the template" + }, + + + + "metadata_information": { + "type": "object", + "description": "Metadata information", + "properties": { + "title": { + "type": "string", + "title": "Title", + "description": "Title of the document" + }, + "idno": { + "type": "string", + "title": "ID number", + "description": "Unique ID number for the document" + }, + "producers": { + "type": "array", + "title": "Producers", + "description": "List of producers", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "title": "Name", + "description": "Name of the producer" + }, + "abbr": { + "type": "string", + "title": "Abbreviation", + "description": "Abbreviation" + }, + "affiliation": { + "type": "string", + "title": "Affiliation", + "description": "Affiliation" + }, + "role": { + "type": "string", + "title": "Role", + "description": "Role" + } + } + } + }, + "production_date": { + "type": "string", + "title": "Production date", + "description": "Date of production" + }, + "version": { + "type": "string", + "title": "Version", + "description": "Document version" + } + } + }, + "template":{ + "type":"object", + "properties":{ + "items":{ + "type":"array", + "items":{ + "$ref": "#/definitions/item" + } + } + } + } + } +}