Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Prod Release - v1.0.0 #15

Merged
merged 18 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
new PUT endpoints & metadata endpoints removed
  • Loading branch information
Sande3p committed Aug 17, 2021
commit 36d0772946cf55072023f0c5cc747586bd6ed026
272 changes: 60 additions & 212 deletions docs/skills-api.postman_collection.json

Large diffs are not rendered by default.

253 changes: 28 additions & 225 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ basePath: "/api/1.0"
tags:
- name: "Skills"
description: "Skills registered in the system"
- name: "Skill Metadata"
description: "Metadata for Skills registered in the system"
- name: "Taxonomies"
description: "Taxonomies registered in the system"
- name: "Taxonomy Metadata"
description: "Metadata for Taxonomies registered in the system"
schemes:
- "https"
consumes:
Expand Down Expand Up @@ -285,16 +281,16 @@ paths:
tags:
- "Skills"
description: >
Update an existing skill with given id.
Partically update an existing skill with given id.


**PERMISSION**

1. permission `UPDATE_SKILL` is required to perform this operation

2. permission `ADD_SKILL_METADATA` is required if any metadata field is provided.
2. permission `ADD_SKILL_METADATA` is required if any new metadata field is provided.

3. permission `DELETE_SKILL_METADATA` is required if there is any existing metadata field in the skill.
3. permission `UPDATE_SKILL_METADATA` is required if any metadata field provided already exist in the skill.
operationId: "skillsSkillIdPATCH"
parameters:
- name: "skillId"
Expand Down Expand Up @@ -329,105 +325,21 @@ paths:
- Bearer: []
x-swagger-router-controller: "Skills"

/skills/{skillId}/metadata:
put:
tags:
- "Skill Metadata"
description: >
Fully update the metadata of an existing skill with given id.

Used to entirely overwrite existing metadata.


**PERMISSION**

1. permission `ADD_SKILL_METADATA` is required if any metadata field is provided.

2. permission `DELETE_SKILL_METADATA` is required if there is any existing metadata field in the skill.
parameters:
- name: "skillId"
in: "path"
description: "The skill id"
required: true
type: "string"
format: "UUID"
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/SkillMetadataUpdateRequestBody"
responses:
"200":
description: "OK - the request was successful"
schema:
$ref: "#/definitions/Skill"
"400":
$ref: "#/definitions/BadRequest"
"401":
$ref: "#/definitions/Unauthorized"
"403":
$ref: "#/definitions/Forbidden"
"404":
$ref: "#/definitions/NotFound"
"500":
$ref: "#/definitions/ServerError"
security:
- Bearer: []
patch:
tags:
- "Skill Metadata"
- "Skills"
description: >
Partically update the metadata of an existing skill with given id.

Used to update existing fields in metadata and to add new fields to metadata.
Fully update an existing skill with given id.


**PERMISSION**

1. permission `ADD_SKILL_METADATA` is required if any new metadata field is provided.

2. permission `UPDATE_SKILL_METADATA` is required if any metadata field provided already exist in the skill.
parameters:
- name: "skillId"
in: "path"
description: "The skill id"
required: true
type: "string"
format: "UUID"
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/SkillMetadataUpdateRequestBody"
responses:
"200":
description: "OK - the request was successful"
schema:
$ref: "#/definitions/Skill"
"400":
$ref: "#/definitions/BadRequest"
"401":
$ref: "#/definitions/Unauthorized"
"403":
$ref: "#/definitions/Forbidden"
"404":
$ref: "#/definitions/NotFound"
"500":
$ref: "#/definitions/ServerError"
security:
- Bearer: []
delete:
tags:
- "Skill Metadata"
description: >
Remove fields from the metadata of an existing skill with given id.

404 error will be raised if one or more of the provided fields is missing in the existing metadata.

1. permission `UPDATE_SKILL` is required to perform this operation

**PERMISSION**
2. permission `ADD_SKILL_METADATA` is required if new metadata fields are provided.

Permission `DELETE_SKILL_METADATA` is required to perform this operation.
3. permission `DELETE_SKILL_METADATA` is required if there is any existing metadata field in the skill.
operationId: "skillsSkillIdPUT"
parameters:
- name: "skillId"
in: "path"
Expand All @@ -439,7 +351,7 @@ paths:
name: "body"
required: true
schema:
$ref: "#/definitions/SkillMetadataDeleteRequestBody"
$ref: "#/definitions/SkillRequestBody"
responses:
"200":
description: "OK - the request was successful"
Expand All @@ -453,10 +365,13 @@ paths:
$ref: "#/definitions/Forbidden"
"404":
$ref: "#/definitions/NotFound"
"409":
$ref: "#/definitions/Conflict"
"500":
$ref: "#/definitions/ServerError"
security:
- Bearer: []
x-swagger-router-controller: "Skills"

/taxonomies:
get:
Expand Down Expand Up @@ -674,16 +589,16 @@ paths:
tags:
- "Taxonomies"
description: >
Update an existing taxonomy with given id.
Partically update an existing taxonomy with given id.


**PERMISSION**

1. permission `UPDATE_TAXONOMY` is required to perform this operation

2. permission `ADD_TAXONOMY_METADATA` is required if any metadata field is provided.
2. permission `ADD_TAXONOMY_METADATA` is required if any new metadata field is provided.

3. permission `DELETE_TAXONOMY_METADATA` is required if there is any existing metadata field in the taxonomy.
3. permission `UPDATE_TAXONOMY_METADATA` is required if any metadata field provided already exist in the taxonomy.
operationId: "skillstaxonomiestaxonomyIdPATCH"
parameters:
- name: "taxonomyId"
Expand Down Expand Up @@ -717,105 +632,21 @@ paths:
security:
- Bearer: []
x-swagger-router-controller: "Taxonomy"
/taxonomies/{taxonomyId}/metadata:
put:
tags:
- "Taxonomy Metadata"
description: >
Fully update the metadata of an existing taxonomy with given id.

Used to entirely overwrite existing metadata.


**PERMISSION**

1. permission `ADD_TAXONOMY_METADATA` is required if any metadata field is provided.

2. permission `DELETE_TAXONOMY_METADATA` is required if there is any existing metadata field in the taxonomy.
parameters:
- name: "taxonomyId"
in: "path"
description: "The taxonomy id"
required: true
type: "string"
format: "UUID"
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/TaxonomyMetadataUpdateRequestBody"
responses:
"200":
description: "OK - the request was successful"
schema:
$ref: "#/definitions/Taxonomy"
"400":
$ref: "#/definitions/BadRequest"
"401":
$ref: "#/definitions/Unauthorized"
"403":
$ref: "#/definitions/Forbidden"
"404":
$ref: "#/definitions/NotFound"
"500":
$ref: "#/definitions/ServerError"
security:
- Bearer: []
patch:
tags:
- "Taxonomy Metadata"
- "Taxonomies"
description: >
Partically update the metadata of an existing taxonomy with given id.

Used to update existing fields in metadata and to add new fields to metadata.
Fully update an existing taxonomy with given id.


**PERMISSION**

1. permission `ADD_TAXONOMY_METADATA` is required if any new metadata field is provided.

2. permission `UPDATE_TAXONOMY_METADATA` is required if any metadata field provided already exist in the taxonomy.
parameters:
- name: "taxonomyId"
in: "path"
description: "The taxonomy id"
required: true
type: "string"
format: "UUID"
- in: "body"
name: "body"
required: true
schema:
$ref: "#/definitions/TaxonomyMetadataUpdateRequestBody"
responses:
"200":
description: "OK - the request was successful"
schema:
$ref: "#/definitions/Taxonomy"
"400":
$ref: "#/definitions/BadRequest"
"401":
$ref: "#/definitions/Unauthorized"
"403":
$ref: "#/definitions/Forbidden"
"404":
$ref: "#/definitions/NotFound"
"500":
$ref: "#/definitions/ServerError"
security:
- Bearer: []
delete:
tags:
- "Taxonomy Metadata"
description: >
Remove fields from the metadata of an existing taxonomy with given id.

404 error will be raised if one or more of the provided fields is missing in the existing metadata.

1. permission `UPDATE_TAXONOMY` is required to perform this operation

**PERMISSION**
2. permission `ADD_TAXONOMY_METADATA` is required if any metadata field is provided.

Permission `DELETE_TAXONOMY_METADATA` is required to perform this operation.
3. permission `DELETE_TAXONOMY_METADATA` is required if there is any existing metadata field in the taxonomy.
operationId: "skillstaxonomiestaxonomyIdPUT"
parameters:
- name: "taxonomyId"
in: "path"
Expand All @@ -827,7 +658,7 @@ paths:
name: "body"
required: true
schema:
$ref: "#/definitions/TaxonomyMetadataDeleteRequestBody"
$ref: "#/definitions/TaxonomyRequestBody"
responses:
"200":
description: "OK - the request was successful"
Expand All @@ -841,10 +672,13 @@ paths:
$ref: "#/definitions/Forbidden"
"404":
$ref: "#/definitions/NotFound"
"409":
$ref: "#/definitions/Conflict"
"500":
$ref: "#/definitions/ServerError"
security:
- Bearer: []
x-swagger-router-controller: "Taxonomy"

securityDefinitions:
Bearer:
Expand Down Expand Up @@ -954,26 +788,6 @@ definitions:
metadata:
challengeProminence: "challengeProminence"
memberProminence: "memberProminence"
SkillMetadataUpdateRequestBody:
type: "object"
description: "The metadata for a skill. Can contain arbitrary fields"
properties:
challengeProminence:
type: "string"
description: "The challenge prominence ranging from [0, 1]"
memberProminence:
type: "string"
description: "The member prominence ranging from [0, 1]"
example:
verions: "1.0.0"
random_field: "random_value"
SkillMetadataDeleteRequestBody:
type: "array"
description: "The list of fields to be removed from the metadata for a skill."
items:
type: string
description: "field name"
example: ["version", "random_field"]
Taxonomy:
allOf:
- type: "object"
Expand Down Expand Up @@ -1015,19 +829,8 @@ definitions:
description: "The metadata of the taxonomy."
example:
name: "name"
TaxonomyMetadataUpdateRequestBody:
type: "object"
description: "The metadata for a taxonomy. Can contain arbitrary fields"
example:
verions: "1.0.0"
random_field: "random_value"
TaxonomyMetadataDeleteRequestBody:
type: "array"
description: "The list of fields to be removed from the metadata for a taxonomy."
items:
type: string
description: "field name"
example: ["version", "random_field"]
metadata:
random_field_name_01: random_value_01
Unauthorized:
type: "object"
properties:
Expand Down
12 changes: 11 additions & 1 deletion src/common/controller-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ function getControllerMethods (service) {
res.json(await service.patch(req.params.id, req.body, req.authUser))
}

/**
* fully update entity by id
* @param req the http request
* @param res the http response
*/
async function fullyUpdate (req, res) {
res.json(await service.fullyUpdate(req.params.id, req.body, req.authUser))
}

/**
* get entity by id
* @param req the http request
Expand Down Expand Up @@ -59,7 +68,8 @@ function getControllerMethods (service) {
search,
remove,
get,
patch
patch,
fullyUpdate
}
}

Expand Down
Loading