diff --git a/apps/schematic/api/.openapi-generator/FILES b/apps/schematic/api/.openapi-generator/FILES index 2e57b51219..b69a7d46a7 100644 --- a/apps/schematic/api/.openapi-generator/FILES +++ b/apps/schematic/api/.openapi-generator/FILES @@ -13,6 +13,9 @@ schematic_api/models/__init__.py schematic_api/models/asset_type.py schematic_api/models/base_model_.py schematic_api/models/basic_error.py +schematic_api/models/component_requirements_array.py +schematic_api/models/component_requirements_graph.py +schematic_api/models/component_requirements_subgraph.py schematic_api/models/connected_node_pair.py schematic_api/models/connected_node_pair_array.py schematic_api/models/connected_node_pair_page.py diff --git a/apps/schematic/api/schematic_api/controllers/schema_controller.py b/apps/schematic/api/schematic_api/controllers/schema_controller.py index 80fbed68bd..f25abb6a6a 100644 --- a/apps/schematic/api/schematic_api/controllers/schema_controller.py +++ b/apps/schematic/api/schematic_api/controllers/schema_controller.py @@ -5,6 +5,12 @@ from typing import Union from schematic_api.models.basic_error import BasicError # noqa: E501 +from schematic_api.models.component_requirements_array import ( + ComponentRequirementsArray, +) # noqa: E501 +from schematic_api.models.component_requirements_graph import ( + ComponentRequirementsGraph, +) # noqa: E501 from schematic_api.models.connected_node_pair_array import ( ConnectedNodePairArray, ) # noqa: E501 @@ -42,6 +48,48 @@ def get_component( ) +def get_component_requirements_array( + component_label, schema_url, display_label_type=None +): # noqa: E501 + """Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in array form. + + Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in array form. # noqa: E501 + + :param component_label: The label of a component in a schema + :type component_label: str + :param schema_url: The URL of a schema in jsonld or csv form + :type schema_url: str + :param display_label_type: The type of label to display + :type display_label_type: str + + :rtype: Union[ComponentRequirementsArray, Tuple[ComponentRequirementsArray, int], Tuple[ComponentRequirementsArray, int, Dict[str, str]] + """ + return schema_controller_impl.get_component_requirements_array( + component_label, schema_url, display_label_type + ) + + +def get_component_requirements_graph( + component_label, schema_url, display_label_type=None +): # noqa: E501 + """Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in graph form. + + Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in graph form. # noqa: E501 + + :param component_label: The label of a component in a schema + :type component_label: str + :param schema_url: The URL of a schema in jsonld or csv form + :type schema_url: str + :param display_label_type: The type of label to display + :type display_label_type: str + + :rtype: Union[ComponentRequirementsGraph, Tuple[ComponentRequirementsGraph, int], Tuple[ComponentRequirementsGraph, int, Dict[str, str]] + """ + return schema_controller_impl.get_component_requirements_graph( + component_label, schema_url, display_label_type + ) + + def get_connected_node_pair_array( schema_url, relationship_type, display_label_type=None ): # noqa: E501 diff --git a/apps/schematic/api/schematic_api/controllers/schema_controller_impl.py b/apps/schematic/api/schematic_api/controllers/schema_controller_impl.py index 72e8699b6b..f9f6182976 100644 --- a/apps/schematic/api/schematic_api/controllers/schema_controller_impl.py +++ b/apps/schematic/api/schematic_api/controllers/schema_controller_impl.py @@ -9,8 +9,12 @@ from schematic.visualization.attributes_explorer import AttributesExplorer # type: ignore from schematic.utils.schema_utils import get_property_label_from_display_name # type: ignore from schematic.utils.schema_utils import DisplayLabelType # type: ignore +from schematic.models.metadata import MetadataModel # type: ignore from schematic_api.models.basic_error import BasicError +from schematic_api.models.component_requirements_subgraph import ( + ComponentRequirementsSubgraph, +) from schematic_api.models.node_property_array import NodePropertyArray from schematic_api.models.validation_rule import ValidationRule from schematic_api.models.validation_rule_array import ValidationRuleArray @@ -62,6 +66,70 @@ def get_component( return result, status +@handle_exceptions +def get_component_requirements_array( + component_label: str, + schema_url: str, + display_label_type: DisplayLabelType, +) -> tuple[Union[list[str], BasicError], int]: + """Gets the input components required components + Args: + component_label (str): The label of the component + schema_url (str): The URL of the schema in json form + display_label_type (DisplayLabelType): + The type of label to use as display + Defaults to "class_label" + Returns: + tuple[Union[ComponentRequirementArray, BasicError], int]: A tuple + item 1 is either the required coponents or an error + item 2 is the status + """ + schema_path = download_schema_file_as_jsonld(schema_url) + metadata_model = MetadataModel( + inputMModelLocation=schema_path, + inputMModelLocationType="local", + data_model_labels=display_label_type, + ) + result = metadata_model.get_component_requirements( + source_component=component_label, as_graph=False + ) + status = 200 + return result, status + + +@handle_exceptions +def get_component_requirements_graph( + component_label: str, + schema_url: str, + display_label_type: DisplayLabelType, +) -> tuple[Union[list[ComponentRequirementsSubgraph], BasicError], int]: + """Gets the input components required components + Args: + component_label (str): The label of the component + schema_url (str): The URL of the schema in json form + display_label_type (DisplayLabelType): + The type of label to use as display + Defaults to "class_label" + Returns: + tuple[Union[ComponentRequirementsSubgrpah, BasicError], int]: A tuple + item 1 is either the required coponents or an error + item 2 is the status + """ + schema_path = download_schema_file_as_jsonld(schema_url) + metadata_model = MetadataModel( + inputMModelLocation=schema_path, + inputMModelLocationType="local", + data_model_labels=display_label_type, + ) + results = metadata_model.get_component_requirements( + source_component=component_label, as_graph=True + ) + result = [ComponentRequirementsSubgraph(result[0], result[1]) for result in results] + + status = 200 + return result, status + + def get_connected_node_pairs_from_schematic( relationship_type: str, schema_url: str, diff --git a/apps/schematic/api/schematic_api/models/__init__.py b/apps/schematic/api/schematic_api/models/__init__.py index 20d7f19caf..37a388b3b2 100644 --- a/apps/schematic/api/schematic_api/models/__init__.py +++ b/apps/schematic/api/schematic_api/models/__init__.py @@ -5,6 +5,9 @@ # import models into model package from schematic_api.models.asset_type import AssetType from schematic_api.models.basic_error import BasicError +from schematic_api.models.component_requirements_array import ComponentRequirementsArray +from schematic_api.models.component_requirements_graph import ComponentRequirementsGraph +from schematic_api.models.component_requirements_subgraph import ComponentRequirementsSubgraph from schematic_api.models.connected_node_pair import ConnectedNodePair from schematic_api.models.connected_node_pair_array import ConnectedNodePairArray from schematic_api.models.connected_node_pair_page import ConnectedNodePairPage diff --git a/apps/schematic/api/schematic_api/models/component_requirements_array.py b/apps/schematic/api/schematic_api/models/component_requirements_array.py new file mode 100644 index 0000000000..6dae96dcba --- /dev/null +++ b/apps/schematic/api/schematic_api/models/component_requirements_array.py @@ -0,0 +1,64 @@ +# coding: utf-8 + +from __future__ import absolute_import +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from schematic_api.models.base_model_ import Model +from schematic_api import util + + +class ComponentRequirementsArray(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + def __init__(self, component_requirements_list=None): # noqa: E501 + """ComponentRequirementsArray - a model defined in OpenAPI + + :param component_requirements_list: The component_requirements_list of this ComponentRequirementsArray. # noqa: E501 + :type component_requirements_list: List[str] + """ + self.openapi_types = { + 'component_requirements_list': List[str] + } + + self.attribute_map = { + 'component_requirements_list': 'componentRequirementsList' + } + + self._component_requirements_list = component_requirements_list + + @classmethod + def from_dict(cls, dikt) -> 'ComponentRequirementsArray': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The ComponentRequirementsArray of this ComponentRequirementsArray. # noqa: E501 + :rtype: ComponentRequirementsArray + """ + return util.deserialize_model(dikt, cls) + + @property + def component_requirements_list(self): + """Gets the component_requirements_list of this ComponentRequirementsArray. + + + :return: The component_requirements_list of this ComponentRequirementsArray. + :rtype: List[str] + """ + return self._component_requirements_list + + @component_requirements_list.setter + def component_requirements_list(self, component_requirements_list): + """Sets the component_requirements_list of this ComponentRequirementsArray. + + + :param component_requirements_list: The component_requirements_list of this ComponentRequirementsArray. + :type component_requirements_list: List[str] + """ + + self._component_requirements_list = component_requirements_list diff --git a/apps/schematic/api/schematic_api/models/component_requirements_graph.py b/apps/schematic/api/schematic_api/models/component_requirements_graph.py new file mode 100644 index 0000000000..10fff96445 --- /dev/null +++ b/apps/schematic/api/schematic_api/models/component_requirements_graph.py @@ -0,0 +1,66 @@ +# coding: utf-8 + +from __future__ import absolute_import +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from schematic_api.models.base_model_ import Model +from schematic_api.models.component_requirements_subgraph import ComponentRequirementsSubgraph +from schematic_api import util + +from schematic_api.models.component_requirements_subgraph import ComponentRequirementsSubgraph # noqa: E501 + +class ComponentRequirementsGraph(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + def __init__(self, component_requirements_graph=None): # noqa: E501 + """ComponentRequirementsGraph - a model defined in OpenAPI + + :param component_requirements_graph: The component_requirements_graph of this ComponentRequirementsGraph. # noqa: E501 + :type component_requirements_graph: List[ComponentRequirementsSubgraph] + """ + self.openapi_types = { + 'component_requirements_graph': List[ComponentRequirementsSubgraph] + } + + self.attribute_map = { + 'component_requirements_graph': 'componentRequirementsGraph' + } + + self._component_requirements_graph = component_requirements_graph + + @classmethod + def from_dict(cls, dikt) -> 'ComponentRequirementsGraph': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The ComponentRequirementsGraph of this ComponentRequirementsGraph. # noqa: E501 + :rtype: ComponentRequirementsGraph + """ + return util.deserialize_model(dikt, cls) + + @property + def component_requirements_graph(self): + """Gets the component_requirements_graph of this ComponentRequirementsGraph. + + + :return: The component_requirements_graph of this ComponentRequirementsGraph. + :rtype: List[ComponentRequirementsSubgraph] + """ + return self._component_requirements_graph + + @component_requirements_graph.setter + def component_requirements_graph(self, component_requirements_graph): + """Sets the component_requirements_graph of this ComponentRequirementsGraph. + + + :param component_requirements_graph: The component_requirements_graph of this ComponentRequirementsGraph. + :type component_requirements_graph: List[ComponentRequirementsSubgraph] + """ + + self._component_requirements_graph = component_requirements_graph diff --git a/apps/schematic/api/schematic_api/models/component_requirements_subgraph.py b/apps/schematic/api/schematic_api/models/component_requirements_subgraph.py new file mode 100644 index 0000000000..6c54af1354 --- /dev/null +++ b/apps/schematic/api/schematic_api/models/component_requirements_subgraph.py @@ -0,0 +1,98 @@ +# coding: utf-8 + +from __future__ import absolute_import +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from schematic_api.models.base_model_ import Model +from schematic_api import util + + +class ComponentRequirementsSubgraph(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + def __init__(self, component1=None, component2=None): # noqa: E501 + """ComponentRequirementsSubgraph - a model defined in OpenAPI + + :param component1: The component1 of this ComponentRequirementsSubgraph. # noqa: E501 + :type component1: str + :param component2: The component2 of this ComponentRequirementsSubgraph. # noqa: E501 + :type component2: str + """ + self.openapi_types = { + 'component1': str, + 'component2': str + } + + self.attribute_map = { + 'component1': 'component1', + 'component2': 'component2' + } + + self._component1 = component1 + self._component2 = component2 + + @classmethod + def from_dict(cls, dikt) -> 'ComponentRequirementsSubgraph': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The ComponentRequirementsSubgraph of this ComponentRequirementsSubgraph. # noqa: E501 + :rtype: ComponentRequirementsSubgraph + """ + return util.deserialize_model(dikt, cls) + + @property + def component1(self): + """Gets the component1 of this ComponentRequirementsSubgraph. + + The display name of the first component in the graph # noqa: E501 + + :return: The component1 of this ComponentRequirementsSubgraph. + :rtype: str + """ + return self._component1 + + @component1.setter + def component1(self, component1): + """Sets the component1 of this ComponentRequirementsSubgraph. + + The display name of the first component in the graph # noqa: E501 + + :param component1: The component1 of this ComponentRequirementsSubgraph. + :type component1: str + """ + if component1 is None: + raise ValueError("Invalid value for `component1`, must not be `None`") # noqa: E501 + + self._component1 = component1 + + @property + def component2(self): + """Gets the component2 of this ComponentRequirementsSubgraph. + + The display name of the second component in the graph # noqa: E501 + + :return: The component2 of this ComponentRequirementsSubgraph. + :rtype: str + """ + return self._component2 + + @component2.setter + def component2(self, component2): + """Sets the component2 of this ComponentRequirementsSubgraph. + + The display name of the second component in the graph # noqa: E501 + + :param component2: The component2 of this ComponentRequirementsSubgraph. + :type component2: str + """ + if component2 is None: + raise ValueError("Invalid value for `component2`, must not be `None`") # noqa: E501 + + self._component2 = component2 diff --git a/apps/schematic/api/schematic_api/openapi/openapi.yaml b/apps/schematic/api/schematic_api/openapi/openapi.yaml index 1b172b056c..be7590e70f 100644 --- a/apps/schematic/api/schematic_api/openapi/openapi.yaml +++ b/apps/schematic/api/schematic_api/openapi/openapi.yaml @@ -1202,6 +1202,116 @@ paths: tags: - Schema x-openapi-router-controller: schematic_api.controllers.schema_controller + /components/{componentLabel}/requirementsArray: + get: + description: "Given a source model component (see https://w3id.org/biolink/vocab/category\ + \ for definnition of component), return all components required by it in array\ + \ form." + operationId: get_component_requirements_array + parameters: + - description: The label of a component in a schema + explode: false + in: path + name: componentLabel + required: true + schema: + $ref: '#/components/schemas/ComponentLabel' + style: simple + - description: The URL of a schema in jsonld or csv form + explode: true + in: query + name: schemaUrl + required: true + schema: + $ref: '#/components/schemas/SchemaUrl' + style: form + - description: The type of label to display + explode: true + in: query + name: displayLabelType + required: false + schema: + default: class_label + enum: + - class_label + - display_label + type: string + style: form + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ComponentRequirementsArray' + description: Success + "500": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/BasicError' + description: The request cannot be fulfilled due to an unexpected server + error + summary: "Given a source model component (see https://w3id.org/biolink/vocab/category\ + \ for definnition of component), return all components required by it in array\ + \ form." + tags: + - Schema + x-openapi-router-controller: schematic_api.controllers.schema_controller + /components/{componentLabel}/requirementsGraph: + get: + description: "Given a source model component (see https://w3id.org/biolink/vocab/category\ + \ for definnition of component), return all components required by it in graph\ + \ form." + operationId: get_component_requirements_graph + parameters: + - description: The label of a component in a schema + explode: false + in: path + name: componentLabel + required: true + schema: + $ref: '#/components/schemas/ComponentLabel' + style: simple + - description: The URL of a schema in jsonld or csv form + explode: true + in: query + name: schemaUrl + required: true + schema: + $ref: '#/components/schemas/SchemaUrl' + style: form + - description: The type of label to display + explode: true + in: query + name: displayLabelType + required: false + schema: + default: class_label + enum: + - class_label + - display_label + type: string + style: form + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/ComponentRequirementsGraph' + description: Success + "500": + content: + application/problem+json: + schema: + $ref: '#/components/schemas/BasicError' + description: The request cannot be fulfilled due to an unexpected server + error + summary: "Given a source model component (see https://w3id.org/biolink/vocab/category\ + \ for definnition of component), return all components required by it in graph\ + \ form." + tags: + - Schema + x-openapi-router-controller: schematic_api.controllers.schema_controller /connectedNodePairArray: get: description: Gets a array of connected node pairs @@ -3302,6 +3412,59 @@ components: description: The label of a component in a schema example: MolecularEntity type: string + ComponentRequirementsArray: + description: An array of components + example: + componentRequirementsList: + - componentRequirementsList + - componentRequirementsList + properties: + componentRequirementsList: + items: + type: string + title: componentRequirementsList + type: array + title: ComponentRequirementsArray + type: object + ComponentRequirementsSubgraph: + description: A pair of components + example: + component1: component1 + component2: component2 + properties: + component1: + description: The display name of the first component in the graph + example: component1 + title: component1 + type: string + component2: + description: The display name of the second component in the graph + example: component2 + title: component2 + type: string + required: + - component1 + - component2 + title: ComponentRequirementsSubgraph + type: object + x-java-class-annotations: + - '@lombok.Builder' + ComponentRequirementsGraph: + description: A graph of components + example: + componentRequirementsGraph: + - component1: component1 + component2: component2 + - component1: component1 + component2: component2 + properties: + componentRequirementsGraph: + items: + $ref: '#/components/schemas/ComponentRequirementsSubgraph' + title: componentRequirementsGraph + type: array + title: ComponentRequirementsGraph + type: object RelationshipType: description: A type of schema relationship example: requiresDependency diff --git a/apps/schematic/api/schematic_api/test/test_schema_controller_impl.py b/apps/schematic/api/schematic_api/test/test_schema_controller_impl.py index 93e4e7cb2d..d4e90819c9 100644 --- a/apps/schematic/api/schematic_api/test/test_schema_controller_impl.py +++ b/apps/schematic/api/schematic_api/test/test_schema_controller_impl.py @@ -2,6 +2,9 @@ # pylint: disable=duplicate-code from schematic_api.models.basic_error import BasicError +from schematic_api.models.component_requirements_subgraph import ( + ComponentRequirementsSubgraph, +) from schematic_api.models.node_property_array import NodePropertyArray from schematic_api.models.validation_rule import ValidationRule from schematic_api.models.validation_rule_array import ValidationRuleArray @@ -13,6 +16,8 @@ from schematic_api.models.connected_node_pair import ConnectedNodePair from schematic_api.controllers.schema_controller_impl import ( get_component, + get_component_requirements_array, + get_component_requirements_graph, get_connected_node_pair_page, get_connected_node_pair_array, get_node_is_required, @@ -45,6 +50,60 @@ def test_internal_error(self, test_schema_url: str) -> None: assert isinstance(result, BasicError) +class TestGetComponentRequirementsArray: + """Tests get_component_requirements_array""" + + def test_success(self, test_schema_url: str) -> None: + """Test for successful result""" + result, status = get_component_requirements_array( + component_label="Biospecimen", + schema_url=test_schema_url, + display_label_type="class_label", + ) + assert status == 200 + assert isinstance(result, list) + for req in result: + assert isinstance(req, str) + + def test_internal_error(self, test_schema_url: str) -> None: + """Test for 500 result""" + result, status = get_component_requirements_array( + component_label="not_a_component", + schema_url=test_schema_url, + display_label_type="class_label", + ) + assert status == 500 + assert isinstance(result, BasicError) + + +class TestGetComponentRequirementsGraph: + """Tests get_component_requirements_graph""" + + def test_success(self, test_schema_url: str) -> None: + """Test for successful result""" + result, status = get_component_requirements_graph( + component_label="Biospecimen", + schema_url=test_schema_url, + display_label_type="class_label", + ) + assert status == 200 + assert isinstance(result, list) + for subgraph in result: + assert isinstance(subgraph, ComponentRequirementsSubgraph) + assert isinstance(subgraph.component1, str) + assert isinstance(subgraph.component2, str) + + def test_internal_error(self, test_schema_url: str) -> None: + """Test for 500 result""" + result, status = get_component_requirements_graph( + component_label="not_a_component", + schema_url=test_schema_url, + display_label_type="class_label", + ) + assert status == 500 + assert isinstance(result, BasicError) + + class TestGetConnectedNodePairArray: """Tests get_connected_node_pair_array""" diff --git a/libs/schematic/api-description/build/openapi.yaml b/libs/schematic/api-description/build/openapi.yaml index 29c3b502d6..8238c8f99e 100644 --- a/libs/schematic/api-description/build/openapi.yaml +++ b/libs/schematic/api-description/build/openapi.yaml @@ -623,6 +623,48 @@ paths: type: string '500': $ref: '#/components/responses/InternalServerError' + /components/{componentLabel}/requirementsArray: + parameters: + - $ref: '#/components/parameters/componentLabel' + get: + tags: + - Schema + summary: Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in array form. + description: Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in array form. + operationId: getComponentRequirementsArray + parameters: + - $ref: '#/components/parameters/schemaUrl' + - $ref: '#/components/parameters/displayLabelType' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ComponentRequirementsArray' + '500': + $ref: '#/components/responses/InternalServerError' + /components/{componentLabel}/requirementsGraph: + parameters: + - $ref: '#/components/parameters/componentLabel' + get: + tags: + - Schema + summary: Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in graph form. + description: Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in graph form. + operationId: getComponentRequirementsGraph + parameters: + - $ref: '#/components/parameters/schemaUrl' + - $ref: '#/components/parameters/displayLabelType' + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: '#/components/schemas/ComponentRequirementsGraph' + '500': + $ref: '#/components/responses/InternalServerError' /schemaAttributes: get: tags: @@ -1284,6 +1326,39 @@ components: description: The label of a component in a schema type: string example: MolecularEntity + ComponentRequirementsArray: + type: object + description: An array of components + properties: + componentRequirementsList: + type: array + items: + type: string + ComponentRequirementsSubgraph: + type: object + description: A pair of components + properties: + component1: + type: string + description: The display name of the first component in the graph + example: component1 + component2: + type: string + description: The display name of the second component in the graph + example: component2 + required: + - component1 + - component2 + x-java-class-annotations: + - '@lombok.Builder' + ComponentRequirementsGraph: + type: object + description: A graph of components + properties: + componentRequirementsGraph: + type: array + items: + $ref: '#/components/schemas/ComponentRequirementsSubgraph' RelationshipType: description: A type of schema relationship type: string diff --git a/libs/schematic/api-description/src/components/schemas/ComponentRequirementsArray.yaml b/libs/schematic/api-description/src/components/schemas/ComponentRequirementsArray.yaml new file mode 100644 index 0000000000..1a6ff6436a --- /dev/null +++ b/libs/schematic/api-description/src/components/schemas/ComponentRequirementsArray.yaml @@ -0,0 +1,7 @@ +type: object +description: An array of components +properties: + componentRequirementsList: + type: array + items: + type: string diff --git a/libs/schematic/api-description/src/components/schemas/ComponentRequirementsGraph.yaml b/libs/schematic/api-description/src/components/schemas/ComponentRequirementsGraph.yaml new file mode 100644 index 0000000000..dca156b3aa --- /dev/null +++ b/libs/schematic/api-description/src/components/schemas/ComponentRequirementsGraph.yaml @@ -0,0 +1,7 @@ +type: object +description: A graph of components +properties: + componentRequirementsGraph: + type: array + items: + $ref: ComponentRequirementsSubgraph.yaml diff --git a/libs/schematic/api-description/src/components/schemas/ComponentRequirementsSubgraph.yaml b/libs/schematic/api-description/src/components/schemas/ComponentRequirementsSubgraph.yaml new file mode 100644 index 0000000000..6a22a9c1bb --- /dev/null +++ b/libs/schematic/api-description/src/components/schemas/ComponentRequirementsSubgraph.yaml @@ -0,0 +1,16 @@ +type: object +description: A pair of components +properties: + component1: + type: string + description: The display name of the first component in the graph + example: component1 + component2: + type: string + description: The display name of the second component in the graph + example: component2 +required: + - component1 + - component2 +x-java-class-annotations: + - '@lombok.Builder' diff --git a/libs/schematic/api-description/src/openapi.yaml b/libs/schematic/api-description/src/openapi.yaml index 944ffdf4b2..ebd57d8ec9 100644 --- a/libs/schematic/api-description/src/openapi.yaml +++ b/libs/schematic/api-description/src/openapi.yaml @@ -89,6 +89,12 @@ paths: /components/{componentLabel}/: $ref: paths/components/@{componentLabel}/component.yaml + /components/{componentLabel}/requirementsArray: + $ref: paths/components/@{componentLabel}/requirementsArray.yaml + + /components/{componentLabel}/requirementsGraph: + $ref: paths/components/@{componentLabel}/requirementsGraph.yaml + /schemaAttributes: $ref: paths/schemaAttributes.yaml diff --git a/libs/schematic/api-description/src/paths/components/@{componentLabel}/requirementsArray.yaml b/libs/schematic/api-description/src/paths/components/@{componentLabel}/requirementsArray.yaml new file mode 100644 index 0000000000..b450d5e93d --- /dev/null +++ b/libs/schematic/api-description/src/paths/components/@{componentLabel}/requirementsArray.yaml @@ -0,0 +1,20 @@ +parameters: + - $ref: ../../../components/parameters/path/componentLabel.yaml +get: + tags: + - Schema + summary: Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in array form. + description: Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in array form. + operationId: getComponentRequirementsArray + parameters: + - $ref: ../../../components/parameters/query/schemaUrl.yaml + - $ref: ../../../components/parameters/query/displayLabelType.yaml + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: ../../../components/schemas/ComponentRequirementsArray.yaml + '500': + $ref: ../../../components/responses/InternalServerError.yaml diff --git a/libs/schematic/api-description/src/paths/components/@{componentLabel}/requirementsGraph.yaml b/libs/schematic/api-description/src/paths/components/@{componentLabel}/requirementsGraph.yaml new file mode 100644 index 0000000000..164a07d12d --- /dev/null +++ b/libs/schematic/api-description/src/paths/components/@{componentLabel}/requirementsGraph.yaml @@ -0,0 +1,20 @@ +parameters: + - $ref: ../../../components/parameters/path/componentLabel.yaml +get: + tags: + - Schema + summary: Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in graph form. + description: Given a source model component (see https://w3id.org/biolink/vocab/category for definnition of component), return all components required by it in graph form. + operationId: getComponentRequirementsGraph + parameters: + - $ref: ../../../components/parameters/query/schemaUrl.yaml + - $ref: ../../../components/parameters/query/displayLabelType.yaml + responses: + '200': + description: Success + content: + application/json: + schema: + $ref: ../../../components/schemas/ComponentRequirementsGraph.yaml + '500': + $ref: ../../../components/responses/InternalServerError.yaml