diff --git a/.gitignore b/.gitignore index c131d997..6098a015 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,8 @@ localstack_data/ sandbox/specification/* /volume/* /coverage.xml +/lines-of-code-report* +/specification/postman +/sandbox/specification/* /integration-test-results.xml /specification/tmp/* diff --git a/Makefile b/Makefile index 852f59b0..8087f3f2 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,16 @@ config:: # Configure development environment (main) @Configuration precommit: test-unit build test-integration lint ## Pre-commit tasks python -m this +SPEC_DIR := $(CURDIR)/specification +POSTMAN_DIR := $(SPEC_DIR)/postman + +convert-postman: # Create Postman collection from OAS spec + mkdir -p $(POSTMAN_DIR) + cp $(SPEC_DIR)/eligibility-signposting-api.yaml $(POSTMAN_DIR)/ + docker build -t portman-converter -f $(POSTMAN_DIR)/Dockerfile $(SPEC_DIR) + docker run --rm -v $(SPEC_DIR):/app portman-converter \ + portman -l /app/eligibility-signposting-api.yaml -o /app/postman/collection.json + rm $(POSTMAN_DIR)/eligibility-signposting-api.yaml # ============================================================================== ${VERBOSE}.SILENT: \ diff --git a/README.md b/README.md index b1bbbce8..daac8e8d 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ The software will only be used for signposting an individual to an appropriate s - [Testing](#testing) - [Sandbox](#sandbox) - [Conflict with yanai](#conflict-with-yanai) + - [Creating a Postman collection](#creating-a-postman-collection) - [Design](#design) - [Diagrams](#diagrams) - [Modularity](#modularity) @@ -103,6 +104,17 @@ If you have previously built [yanai](https://nhsd-confluence.digital.nhs.uk/page docker rmi localstack/localstack ``` +## Creating a Postman collection + +A Postman collection can be generated from the Open API specification in `specification/` by running the following make command: + +```shell +make convert-postman +``` + +The conversion is done using the [Portman CLI](https://github.com/apideck-libraries/portman). The resulting Postman collection +is saved to `specification/postman/`. + ## Design 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. diff --git a/scripts/config/vale/styles/config/vocabularies/words/accept.txt b/scripts/config/vale/styles/config/vocabularies/words/accept.txt index cae10a15..d4e7d15e 100644 --- a/scripts/config/vale/styles/config/vocabularies/words/accept.txt +++ b/scripts/config/vale/styles/config/vocabularies/words/accept.txt @@ -22,3 +22,4 @@ colima wireup Pydantic yanai +Portman diff --git a/specification/postman/Dockerfile b/specification/postman/Dockerfile new file mode 100644 index 00000000..5f164b15 --- /dev/null +++ b/specification/postman/Dockerfile @@ -0,0 +1,9 @@ +FROM node:18-alpine + +RUN npm install -g @apideck/portman + +WORKDIR /app + +COPY ../eligibility-signposting-api.yaml . + +CMD ["portman", "-l", "eligibility-signposting-api.yaml", "-o", "collection.json"]