Skip to content

Commit

Permalink
Merge pull request #82 from Financial-Times/Feature/UPPSF-5438
Browse files Browse the repository at this point in the history
Draft Annotations for FTA
  • Loading branch information
agrancharova authored Jul 30, 2024
2 parents 1627136 + 15a371f commit 6c7b2a4
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ executors:
ANNOTATIONS_ENDPOINT: http://localhost:9000/content/%v/annotations
INTERNAL_CONCORDANCES_ENDPOINT: http://localhost:9000/internalconcordances
JSON_SCHEMAS_PATH: ./schemas
JSON_SCHEMA_NAME: draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json
JSON_SCHEMA_NAME: draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json;draft-annotations-fta-add.json;draft-annotations-fta-replace.json;draft-annotations-fta-write.json
JSON_SCHEMAS_API_CONFIG_PATH: ./config/schemas-api-config.json
OPA_ADDRESS: "http://localhost:8181"

Expand Down
24 changes: 24 additions & 0 deletions config/schemas-api-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@
],
"schema_file_name": "draft-annotations-ftpc-write.json"
},
{
"http_method": "PUT",
"url": "/draft-annotations/content/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/annotations.*$",
"publication": [
"19d50190-8656-4e91-8d34-82e646ada9c9"
],
"schema_file_name": "draft-annotations-fta-write.json"
},
{
"http_method": "POST",
"url": "/draft-annotations/content/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/annotations.*$",
Expand All @@ -47,6 +55,14 @@
],
"schema_file_name": "draft-annotations-ftpc-add.json"
},
{
"http_method": "POST",
"url": "/draft-annotations/content/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/annotations.*$",
"publication": [
"19d50190-8656-4e91-8d34-82e646ada9c9"
],
"schema_file_name": "draft-annotations-fta-add.json"
},
{
"http_method": "PATCH",
"url": "/draft-annotations/content/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/annotations/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}.*$",
Expand All @@ -70,5 +86,13 @@
"724b5e36-6d45-4cf1-b1c2-3f676b21f21b"
],
"schema_file_name": "draft-annotations-ftpc-replace.json"
},
{
"http_method": "PATCH",
"url": "/draft-annotations/content/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/annotations/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}.*$",
"publication": [
"19d50190-8656-4e91-8d34-82e646ada9c9"
],
"schema_file_name": "draft-annotations-fta-replace.json"
}
]
4 changes: 2 additions & 2 deletions handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3034,15 +3034,15 @@ func TestValidate(t *testing.T) {
func TestListSchemas(t *testing.T) {
_ = os.Setenv("JSON_SCHEMAS_PATH", "../schemas")
_ = os.Setenv("JSON_SCHEMAS_API_CONFIG_PATH", "../config/schemas-api-config.json")
_ = os.Setenv("JSON_SCHEMA_NAME", "draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json")
_ = os.Setenv("JSON_SCHEMA_NAME", "draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json,;draft-annotations-fta-add.json;draft-annotations-fta-replace.json;draft-annotations-fta-write.json")

tests := []struct {
name string
expectedMessage string
}{
{
"List schemas",
`{"_links":{"application/vnd.ft-upp-annotations-ftpc-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-ftpc-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-ftpc-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-write.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-write.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-write.json","name":"latest-version"}],"self":{"href":"/draft-annotations/schemas"}}}`,
`{"_links":{"application/vnd.ft-upp-annotations-fta-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-fta-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-fta-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-fta-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-fta-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-fta-write.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-ftpc-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-ftpc-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-ftpc-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-ftpc-write.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-pac-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-pac-write.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-add.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-add.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-replace.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-replace.json","name":"latest-version"}],"application/vnd.ft-upp-annotations-sv-write.json":[{"href":"/draft-annotations/schemas/draft-annotations-sv-write.json","name":"latest-version"}],"self":{"href":"/draft-annotations/schemas"}}}`,
},
}

Expand Down
2 changes: 1 addition & 1 deletion helm/draft-annotations-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:
ANNOTATIONS_ENDPOINT: "" # This should be defined in the specific app-configs folder
INTERNAL_CONCORDANCES_ENDPOINT: "" # This should be defined in the specific app-configs folder
JSON_SCHEMAS_PATH: "/schemas"
JSON_SCHEMA_NAME: "draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json"
JSON_SCHEMA_NAME: "draft-annotations-pac-add.json;draft-annotations-pac-replace.json;draft-annotations-pac-write.json;draft-annotations-sv-add.json;draft-annotations-sv-replace.json;draft-annotations-sv-write.json;draft-annotations-ftpc-add.json;draft-annotations-ftpc-replace.json;draft-annotations-ftpc-write.json;draft-annotations-fta-add.json;draft-annotations-fta-replace.json;draft-annotations-fta-write.json"
JSON_SCHEMAS_API_CONFIG_PATH: "/config/schemas-api-config.json"
openPolicyAgentSidecar:
name: open-policy-agent
Expand Down
65 changes: 65 additions & 0 deletions schemas/draft-annotations-fta-add.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://upp-publishing-prod.ft.com/schema/draft-annotations-fta-add+json",
"title": "Draft FTA Annotations Add Endpoint",
"type": "object",
"description": "Schema for Draft FTA Annotations",
"properties": {
"annotation": {
"type": "object",
"description": "Schema for FTA Annotations",
"properties": {
"id": {
"type": "string",
"pattern": ".*/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$",
"description": "ID of the related concept"
},
"predicate": {
"type": "string",
"description": "Predicate of the annotation",
"enum": [
"http://www.ft.com/ontology/annotation/mentions",
"http://www.ft.com/ontology/classification/isClassifiedBy",
"http://www.ft.com/ontology/annotation/about",
"http://www.ft.com/ontology/hasDisplayTag",
"http://www.ft.com/ontology/annotation/isSponsoredBy"
]
},
"apiUrl": {
"type": "string",
"description": "API URL of the related concept"
},
"type": {
"type": "string",
"description": "Type of the related concept"
},
"prefLabel": {
"type": "string",
"description": "PrefLabel of the related concept"
},
"isFTAuthor": {
"type": "boolean",
"description": "Indicates whether the related concept is an FT author"
}
},
"required": [
"id",
"predicate"
],
"additionalProperties": false
},
"publication": {
"type": "array",
"description": "Indicates which titles are aware of this content",
"items": {
"type": "string",
"pattern": "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"
}
}
},
"required": [
"annotation",
"publication"
],
"additionalProperties": false
}
65 changes: 65 additions & 0 deletions schemas/draft-annotations-fta-replace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://upp-publishing-prod.ft.com/schema/draft-annotations-fta-add+json",
"title": "Draft FTA Annotations Replace Endpoint",
"type": "object",
"description": "Schema for Draft FTA Annotations",
"properties": {
"annotation": {
"type": "object",
"description": "Schema for FTA Annotations",
"properties": {
"id": {
"type": "string",
"pattern": ".*/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$",
"description": "ID of the related concept"
},
"predicate": {
"type": "string",
"description": "Predicate of the annotation",
"enum": [
"http://www.ft.com/ontology/annotation/mentions",
"http://www.ft.com/ontology/classification/isClassifiedBy",
"http://www.ft.com/ontology/annotation/about",
"http://www.ft.com/ontology/hasDisplayTag",
"http://www.ft.com/ontology/annotation/isSponsoredBy"
]
},
"apiUrl": {
"type": "string",
"description": "API URL of the related concept"
},
"type": {
"type": "string",
"description": "Type of the related concept"
},
"prefLabel": {
"type": "string",
"description": "PrefLabel of the related concept"
},
"isFTAuthor": {
"type": "boolean",
"description": "Indicates whether the related concept is an FT author"
}
},
"required": [
"id",
"predicate"
],
"additionalProperties": false
},
"publication": {
"type": "array",
"description": "Indicates which titles are aware of this content",
"items": {
"type": "string",
"pattern": "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"
}
}
},
"required": [
"annotation",
"publication"
],
"additionalProperties": false
}
74 changes: 74 additions & 0 deletions schemas/draft-annotations-fta-write.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://upp-publishing-prod.ft.com/schema/draft-annotations-fta-write+json",
"title": "Draft FTA Annotations",
"type": "object",
"description": "Schema for Draft FTA Annotations",
"properties": {
"annotations": {
"type": "array",
"description": "Draft FTA annotations",
"items": {
"$ref": "#/$defs/annotation"
}
},
"publication": {
"type": "array",
"description": "Indicates which titles are aware of this content",
"items": {
"type": "string",
"pattern": "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"
}
}
},
"required": [
"annotations",
"publication"
],
"additionalProperties": false,
"$defs": {
"annotation": {
"type": "object",
"description": "Schema for FTA Annotations",
"properties": {
"id": {
"type": "string",
"pattern": ".*/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$",
"description": "ID of the related concept"
},
"predicate": {
"type": "string",
"description": "Predicate of the annotation",
"enum": [
"http://www.ft.com/ontology/annotation/mentions",
"http://www.ft.com/ontology/classification/isClassifiedBy",
"http://www.ft.com/ontology/annotation/about",
"http://www.ft.com/ontology/hasDisplayTag",
"http://www.ft.com/ontology/annotation/isSponsoredBy"
]
},
"apiUrl": {
"type": "string",
"description": "API URL of the related concept"
},
"type": {
"type": "string",
"description": "Type of the related concept"
},
"prefLabel": {
"type": "string",
"description": "PrefLabel of the related concept"
},
"isFTAuthor": {
"type": "boolean",
"description": "Indicates whether the related concept is an FT author"
}
},
"required": [
"id",
"predicate"
],
"additionalProperties": false
}
}
}
2 changes: 1 addition & 1 deletion schemas/draft-annotations-ftpc-replace.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://upp-publishing-prod.ft.com/schema/draft-annotations-ftpc-add+json",
"title": "Draft FTPC Annotations Add Endpoint",
"title": "Draft FTPC Annotations Replace Endpoint",
"type": "object",
"description": "Schema for Draft FTPC Annotations",
"properties": {
Expand Down

0 comments on commit 6c7b2a4

Please sign in to comment.