Skip to content

Commit 03fc79b

Browse files
authored
Merge pull request #580 from NHSDigital/feature/eema1-NRL-634-removeModelGeneration
[NRL-634] update readme and add make commands
2 parents 86ac4bd + 17c596f commit 03fc79b

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,9 @@ truststore-pull-client: check-warn ## Pull a client certificate
126126

127127
truststore-pull-ca: check-warn ## Pull a CA certificate
128128
@./scripts/truststore.sh pull-ca "$(ENV)"
129+
130+
swagger-merge: check-warn ## Generate Swagger Documentation
131+
@./scripts/swagger.sh merge "$(TYPE)"
132+
133+
generate-model: check-warn ## Generate Pydantic Models
134+
@./scripts/swagger.sh generate-model "$(TYPE)"

swagger/README.md

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,13 @@ This README documents the commands used to create the swagger docs for the API c
44

55
If you need to manually generate the swagger after making a change then the following commands in this order will create the correct results:
66

7-
## Command order
8-
9-
```shell
10-
nrlf swagger merge producer
11-
nrlf swagger merge consumer
12-
nrlf swagger generate-model producer
13-
nrlf swagger generate-model consumer
14-
```
15-
16-
## Generate - DO NOT DO THIS UNLESS EXPLICITLY TOLD TO
17-
18-
PLEASE DO NOT USE THIS COMMAND UNLESS EXPLICITLY TOLD TO DO SO. This command was useful when NRLF was in it's infancy, but since then the generated swagger files have been manually modified, so running this command will lose ALL of that that information! instead please use generate-model steps as mentioned above.
19-
20-
The generate command recreates the two swagger files for the consumer and producer using the fhir swagger generator - it will then use that `./api/*/swagger.yaml` file to generate the pydantic models using the datamodel-codegen package
21-
22-
you can run the swagger generate using the below command:
23-
247
```shell
25-
nrlf swagger generate
8+
make swagger-merge TYPE={type}
269
```
2710

28-
## Merge
11+
With TYPE being one of the following: `consumer` or `producer`.
2912

30-
The merge command will take the changes in the static swagger files and merge them into the freshly generated swagger.yaml files, it will do the following:
13+
This command uses the merge command from the swagger.sh script which will take the changes in the static swagger files and merge them into the freshly generated swagger.yaml files, it will do the following:
3114

3215
- remove commented lines
3316
- replace the snake case terms
@@ -40,3 +23,29 @@ It will then:
4023
And finally:
4124

4225
- remove all information that is not required for public documentation (e.g. security sections and authorisers) and put that into the `nrl-*-api.yaml` files
26+
27+
## Generate Model - DO NOT DO THIS UNLESS NEW PYDANTIC MODELS ARE REQUIRED
28+
29+
PLEASE DO NOT USE THIS COMMAND UNLESS EXPLICITLY TOLD TO DO SO. This command is only useful when we need to generate the new Pydantic Models, but FHIR does not update often enough to warrant regenerating the models constantly.
30+
31+
The generate- command will use that `./api/*/swagger.yaml` file that was generated in the swagger-merge step, to generate the pydantic models using the datamodel-codegen package
32+
33+
you can run the model generate using the below command:
34+
35+
```shell
36+
make generate-model TYPE={type}
37+
```
38+
39+
With TYPE being one of the following: `consumer` or `producer`.
40+
41+
## Generate - DO NOT DO THIS UNLESS EXPLICITLY TOLD TO
42+
43+
PLEASE DO NOT USE THIS COMMAND UNLESS EXPLICITLY TOLD TO DO SO. This command was useful when NRLF was in it's infancy, but since then the generated swagger files have been manually modified, so running this command will lose ALL of that that information! instead please use generate-model steps as mentioned above.
44+
45+
The generate command recreates the two swagger files for the consumer and producer using the fhir swagger generator - it will then use that `./api/*/swagger.yaml` file to generate the pydantic models using the datamodel-codegen package
46+
47+
you can run the swagger generate using the below command:
48+
49+
```shell
50+
./scripts/swagger.sh generate
51+
```

0 commit comments

Comments
 (0)