diff --git a/README.md b/README.md index 03f85791..45dd2dc4 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,12 @@ git clone git@github.com:NHSDigital/clinical-data-gateway-api.git cd clinical-data-gateway-api.git ``` +### External Dependencies + +This project depends on the [clinical-data-common](https://github.com/NHSDigital/clinical-data-common) library, which provides shared code and utilities used across various clinical data API products. The dependency is managed via Poetry and installed directly from the GitHub repository. + +The library is referenced in `gateway-api/pyproject.toml` as a git dependency. The CI/CD pipeline is currently configured to pull the latest version from the specified branch automatically. + The project can then be built within a [Dev Container](https://containers.dev/) as defined within the file outlined under `.devcontainer/devcontainer.json`. When opening the project within Visual Studio Code, if the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) is installed, you should be prompted to re-open the folder within a Dev Container if you wish. If accepted, this should build the Dev Container locally which will include all required libraries and tools for development. > [!NOTE]
diff --git a/gateway-api/README.md b/gateway-api/README.md index fe0928af..2919806e 100644 --- a/gateway-api/README.md +++ b/gateway-api/README.md @@ -56,3 +56,22 @@ gateway-api/ ├── pyproject.toml # Dependencies and config └── README.md ``` + +## External Dependencies + +This module depends on the [clinical-data-common](https://github.com/NHSDigital/clinical-data-common) library for shared utilities and code. The dependency is specified as a git poetry dependency in `pyproject.toml`: + +```toml +[tool.poetry.dependencies] +clinical-data-common = { git = "https://github.com/NHSDigital/clinical-data-common.git", branch = "main" } +``` + +### Updating the Dependency + +To pull the latest version of the common library: + +```bash +poetry update clinical-data-common +``` + +The CI/CD pipeline automatically updates this dependency on each run to ensure the latest code from the specified branch is used during active development. diff --git a/gateway-api/poetry.lock b/gateway-api/poetry.lock index e9e8da1a..628aecc1 100644 --- a/gateway-api/poetry.lock +++ b/gateway-api/poetry.lock @@ -310,6 +310,22 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} +[[package]] +name = "clinical-data-common" +version = "0.1.0" +description = "Common code used across various clinical data API products" +optional = false +python-versions = ">3.13,<4.0.0" +groups = ["main"] +files = [] +develop = false + +[package.source] +type = "git" +url = "https://github.com/NHSDigital/clinical-data-common.git" +reference = "v0.1.0" +resolved_reference = "b2fbfe7d723238bb67a2b6423c04271d87ea456b" + [[package]] name = "colorama" version = "0.4.6" @@ -1548,6 +1564,21 @@ files = [ [package.dependencies] six = ">=1.5" +[[package]] +name = "python-dotenv" +version = "1.2.1" +description = "Read key-value pairs from a .env file and set them as environment variables" +optional = false +python-versions = ">=3.9" +groups = ["dev"] +files = [ + {file = "python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61"}, + {file = "python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6"}, +] + +[package.extras] +cli = ["click (>=5.0)"] + [[package]] name = "pyyaml" version = "6.0.3" @@ -2212,4 +2243,4 @@ propcache = ">=0.2.1" [metadata] lock-version = "2.1" python-versions = ">3.13,<4.0.0" -content-hash = "b1f7ca89a1d19d8d860a88040999a785e36e52110abb98e15dbedcb5c78a7073" +content-hash = "ec013475c1d46e197243aad2c6ac8eb56957da032015c466694978937b784a61" diff --git a/gateway-api/pyproject.toml b/gateway-api/pyproject.toml index acf40fcc..3a5cd476 100644 --- a/gateway-api/pyproject.toml +++ b/gateway-api/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "gateway-api" version = "0.1.0" -description = "" +description = "Clinical Data Gateway API - Provides GP Connect APIs over the internet via the API Management platform" authors = [ {name = "Your Name", email = "you@example.com"} ] @@ -10,6 +10,9 @@ requires-python = ">3.13,<4.0.0" dependencies = [ ] +[tool.poetry.dependencies] +clinical-data-common = { git = "https://github.com/NHSDigital/clinical-data-common.git", tag = "v0.1.0" } + [tool.poetry] packages = [{include = "gateway_api", from = "src"}] @@ -45,6 +48,7 @@ dev = [ "pytest-cov (>=7.0.0,<8.0.0)", "pytest-html (>=4.1.1,<5.0.0)", "pact-python>=2.0.0", + "python-dotenv>=1.0.0", "requests>=2.31.0", "schemathesis>=4.4.1", "types-requests (>=2.32.4.20250913,<3.0.0.0)", diff --git a/gateway-api/src/gateway_api/handler.py b/gateway-api/src/gateway_api/handler.py index 940e382d..a3f66b94 100644 --- a/gateway-api/src/gateway_api/handler.py +++ b/gateway-api/src/gateway_api/handler.py @@ -1,3 +1,6 @@ +from clinical_data_common import get_hello + + class User: def __init__(self, name: str): self._name = name @@ -10,4 +13,5 @@ def name(self) -> str: def greet(user: User) -> str: if user.name == "nonexistent": raise ValueError("nonexistent user provided.") - return f"Hello, {user.name}!" + hello = get_hello() + return f"{hello}{user.name}!" diff --git a/gateway-api/tests/conftest.py b/gateway-api/tests/conftest.py index dc9ae006..436ebbae 100644 --- a/gateway-api/tests/conftest.py +++ b/gateway-api/tests/conftest.py @@ -7,6 +7,11 @@ import pytest import requests +from dotenv import find_dotenv, load_dotenv + +# Load environment variables from .env file in the workspace root +# find_dotenv searches upward from current directory for .env file +load_dotenv(find_dotenv()) class Client: