Skip writing the HTTP actions to config file and log warning when REST Methods are configured for tables/views#1607
Merged
severussundar merged 15 commits intomainfrom Aug 17, 2023
Conversation
ayush3797
reviewed
Jul 28, 2023
ayush3797
reviewed
Jul 28, 2023
ayush3797
reviewed
Jul 28, 2023
ayush3797
reviewed
Jul 28, 2023
ayush3797
reviewed
Jul 28, 2023
ayush3797
reviewed
Jul 28, 2023
ayush3797
reviewed
Jul 28, 2023
ayush3797
reviewed
Jul 28, 2023
ayush3797
reviewed
Jul 28, 2023
ayush3797
reviewed
Jul 28, 2023
ayush3797
reviewed
Jul 28, 2023
Contributor
|
Some questions and suggestions around the same. Looks good so far! |
Aniruddh25
reviewed
Jul 29, 2023
Collaborator
Aniruddh25
left a comment
There was a problem hiding this comment.
Looks good so far, left few comments.
Aniruddh25
reviewed
Jul 29, 2023
Aniruddh25
approved these changes
Aug 2, 2023
Collaborator
Aniruddh25
left a comment
There was a problem hiding this comment.
Thanks for noticing this bug and fixing it for 0.8!
ayush3797
reviewed
Aug 16, 2023
ayush3797
approved these changes
Aug 16, 2023
Contributor
ayush3797
left a comment
There was a problem hiding this comment.
Just one question. LGTM! Thanks for fixing this!
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: