Skip writing the HTTP actions to config file and log warning when REST Methods are configured for tables/views - #1607
Merged
Shyam Sundar J (severussundar) merged 15 commits intoAug 17, 2023
Conversation
Shyam Sundar J (severussundar)
marked this pull request as ready for review
July 26, 2023 06:01
Shyam Sundar J (severussundar)
requested review from
Aniruddh Munde (Aniruddh25),
Jelte Fennema-Nio (JelteF),
Mathieu Tremblay (Mathos1432),
aaronburtle,
Aaron Powell (aaronpowell),
Abhishek Kumar (abhishekkumams),
Ayush Agarwal (ayush3797),
Gledis Zeneli (gledis69),
Bhaskar Mallapragada (mbhaskar),
Milis (milismsft),
Ravi Shetye (ravishetye),
Sean Leonard (seantleonard) and
tarazou9
as code owners
July 26, 2023 06:01
Sean Leonard (seantleonard)
left a comment
Contributor
There was a problem hiding this comment.
Some questions.
Shyam Sundar J (severussundar)
requested a review
from Sean Leonard (seantleonard)
July 27, 2023 12:29
Contributor
|
Some questions and suggestions around the same. Looks good so far! |
Aniruddh Munde (Aniruddh25)
left a comment
Collaborator
There was a problem hiding this comment.
Looks good so far, left few comments.
Shyam Sundar J (severussundar)
requested review from
Aniruddh Munde (Aniruddh25) and
Ayush Agarwal (ayush3797)
July 31, 2023 13:12
Aniruddh Munde (Aniruddh25)
approved these changes
Aug 2, 2023
Aniruddh Munde (Aniruddh25)
left a comment
Collaborator
There was a problem hiding this comment.
Thanks for noticing this bug and fixing it for 0.8!
Shyam Sundar J (severussundar)
requested a review
from Sean Leonard (seantleonard)
August 7, 2023 11:05
Ayush Agarwal (ayush3797)
approved these changes
Aug 16, 2023
Ayush Agarwal (ayush3797)
left a comment
Contributor
There was a problem hiding this comment.
Just one question. LGTM! Thanks for fixing this!
Shyam Sundar J (severussundar)
deleted the
dev/shyamsundarj/make-rest-methods-nullable
branch
August 17, 2023 06:11
Shyam Sundar J (severussundar)
added a commit
that referenced
this pull request
Aug 23, 2023
…T Methods are configured for tables/views (#1607) - 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.  - However, for tables/views, the `Methods` property does not play any role and can be skipped writing to the config file. - `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 - [x] Integration Tests - [x] Unit Tests - [x] Manual Tests - 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: 
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why make this change?
Closes Make the REST Methods property nullable in EntityRestOptions class #1571 Need to unignore test once behavior of stored procedures is fixed #1570
At the moment, CLI writes out all the 5 HTTP methods to the config file when adding an entity backed by table/view.

However, for tables/views, the
Methodsproperty does not play any role and can be skipped writing to the config file.What is this change?
EntityRestOptions:Methodsproperty is made nullable. References where it was initialized with an empty array is updated tonull. Appropriatenullchecks are added.EntityRestOptionsConverter: Serialization logic is updated to write to the config file only when theMethodswithin REST element is not emptyRuntimeConfigValidator.ValidatePresenceOfExtraRestProperties(): Helper method to log a warning message whenMethodsproperty is added manually to an entity backed by table/view.dab-config.*files -Methodsproperty is removed from the reference config filesHow was this tested?
Sample Request(s)
dab add books --source books --permissions "anonymous:*"Config Json created:
methodsproperty to a table/view, engine logs a warning message during start-upConfig:
Warning Logged: