Skip to content

Commit 7ae3a48

Browse files
authored
Merge pull request #111 from NHSDigital/docs/NPA-3332_Update_README
NPA-3332 Improve Repository Documentation
2 parents c51f697 + f829715 commit 7ae3a48

File tree

6 files changed

+231
-184
lines changed

6 files changed

+231
-184
lines changed

.vscode/extensions.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"recommendations": [
3+
"mermade.openapi-lint",
4+
"42Crunch.vscode-openapi"
5+
]
6+
}

CODE_OF_CONDUCT.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
32-
professional setting
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
3333

3434
## Our Responsibilities
3535

CONTRIBUTING.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,46 @@
11
# Contribution Guidelines
22

3+
- [Contribution Guidelines](#contribution-guidelines)
4+
- [Raising an Issue](#raising-an-issue)
5+
- [Contributing code](#contributing-code)
6+
- [Merge responsibility](#merge-responsibility)
7+
- [Branch naming](#branch-naming)
8+
- [Commit messages](#commit-messages)
9+
310
## Raising an Issue
11+
412
If you raise an issue against this repository, please include as much information as possible to reproduce any bugs,
513
or specific locations in the case of content errors.
614

715
## Contributing code
16+
817
To contribute code, please fork the repository and raise a pull request.
918

1019
Ideally pull requests should be fairly granular and aim to solve one problem each. It would also be helpful if they
1120
linked to an issue. If the maintainers cannot understand why a pull request was raised, it will be rejected,
1221
so please explain why the changes need to be made (unless it is self-evident).
1322

1423
### Merge responsibility
15-
* It is the responsibility of the reviewer to merge branches they have approved.
16-
* It is the responsibility of the author of the merge to ensure their merge is in a mergeable state.
17-
* It is the responsibility of the maintainers to ensure the merge process is unambiguous and automated where possible.
24+
25+
- It is the responsibility of the reviewer to merge branches they have approved.
26+
- It is the responsibility of the author of the merge to ensure their merge is in a mergeable state.
27+
- It is the responsibility of the maintainers to ensure the merge process is unambiguous and automated where possible.
1828

1929
### Branch naming
30+
2031
Branch names should be of the format:
2132

2233
`apm-nnn-short-issue-description`
2334

2435
Multiple branches are permitted for the same ticket.
2536

2637
### Commit messages
38+
2739
Commit messages should be formatted as follows:
40+
2841
```
2942
APM-NNN Summary of changes
3043
3144
Longer description of changes if explaining rationale is necessary,
3245
limited to 80 columns and spanning as many lines as you need.
3346
```
34-

DEVELOPMENT_GUIDE.md

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Development Guide
2+
3+
This documentation is intended for developers to develop the schema, sandbox and proxies. It may be used by developers working within the NHS Digital organisation and outside contributors.
4+
5+
> [!WARNING]
6+
> Some of the documentation and links are specific to the maintainers of this repository and are only available to NHS England staff.
7+
8+
## Table of Contents
9+
10+
- [Development Guide](#development-guide)
11+
- [Table of Contents](#table-of-contents)
12+
- [Development](#development)
13+
- [Requirements](#requirements)
14+
- [Make commands](#make-commands)
15+
- [Testing](#testing)
16+
- [Platform setup](#platform-setup)
17+
- [Detailed folder walk through](#detailed-folder-walk-through)
18+
- [`/.github`:](#github)
19+
- [`/azure`:](#azure)
20+
- [`/proxies`:](#proxies)
21+
- [`/scripts`:](#scripts)
22+
- [`/specification`:](#specification)
23+
- [`/tests`:](#tests)
24+
- [`Makefile`:](#makefile)
25+
- [`ecs-proxies-containers.yml ` and `ecs-proxies-deploy.yml`:](#ecs-proxies-containersyml--and-ecs-proxies-deployyml)
26+
- [`manifest_template.yml`:](#manifest_templateyml)
27+
- [Releasing a new schema version](#releasing-a-new-schema-version)
28+
- [Caveats](#caveats)
29+
- [Swagger UI](#swagger-ui)
30+
- [Apigee Portal](#apigee-portal)
31+
32+
## Development
33+
34+
> [!NOTE]
35+
> Sandbox development is not documented here. Please see the [Sandbox README](./sandbox/README.md) for more information.
36+
37+
### Requirements
38+
39+
- GNU make
40+
- nodejs 22+
41+
- npm 10.8+
42+
- Python 3.8 +
43+
- [poetry](https://github.com/python-poetry/poetry) 1.8+
44+
- Java 8+
45+
46+
### Make commands
47+
48+
To run the below make targets you will first need to run `make install-node`
49+
50+
There are `make` commands that alias scripts in the `package.json`
51+
52+
- `lint` -- Lints the spec and code
53+
- `publish` -- Outputs the specification as a **single file** into the `build/` directory
54+
- `serve` -- Serves a preview of the specification in human-readable format
55+
56+
### Testing
57+
58+
A minimal Pytest test suite is available under the [tests](./tests) folder. These test the Apigee Proxy is set up. These tests are written in Python and use the PyTest test runner.
59+
60+
A majority of the testing is co-located with the application in the `Proxy Validated Relationship Service` repository that is not currently open source.
61+
62+
The test dependencies can be installed by running `make install` from the root directory of this project.
63+
To run tests run `make test` from the project root. Or for Smoke tests run `make smoketest`
64+
65+
### Platform setup
66+
67+
Apigee is setup for all live environments (dev, qa, int, prod) proxy the request to a target server. The target server on Apigee should be named `validated-relationships-service-api-target`.
68+
Target Servers defined in the [api-management-infrastructure](https://github.com/NHSDigital/api-management-infrastructure/blob/master/ansible/roles/apigee-keystores-refs-targetservers/vars/main/target-servers.yml) repository.
69+
70+
Sandbox environments use Apigee to proxy the request to an AWS ECS container.
71+
72+
### Detailed folder walk through
73+
74+
For further information about Apigee and APIM see [API Producer Zone confluence](https://nhsd-confluence.digital.nhs.uk/display/APM/Deliver+your+API)
75+
76+
#### `/.github`:
77+
78+
`/.github/workflows`: This folder contains GitHub workflows, these workflow are mainly used to check pull requests and publish releases.
79+
80+
- `pr-lint.yaml`: This workflow links Pull Request's to Jira tickets and runs when a pull request is opened/updated.
81+
- `continuous-integration.yml`: This workflow publishes a Github release when pushing to master.
82+
- `sandbox-checks.yaml`: This workflow checks the sandbox meets the formatting and linting rules (Black + Flake8). Also it runs the sandbox unit tests (Pytest)
83+
- `dependency-review.yml`: This workflow checks for any vulnerabilities in dependencies to be added to the project.
84+
- `codeql-analysis.yml`: This workflow checks for any code vulnerabilities in the project.
85+
86+
#### `/azure`:
87+
88+
Contains Azure Devops pipelines for building and deploying to Apigee:
89+
90+
- `azure-build-pipeline.yml`: Assembles the contents of your repository into a single file ("artifact") on Azure Devops and pushes any containers to our Docker registry. This pipeline is enabled for all branches.
91+
- `azure-pr-pipeline.yml`: Deploys ephemeral versions of your proxy/spec to Apigee (and docker containers on AWS) to internal environments. This will deploy a internal-dev environment and internal-dev-sandbox for each pull request.
92+
- `azure-release-pipeline.yml`: Deploys the long-lived version of your pipeline to internal and external environments, when you merge to master.
93+
94+
`/azure/templates`: Here you can define reusable actions, such as running tests, and call these actions during Azure Devops pipelines.
95+
96+
#### `/proxies`:
97+
98+
This folder contains files relating to the Apigee API proxy.
99+
100+
There are 2 folders `/live` and `/sandbox` allowing you to define a different proxy for sandbox use. By default, this sandbox proxy is implemented to route to the sandbox target server (code for this sandbox is found under /sandbox of this template repo)
101+
102+
Within the `live/apiproxy` and `sandbox/apiproxy` folders are:
103+
104+
`/proxies/default.xml`: Defines the proxy's Flows. Flows define how the proxy should handle different requests. By default, \_ping and \_status endpoint flows are defined.
105+
See the APM confluence for more information on how the [\_ping](https://nhsd-confluence.digital.nhs.uk/display/APM/_ping+endpoint) and [\_status](https://nhsd-confluence.digital.nhs.uk/display/APM/_status+endpoint) endpoints work.
106+
107+
`/policies`: Populated with a set of standard XML Apigee policies that can be used in flows.
108+
109+
`/resources/jsc`: Snippets of javascript code that are used in Apigee Javascript policies. For more info about Javascript policies see [here](https://docs.apigee.com/api-platform/reference/policies/javascript-policy)
110+
111+
`/targets`: The XMLs within these folders set up target definitions which allow connections to external target servers. The sandbox target definition is implemented to route to the sandbox target server (code for this sandbox is found under /sandbox of this template repo). For more info on setting up a target server see the [API Producer Zone confluence](https://nhsd-confluence.digital.nhs.uk/display/APM/Setting+up+a+target+server)
112+
113+
#### `/scripts`:
114+
115+
Contains useful scripts that are used throughout the project. Mainly Python scripts used in the release process.
116+
117+
#### `/specification`:
118+
119+
Contains the OpenAPI specification - [validated-relationships-service-api.yaml](./specification/validated-relationships-service-api.yaml)
120+
121+
#### `/tests`:
122+
123+
End to End tests. These tests are written in Python and use the PyTest test runner. Before running these tests you will need to set environment variables. The `test_endpoint.py` file provides a template of how to set up tests which test your api endpoints. For more information about testing your API see the [API Producer Zone confluence](https://nhsd-confluence.digital.nhs.uk/display/APM/Testing+your+API).
124+
125+
#### `Makefile`:
126+
127+
Contains make targets to run parts of the project such as installing dependencies and running smoke tests.
128+
129+
#### `ecs-proxies-containers.yml ` and `ecs-proxies-deploy.yml`:
130+
131+
These files are required to deploy containers alongside your Apigee proxy during the Azure Devops `azure-build-pipeline`.
132+
133+
`ecs-proxies-containers.yml`: The path to a container's Dockerfile is defined here. This path needs to be defined to allow containers to be pushed to our repository during the `azure-build-pipeline`. This is used for the sandbox proxy docker container.
134+
135+
`ecs-proxies-deploy.yml` : Here you can define config for your container deployment.
136+
137+
For more information about deploying ECS containers see the [API Producer Zone confluence](https://nhsd-confluence.digital.nhs.uk/display/APM/Developing+ECS+proxies#DevelopingECSproxies-Buildingandpushingdockercontainers).
138+
139+
#### `manifest_template.yml`:
140+
141+
This file defines 2 dictionaries of fields that are required for the Apigee deployment. For more info see the [API Producer Zone confluence](https://nhsd-confluence.digital.nhs.uk/display/APM/Manifest.yml+reference).
142+
143+
## Releasing a new schema version
144+
145+
To release a new version of the schema, follow the steps below:
146+
147+
1. Update the version number in [specification/validated-relationships-service-api.yaml](./specification/validated-relationships-service-api.yaml).
148+
2. Update the Postman collection - [postman/Validate Relationship Service Sandbox.postman_collection.json](./postman/Validate%20Relationship%20Service%20Sandbox.postman_collection.json).
149+
1. Documentation on how to update the Postman collection can be found [here](https://nhsd-confluence.digital.nhs.uk/pages/viewpage.action?pageId=874694621).
150+
3. Update the sandbox - [sandbox](./sandbox).
151+
4. Create a pull request with the changes.
152+
5. Once the pull request has been approved, merge it into the `master` branch.
153+
6. Request a schema changes are published to the [Validated Relationship Service API](https://digital.nhs.uk/developer/api-catalogue/validated-relationship-service) page.
154+
1. Documentation on how to update the published specification page can be found [here](https://nhsd-confluence.digital.nhs.uk/display/NPA/Deploy+to+Public+Validated+Relationship+Service+API+Page)
155+
156+
### Caveats
157+
158+
#### Swagger UI
159+
160+
Swagger UI unfortunately doesn't correctly render `$ref`s in examples, so when publishing the schema to the API catalogue it uses `make publish` which under the hood uses `speccy serve` instead.
161+
162+
#### Apigee Portal
163+
164+
The Apigee portal will not automatically pull examples from schemas, you must specify them manually.

0 commit comments

Comments
 (0)