Skip to content

Commit 07b1b9d

Browse files
authored
Merge pull request #32 from NHSDigital/feature/eja-eli-173-create-postman-collection-automagically
eli-173 adding simple container based approach to converting the spec…
2 parents 37a6d1f + cab7956 commit 07b1b9d

File tree

5 files changed

+35
-0
lines changed

5 files changed

+35
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@ localstack_data/
4141
sandbox/specification/*
4242
/volume/*
4343
/coverage.xml
44+
/lines-of-code-report*
45+
/specification/postman
46+
/sandbox/specification/*
4447
/integration-test-results.xml
4548
/specification/tmp/*

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ config:: # Configure development environment (main) @Configuration
6262
precommit: test-unit build test-integration lint ## Pre-commit tasks
6363
python -m this
6464

65+
SPEC_DIR := $(CURDIR)/specification
66+
POSTMAN_DIR := $(SPEC_DIR)/postman
67+
68+
convert-postman: # Create Postman collection from OAS spec
69+
mkdir -p $(POSTMAN_DIR)
70+
cp $(SPEC_DIR)/eligibility-signposting-api.yaml $(POSTMAN_DIR)/
71+
docker build -t portman-converter -f $(POSTMAN_DIR)/Dockerfile $(SPEC_DIR)
72+
docker run --rm -v $(SPEC_DIR):/app portman-converter \
73+
portman -l /app/eligibility-signposting-api.yaml -o /app/postman/collection.json
74+
rm $(POSTMAN_DIR)/eligibility-signposting-api.yaml
6575
# ==============================================================================
6676

6777
${VERBOSE}.SILENT: \

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The software will only be used for signposting an individual to an appropriate s
2121
- [Testing](#testing)
2222
- [Sandbox](#sandbox)
2323
- [Conflict with yanai](#conflict-with-yanai)
24+
- [Creating a Postman collection](#creating-a-postman-collection)
2425
- [Design](#design)
2526
- [Diagrams](#diagrams)
2627
- [Modularity](#modularity)
@@ -103,6 +104,17 @@ If you have previously built [yanai](https://nhsd-confluence.digital.nhs.uk/page
103104
docker rmi localstack/localstack
104105
```
105106

107+
## Creating a Postman collection
108+
109+
A Postman collection can be generated from the Open API specification in `specification/` by running the following make command:
110+
111+
```shell
112+
make convert-postman
113+
```
114+
115+
The conversion is done using the [Portman CLI](https://github.com/apideck-libraries/portman). The resulting Postman collection
116+
is saved to `specification/postman/`.
117+
106118
## Design
107119

108120
We'll be separating our [presentation](https://martinfowler.com/eaaDev/SeparatedPresentation.html) layer (where API logic lives, in [`views/`](src/eligibility_signposting_api/views)), [business services](https://martinfowler.com/eaaCatalog/serviceLayer.html) layer (where business logic lives, in [`services/`](src/eligibility_signposting_api/services)) and [repository](https://martinfowler.com/eaaCatalog/repository.html) layer (where database logic lives, [`repos/`](src/eligibility_signposting_api/repos)). We will be using [wireup](https://pypi.org/project/wireup/) for [dependency injection](https://pinboard.in/u:brunns/t:dependency-injection), so services get their dependencies given to them ("injection"), and wireup takes care of that. (We'll usually use the [`@service` annotation](https://maldoinc.github.io/wireup/latest/services/), but [factory functions](https://maldoinc.github.io/wireup/latest/factory_functions/) will be used where necessary, typically for creating resources from 3rd party libraries.) We'll be using [Pydantic](https://pypi.org/project/pydantic/) for both response models and database models.

scripts/config/vale/styles/config/vocabularies/words/accept.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ colima
2222
wireup
2323
Pydantic
2424
yanai
25+
Portman

specification/postman/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM node:18-alpine
2+
3+
RUN npm install -g @apideck/portman
4+
5+
WORKDIR /app
6+
7+
COPY ../eligibility-signposting-api.yaml .
8+
9+
CMD ["portman", "-l", "eligibility-signposting-api.yaml", "-o", "collection.json"]

0 commit comments

Comments
 (0)