Skip to content

Commit 33774c2

Browse files
Skip writing the HTTP actions to config file and log warning when REST Methods are configured for tables/views (#1607)
## Why make this change? - Closes #1571 #1570 - At the moment, CLI writes out all the 5 HTTP methods to the config file when adding an entity backed by table/view. ![image](https://github.com/Azure/data-api-builder/assets/11196553/206ddffb-a2d5-42c5-94dd-50165ef96f24) - However, for tables/views, the `Methods` property does not play any role and can be skipped writing to the config file. ## What is this change? - `EntityRestOptions`: `Methods` property is made nullable. References where it was initialized with an empty array is updated to `null`. Appropriate `null` checks are added. - `EntityRestOptionsConverter`: Serialization logic is updated to write to the config file only when the `Methods` within REST element is not empty - `RuntimeConfigValidator.ValidatePresenceOfExtraRestProperties()`: Helper method to log a warning message when `Methods` property is added manually to an entity backed by table/view. - HTTP Actions are removed from the snapshot files. - `dab-config.*` files - `Methods` property is removed from the reference config files ## How was this tested? - [x] Integration Tests - [x] Unit Tests - [x] Manual Tests ## Sample Request(s) - CLI: REST actions are not written to the config file `dab add books --source books --permissions "anonymous:*"` Config Json created: ```json "entities": { "books": { "source": { "object": "books", "type": "table" }, "graphql": { "enabled": true, "type": { "singular": "books", "plural": "books" } }, "rest": { "enabled": true }, "permissions": [ { "role": "anonymous", "actions": [ { "action": "*" } ] } ] } } ``` - When the config file is hand-edited to add `methods` property to a table/view, engine logs a warning message during start-up Config: ```json "Book": { "source": { "object": "books", "type": "table" }, "rest": { "enabled": true, "methods": [ "get", "post" ] }, "graphql": { "enabled": true, "type": { "singular": "book", "plural": "books" } }, ``` Warning Logged: ![image](https://github.com/Azure/data-api-builder/assets/11196553/287efcc2-e088-48b1-81f1-f762e18c2b51)
1 parent 927fd21 commit 33774c2

39 files changed

Lines changed: 278 additions & 515 deletions

File tree

src/Cli.Tests/Snapshots/AddEntityTests.AddEntityWithAnExistingNameButWithDifferentCase.verified.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@
3434
Enabled: true
3535
},
3636
Rest: {
37-
Methods: [
38-
Get,
39-
Post,
40-
Put,
41-
Patch,
42-
Delete
43-
],
4437
Enabled: true
4538
},
4639
Permissions: [
@@ -70,13 +63,6 @@
7063
Enabled: true
7164
},
7265
Rest: {
73-
Methods: [
74-
Get,
75-
Post,
76-
Put,
77-
Patch,
78-
Delete
79-
],
8066
Enabled: true
8167
},
8268
Permissions: [

src/Cli.Tests/Snapshots/AddEntityTests.AddEntityWithPolicyAndFieldProperties_70de36ebf1478d0d.verified.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@
3434
Enabled: true
3535
},
3636
Rest: {
37-
Methods: [
38-
Get,
39-
Post,
40-
Put,
41-
Patch,
42-
Delete
43-
],
4437
Enabled: true
4538
},
4639
Permissions: [

src/Cli.Tests/Snapshots/AddEntityTests.AddEntityWithPolicyAndFieldProperties_9f612e68879149a3.verified.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@
3434
Enabled: true
3535
},
3636
Rest: {
37-
Methods: [
38-
Get,
39-
Post,
40-
Put,
41-
Patch,
42-
Delete
43-
],
4437
Enabled: true
4538
},
4639
Permissions: [

src/Cli.Tests/Snapshots/AddEntityTests.AddEntityWithPolicyAndFieldProperties_bea2d26f3e5462d8.verified.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@
3434
Enabled: true
3535
},
3636
Rest: {
37-
Methods: [
38-
Get,
39-
Post,
40-
Put,
41-
Patch,
42-
Delete
43-
],
4437
Enabled: true
4538
},
4639
Permissions: [

src/Cli.Tests/Snapshots/AddEntityTests.AddNewEntityWhenEntitiesEmpty.verified.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@
3434
Enabled: true
3535
},
3636
Rest: {
37-
Methods: [
38-
Get,
39-
Post,
40-
Put,
41-
Patch,
42-
Delete
43-
],
4437
Enabled: true
4538
},
4639
Permissions: [

src/Cli.Tests/Snapshots/AddEntityTests.AddNewEntityWhenEntitiesNotEmpty.verified.txt

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@
3434
Enabled: true
3535
},
3636
Rest: {
37-
Methods: [
38-
Get,
39-
Post,
40-
Put,
41-
Patch,
42-
Delete
43-
],
4437
Enabled: true
4538
},
4639
Permissions: [
@@ -70,13 +63,6 @@
7063
Enabled: true
7164
},
7265
Rest: {
73-
Methods: [
74-
Get,
75-
Post,
76-
Put,
77-
Patch,
78-
Delete
79-
],
8066
Enabled: true
8167
},
8268
Permissions: [

src/Cli.Tests/Snapshots/EndToEndTests.TestConfigGeneratedAfterAddingEntityWithSourceWithDefaultType.verified.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,6 @@
4343
Enabled: true
4444
},
4545
Rest: {
46-
Methods: [
47-
Get,
48-
Post,
49-
Put,
50-
Patch,
51-
Delete
52-
],
5346
Enabled: true
5447
},
5548
Permissions: [

src/Cli.Tests/Snapshots/EndToEndTests.TestConfigGeneratedAfterAddingEntityWithoutIEnumerables.verified.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,6 @@
4040
Enabled: true
4141
},
4242
Rest: {
43-
Methods: [
44-
Get,
45-
Post,
46-
Put,
47-
Patch,
48-
Delete
49-
],
5043
Enabled: true
5144
},
5245
Permissions: [

src/Cli.Tests/Snapshots/UpdateEntityTests.TestConversionOfSourceObject_a70c086a74142c82.verified.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,7 @@
4141
},
4242
Rest: {
4343
Methods: [
44-
Get,
45-
Post,
46-
Put,
47-
Patch,
48-
Delete
44+
Post
4945
],
5046
Enabled: true
5147
},

src/Cli.Tests/Snapshots/UpdateEntityTests.TestConversionOfSourceObject_c26902b0e44f97cd.verified.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@
3636
},
3737
Rest: {
3838
Methods: [
39-
Get,
40-
Post,
41-
Put,
42-
Patch,
43-
Delete
39+
Post
4440
],
4541
Enabled: true
4642
},

0 commit comments

Comments
 (0)