Skip to content

Commit 3a013c0

Browse files
committed
automatic patch creation
Signed-off-by: Timo Glastra <timo@animo.id>
1 parent 788dd9b commit 3a013c0

File tree

6 files changed

+47
-44
lines changed

6 files changed

+47
-44
lines changed

generator/README.md

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -36,34 +36,17 @@ cd aries-cloudcontroller/generator
3636

3737
# Fix the openapi file (add missing operation ids from data/operation-id-map.yml)
3838
./scripts/process-openapi.sh
39+
40+
# Apply manual patches to the openapi file
41+
./scripts/apply-patch.sh
3942
```
4043

41-
### Manual modifications
42-
43-
The code is set up to require the least amount of manual modifications. However, sometimes it's easier to manually fix some issues. The goal is to make those manual modifications to the open api file, not the generated code.
44-
45-
#### `connection_protocol` enum
46-
47-
Fixed in main, not part of 0.7.0. Replace line 4220-4235 in `data/openapi.yml`
48-
49-
```diff
50-
# line 4220-4235
51-
- - c
52-
- - o
53-
- - n
54-
- - e
55-
- - t
56-
- - i
57-
- - s
58-
- - /
59-
- - "1"
60-
- - "."
61-
- - "0"
62-
- - d
63-
- - x
64-
- - h
65-
- - a
66-
- - g
67-
+ - connections/1.0
68-
+ - didexchange/1.0
44+
## Updating the patch file
45+
46+
1. Make changes to the OpenAPI file and then run:
47+
48+
```sh
49+
cd aries-cloudcontroller/generator
50+
51+
./scripts/create-patch.sh
6952
```

generator/data/openapi.patch

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/generator/data/openapi.yml b/generator/data/openapi.yml
2-
index 4582107..0186d58 100644
2+
index 4582107..54bbbf4 100644
33
--- a/generator/data/openapi.yml
44
+++ b/generator/data/openapi.yml
55
@@ -705,7 +705,7 @@ paths:
@@ -89,40 +89,42 @@ index 4582107..0186d58 100644
8989
type: object
9090
properties:
9191
schema:
92-
@@ -7620,7 +7611,7 @@ components:
93-
maximum: 18446744073709551615
94-
minimum: 0
92+
@@ -7617,10 +7608,7 @@ components:
93+
mechanism:
94+
type: string
95+
time:
96+
- maximum: 18446744073709551615
97+
- minimum: 0
9598
type: integer
9699
- format: int32
97-
+ format: uint64
98100
example: 1629715147
99101
TAAInfo:
100102
type: object
101-
@@ -7765,6 +7756,7 @@ components:
103+
@@ -7765,6 +7753,7 @@ components:
102104
example: 2021-08-23 10:39:07+00:00
103105
TxnOrCredentialDefinitionSendResult:
104106
type: object
105107
+ additionalProperties: false
106108
properties:
107109
sent:
108110
$ref: '#/components/schemas/CredentialDefinitionSendResult'
109-
@@ -7775,6 +7767,7 @@ components:
111+
@@ -7775,6 +7764,7 @@ components:
110112
- $ref: '#/components/schemas/TransactionRecord'
111113
TxnOrPublishRevocationsResult:
112114
type: object
113115
+ additionalProperties: false
114116
properties:
115117
sent:
116118
$ref: '#/components/schemas/PublishRevocations'
117-
@@ -7785,6 +7778,7 @@ components:
119+
@@ -7785,6 +7775,7 @@ components:
118120
- $ref: '#/components/schemas/TransactionRecord'
119121
TxnOrRevRegResult:
120122
type: object
121123
+ additionalProperties: false
122124
properties:
123125
sent:
124126
$ref: '#/components/schemas/RevRegResult'
125-
@@ -7795,6 +7789,7 @@ components:
127+
@@ -7795,6 +7786,7 @@ components:
126128
- $ref: '#/components/schemas/TransactionRecord'
127129
TxnOrSchemaSendResult:
128130
type: object

generator/data/openapi.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7608,10 +7608,7 @@ components:
76087608
mechanism:
76097609
type: string
76107610
time:
7611-
maximum: 18446744073709551615
7612-
minimum: 0
76137611
type: integer
7614-
format: uint64
76157612
example: 1629715147
76167613
TAAInfo:
76177614
type: object

generator/scripts/apply-patch.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
cd "$(dirname "$0")" || exit
4+
5+
# Apply the patches required
6+
cd .. && git apply --verbose data/openapi.patch

generator/scripts/create-patch.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
cd "$(dirname "$0")" || exit
4+
5+
cp ../data/openapi.yml ../data/openapi-updated.yml
6+
sh ./convert-to-openapi3.sh
7+
sh ./process-openapi.sh
8+
9+
cd ..
10+
11+
git diff --no-index --patch data/openapi.yml data/openapi-updated.yml > data/openapi.patch
12+
13+
# Move back to the updated file
14+
mv data/openapi-updated.yml data/openapi.yml
15+
16+
# Replace openapi-updated references with openapi
17+
sed -i '' 's/a\/data\/openapi.yml/a\/generator\/data\/openapi.yml/g' data/openapi.patch
18+
sed -i '' 's/b\/data\/openapi-updated.yml/b\/generator\/data\/openapi.yml/g' data/openapi.patch

generator/scripts/process-openapi.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ ${CONTAINER_RUNTIME} run --name ${CONTAINER_NAME} --rm -it \
99
-v "$(pwd)/../data/openapi.yml:/app/openapi.yml:z" \
1010
-v "$(pwd)/../data/operation-id-map.yml:/app/operation-id-map.yml:z" \
1111
-v "$(pwd)/../process-openapi.py:/app/process-openapi.py:z" \
12-
${CONTAINER_NAME} python /app/process-openapi.py
13-
14-
# Apply the patches required
15-
cd .. && git apply --verbose data/openapi.patch
12+
${CONTAINER_NAME} python /app/process-openapi.py

0 commit comments

Comments
 (0)