From bad1f13c1e77f6c050172be4df6028cd361655f4 Mon Sep 17 00:00:00 2001 From: redmitry Date: Mon, 31 Jul 2023 15:47:33 +0200 Subject: [PATCH] received filters in summary to object --- .../{requests => common}/filteringTerms.json | 91 +++++++------------ .../json/requests/beaconRequestBody.json | 2 +- .../sections/beaconFilteringTermsResults.json | 4 +- .../beaconReceivedRequestSummary.json | 2 +- .../{requests => common}/filteringTerms.yaml | 46 +++------- framework/src/requests/beaconRequestBody.yaml | 2 +- .../sections/beaconFilteringTermsResults.yaml | 2 +- .../beaconReceivedRequestSummary.yaml | 2 +- 8 files changed, 55 insertions(+), 96 deletions(-) rename framework/json/{requests => common}/filteringTerms.json (76%) rename framework/src/{requests => common}/filteringTerms.yaml (80%) diff --git a/framework/json/requests/filteringTerms.json b/framework/json/common/filteringTerms.json similarity index 76% rename from framework/json/requests/filteringTerms.json rename to framework/json/common/filteringTerms.json index e513e28d4..35d898104 100644 --- a/framework/json/requests/filteringTerms.json +++ b/framework/json/common/filteringTerms.json @@ -1,15 +1,39 @@ { "$schema": "https://json-schema.org/draft/2020-12/schema", - "additionalProperties": true, "definitions": { - "AlphanumericFilter": { - "description": "Filter results based on operators and values applied to alphanumeric fields.", + "FilteringTerm": { + "title": "Filtering Term Element", + "type": "object", "properties": { "id": { - "description": "Field identfier to be queried.", - "example": "age", + "description": "Custom filter terms should contain a unique identifier.", + "examples": [ "demographic.ethnicity:asian" ], "type": "string" }, + "scope": { + "description": "The entry type to which the filter applies", + "examples": [ "biosamples" ], + "type": "string" + } + }, + "anyOf": [ + { + "$ref": "#/definitions/OntologyFilter" + }, + { + "$ref": "#/definitions/AlphanumericFilter" + }, + { + "$ref": "#/definitions/CustomFilter" + } + ], + "required": [ + "id" + ] + }, + "AlphanumericFilter": { + "description": "Filter results based on operators and values applied to alphanumeric fields.", + "properties": { "operator": { "default": "=", "description": "Defines how the value relates to the field `id`.", @@ -21,22 +45,16 @@ ">=", "<=" ], - "example": ">", - "type": "string" - }, - "scope": { - "description": "The entry type to which the filter applies", - "example": "biosamples", + "examples": [ ">" ], "type": "string" }, "value": { "description": "Alphanumeric search term to be used within the query which can contain wildcard characters (%) to denote any number of unknown characters. Values can be assocatied with units if applicable.", - "example": "P70Y", + "examples": [ "P70Y" ], "type": "string" } }, "required": [ - "id", "operator", "value" ], @@ -44,54 +62,16 @@ }, "CustomFilter": { "description": "Filter results to include records that contain a custom term defined by this Beacon.", - "properties": { - "id": { - "description": "Custom filter terms should contain a unique identifier.", - "example": "demographic.ethnicity:asian", - "type": "string" - }, - "scope": { - "description": "The entry type to which the filter applies", - "example": "biosamples", - "type": "string" - } - }, - "required": [ - "id" - ], "type": "object" }, - "FilteringTerm": { - "anyOf": [ - { - "$ref": "#/definitions/OntologyFilter" - }, - { - "$ref": "#/definitions/AlphanumericFilter" - }, - { - "$ref": "#/definitions/CustomFilter" - } - ] - }, "OntologyFilter": { "description": "Filter results to include records that contain a specific ontology term.", "properties": { - "id": { - "description": "Term ID to be queried, using CURIE syntax where possible.", - "example": "HP:0002664", - "type": "string" - }, "includeDescendantTerms": { "default": true, "description": "Define if the Beacon should implement the ontology hierarchy, thus query the descendant terms of `id`.", "type": "boolean" }, - "scope": { - "description": "The entry type to which the filter applies", - "example": "biosamples", - "type": "string" - }, "similarity": { "default": "exact", "description": "Allow the Beacon to return results which do not match the filter exactly, but do match to a certain degree of similarity. The Beacon defines the semantic similarity model implemented and how to apply the thresholds of 'high', 'medium' and 'low' similarity.", @@ -104,16 +84,13 @@ "type": "string" } }, - "required": [ - "id" - ], "type": "object" } }, "description": "Filtering terms are the main means to select subsets of records from a Beacon response. While the name implies the application to a generated response, in practice implementations may apply them at the query stage. Note: In the processing of Beacon v2.0 requests multiple filters are assumed to be chained by the logical AND operator.", + "title": "Filtering Term Element", + "type": "array", "items": { "$ref": "#/definitions/FilteringTerm" - }, - "title": "Filtering Term Element", - "type": "array" + } } \ No newline at end of file diff --git a/framework/json/requests/beaconRequestBody.json b/framework/json/requests/beaconRequestBody.json index 8b6116bf7..b9f906e0a 100644 --- a/framework/json/requests/beaconRequestBody.json +++ b/framework/json/requests/beaconRequestBody.json @@ -5,7 +5,7 @@ "description": "Parameters to limit the list of returned results.", "properties": { "filters": { - "$ref": "./filteringTerms.json", + "$ref": "../common/filteringTerms.json", "description": "Ontology based filters. Using CURIE syntax is encouraged." }, "includeResultsetResponses": { diff --git a/framework/json/responses/sections/beaconFilteringTermsResults.json b/framework/json/responses/sections/beaconFilteringTermsResults.json index e7a0ab74a..83a969955 100644 --- a/framework/json/responses/sections/beaconFilteringTermsResults.json +++ b/framework/json/responses/sections/beaconFilteringTermsResults.json @@ -31,8 +31,8 @@ } }, "required": [ - "type", - "id" + "id", + "type" ], "type": "object" }, diff --git a/framework/json/responses/sections/beaconReceivedRequestSummary.json b/framework/json/responses/sections/beaconReceivedRequestSummary.json index 56ad90674..e192b2636 100644 --- a/framework/json/responses/sections/beaconReceivedRequestSummary.json +++ b/framework/json/responses/sections/beaconReceivedRequestSummary.json @@ -7,7 +7,7 @@ "description": "API version expected by the client to be supported by the server and used in the response format." }, "filters": { - "$ref": "../../common/beaconCommonComponents.json#/definitions/Filters", + "$ref": "../../common/filteringTerms.json", "description": "Filters as submitted in the request." }, "includeResultsetResponses": { diff --git a/framework/src/requests/filteringTerms.yaml b/framework/src/common/filteringTerms.yaml similarity index 80% rename from framework/src/requests/filteringTerms.yaml rename to framework/src/common/filteringTerms.yaml index 66bae1332..d083448af 100644 --- a/framework/src/requests/filteringTerms.yaml +++ b/framework/src/common/filteringTerms.yaml @@ -11,21 +11,28 @@ items: $ref: '#/definitions/FilteringTerm' definitions: FilteringTerm: + properties: + id: + type: string + description: Term ID to be queried, using CURIE syntax where possible. + examples: + - HP:0002664 + scope: + type: string + description: The entry type to which the filter applies + examples: + - biosamples anyOf: - $ref: '#/definitions/OntologyFilter' - $ref: '#/definitions/AlphanumericFilter' - $ref: '#/definitions/CustomFilter' + required: + - id OntologyFilter: type: object description: Filter results to include records that contain a specific ontology term. - required: - - id properties: - id: - type: string - description: Term ID to be queried, using CURIE syntax where possible. - example: HP:0002664 includeDescendantTerms: type: boolean default: true @@ -43,23 +50,14 @@ definitions: exactly, but do match to a certain degree of similarity. The Beacon defines the semantic similarity model implemented and how to apply the thresholds of 'high', 'medium' and 'low' similarity. - scope: - type: string - description: The entry type to which the filter applies - example: biosamples AlphanumericFilter: description: Filter results based on operators and values applied to alphanumeric fields. type: object required: - - id - operator - value properties: - id: - type: string - description: Field identfier to be queried. - example: age operator: type: string enum: @@ -78,23 +76,7 @@ definitions: contain wildcard characters (%) to denote any number of unknown characters. Values can be assocatied with units if applicable. example: P70Y - scope: - type: string - description: The entry type to which the filter applies - example: biosamples CustomFilter: type: object description: Filter results to include records that contain a custom term defined - by this Beacon. - required: - - id - properties: - id: - type: string - description: Custom filter terms should contain a unique identifier. - example: demographic.ethnicity:asian - scope: - type: string - description: The entry type to which the filter applies - example: biosamples -additionalProperties: true + by this Beacon. \ No newline at end of file diff --git a/framework/src/requests/beaconRequestBody.yaml b/framework/src/requests/beaconRequestBody.yaml index 18fc1586b..fd4acca45 100644 --- a/framework/src/requests/beaconRequestBody.yaml +++ b/framework/src/requests/beaconRequestBody.yaml @@ -26,7 +26,7 @@ definitions: filters: description: >- Ontology based filters. Using CURIE syntax is encouraged. - $ref: ./filteringTerms.yaml + $ref: ../common/filteringTerms.yaml includeResultsetResponses: $ref: ../common/beaconCommonComponents.yaml#/definitions/IncludeResultsetResponses pagination: diff --git a/framework/src/responses/sections/beaconFilteringTermsResults.yaml b/framework/src/responses/sections/beaconFilteringTermsResults.yaml index 4c3bd96c3..05d251075 100644 --- a/framework/src/responses/sections/beaconFilteringTermsResults.yaml +++ b/framework/src/responses/sections/beaconFilteringTermsResults.yaml @@ -17,8 +17,8 @@ definitions: description: >- Entities can be filtered using this term. required: - - type - id + - type properties: type: type: string diff --git a/framework/src/responses/sections/beaconReceivedRequestSummary.yaml b/framework/src/responses/sections/beaconReceivedRequestSummary.yaml index c15df32dc..f27414671 100644 --- a/framework/src/responses/sections/beaconReceivedRequestSummary.yaml +++ b/framework/src/responses/sections/beaconReceivedRequestSummary.yaml @@ -23,7 +23,7 @@ properties: filters: description: >- Filters as submitted in the request. - $ref: ../../common/beaconCommonComponents.yaml#/definitions/Filters + $ref: ../../common/filteringTerms.yaml requestParameters: description: >- Dictionary of request parameters received in the `RequestBody` or as part