Commit 80a7f7d
feat: dab init defaults runtime.rest.request-body-strict to false (#3166)
## Why make this change?
`dab init` generated configs with `request-body-strict: true`, causing
REST endpoints to reject requests with extra/unmapped fields by default.
This added friction for new users and modern scenarios where flexible
request bodies are preferred.
## What is this change?
- **`ConfigGenerator.cs`**: Changed the `RestRequestBodyStrict`
defaulting logic from `CliBool.False ? false : true` to `CliBool.True ?
true : false` — when `--rest.request-body-strict` is omitted, the
generated config now writes `false`
- **`RestRuntimeOptions.cs`**: The record default (`RequestBodyStrict =
true`) is preserved for backward compatibility — existing configs that
omit this field continue to behave as before. Rewrote XML doc to be
internally consistent: `true` rejects extraneous/unmapped fields;
`false` allows and ignores them. Includes a note distinguishing the
record default (`true`, for backward compat) from the `dab init`
generated default (`false`).
- **`InitOptions.cs`**: Updated `--rest.request-body-strict` help text
to `"(Default: false) When true, rejects extraneous/unmapped fields in
the REST request body. When false, allows and ignores them."` and
replaced the stale preceding code comment with a clear description of
both modes.
- Snapshot files and hardcoded expected JSON in `ConfigGeneratorTests`
updated to reflect the new generated default
- **`config-generators/*.txt`**: Added `--rest.request-body-strict true`
explicitly to `dab init` commands in `mssql-commands.txt`,
`mysql-commands.txt`, `postgresql-commands.txt`, and
`dwsql-commands.txt` — these scripts regenerate integration test config
files during CI builds, and those configs must retain strict mode
(`true`) for integration tests that validate extraneous-field rejection
behavior
-
**`ConfigurationTests.TestReadingRuntimeConfigForCosmos.verified.txt`**:
Updated snapshot to set `RequestBodyStrict: false` to reflect the new
default
## How was this tested?
- [x] Integration Tests
- Config-generator command files updated to keep integration test
configs in strict mode, preserving all existing integration test
behavior (e.g. `PutOneTestWithExtraneousFieldsInRequestBody`)
- [x] Unit Tests
- `TestRestRequestBodyStrictMode` — updated `DataRow` for the no-flag
case to assert `false`
- `ConfigGeneratorTests.TestSpecialCharactersInConnectionString` —
updated expected JSON
- All 30 `InitTests` snapshots and 7 `EndToEndTests` snapshots (those
that invoke `dab init` without the flag) updated to `RequestBodyStrict:
false`
- `ConfigurationTests.TestReadingRuntimeConfigForCosmos` snapshot
updated to `RequestBodyStrict: false`
- `AddEntityTests` and `UpdateEntityTests` snapshots intentionally
unchanged — those use pre-built config strings, not `dab init`, and
correctly reflect the record default of `true`
## Sample Request(s)
```bash
dab init --database-type mssql --connection-string "@env('conn')"
```
Generated `dab-config.json` runtime section:
```json
"rest": {
"enabled": true,
"path": "/api",
"request-body-strict": false
}
```
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>dab init to default runtime.rest.request-body-strict to
false </issue_title>
> <issue_description>## What?
>
> When `dab init` is run, update its behavior to default
`runtime.rest.request-body-strict` to `false` in the generated config.
This will allow REST request bodies to accept and ignore additional
fields by default, making development smoother and reducing unexpected
errors.
>
> ## Why?
>
> Currently, `dab init` in the CLI generates a `dab-config.json` where
the `runtime.rest.request-body-strict` option defaults to `true` (strict
mode). This means all extraneous/unmapped fields in REST request bodies
are rejected by default, including keys. This can cause confusion for
new users and adds friction for modern scenarios where flexible request
bodies are preferred, especially with C# developers.</issue_description>
>
> <agent_instructions>Introduce as little change as
possible</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #3165
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/Azure/data-api-builder/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: JerryNixon <[email protected]>
Co-authored-by: Aniruddh Munde <[email protected]>
Co-authored-by: Aniruddh25 <[email protected]>
Co-authored-by: aaronburtle <[email protected]>1 parent 3199765 commit 80a7f7d
47 files changed
Lines changed: 51 additions & 51 deletions
File tree
- config-generators
- src
- Cli.Tests
- Snapshots
- Cli
- Commands
- Config/ObjectModel
- Service.Tests/Snapshots
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1224 | 1224 | | |
1225 | 1225 | | |
1226 | 1226 | | |
1227 | | - | |
| 1227 | + | |
1228 | 1228 | | |
1229 | 1229 | | |
1230 | 1230 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
0 commit comments