Skip to content

Skip writing the HTTP actions to config file and log warning when RES…#1646

Merged
severussundar merged 1 commit intorelease/0.8from
dev/shyamsundarj/make-rest-methods-nullable-cherry-pick-1
Aug 24, 2023
Merged

Skip writing the HTTP actions to config file and log warning when RES…#1646
severussundar merged 1 commit intorelease/0.8from
dev/shyamsundarj/make-rest-methods-nullable-cherry-pick-1

Conversation

@severussundar
Copy link
Copy Markdown
Contributor

@severussundar severussundar commented Aug 23, 2023

  • Cherry Picks PR 1607 to release/0.8

…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.

![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.

- `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:

![image](https://github.com/Azure/data-api-builder/assets/11196553/287efcc2-e088-48b1-81f1-f762e18c2b51)
@severussundar severussundar merged commit 125aafa into release/0.8 Aug 24, 2023
@severussundar severussundar deleted the dev/shyamsundarj/make-rest-methods-nullable-cherry-pick-1 branch August 24, 2023 03:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants