-
Notifications
You must be signed in to change notification settings - Fork 286
Honor methods property for entities backed by tables/views #2945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR extends REST method filtering configuration to work with tables and views, not just stored procedures. Previously, the methods property was ignored for tables/views, always exposing all 5 HTTP verbs regardless of configuration. This change enables read-only REST APIs and generates clean OpenAPI documents that only include configured operations.
Key changes include:
- Runtime method enforcement before authorization checks for all entity types
- OpenAPI document filtering to only include configured operations and conditionally generate request schemas
- CLI support for
--rest.methodswith tables/views and updated help text
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/Service.Tests/dab-config.MsSql.json |
Adds test entity configurations for read-only, write-only, and partial CRUD scenarios |
src/Service.Tests/SqlTests/RestApiTests/MethodEnforcementTests.cs |
New integration tests for runtime method enforcement on tables/views |
src/Service.Tests/OpenApiDocumentor/SchemaGenerationTests.cs |
New tests validating conditional schema generation based on configured methods |
src/Service.Tests/OpenApiDocumentor/PathValidationTests.cs |
Updated tests to verify filtered operations in OpenAPI documents |
src/Service.Tests/OpenApiDocumentor/MethodFilteringTests.cs |
New unit tests for the GetConfiguredRestOperations method behavior |
src/Service.Tests/Configuration/ConfigurationTests.cs |
Adds test for custom OpenAPI description configuration |
src/Core/Services/RestService.cs |
Updates method enforcement to apply to all entity types, not just stored procedures |
src/Core/Services/OpenAPI/OpenApiDocumentor.cs |
Implements operation filtering and conditional schema generation for OpenAPI documents |
src/Core/Configurations/RuntimeConfigValidator.cs |
Removes obsolete validation that prevented methods configuration on tables/views |
src/Config/ObjectModel/RuntimeOptions.cs |
Adds OpenApiDescription property to runtime configuration |
src/Config/ObjectModel/RuntimeConfig.cs |
Exposes OpenApiDescription through runtime config |
src/Cli/ConfigGenerator.cs |
Updates CLI to support REST methods for all entity types |
src/Cli/Commands/InitOptions.cs |
Adds OpenApiDescription option to init command |
src/Cli/Commands/EntityOptions.cs |
Updates help text to indicate methods apply to all entity types |
src/Cli/Commands/ConfigureOptions.cs |
Adds OpenApiDescription option to configure command |
src/Cli.Tests/InitTests.cs |
Tests OpenApiDescription configuration during init |
src/Cli.Tests/ConfigureOptionsTests.cs |
Tests OpenApiDescription configuration during update |
schemas/dab.draft.schema.json |
Adds schema definition for openapi-description property |
docs/fork-management-guide.md |
New documentation for maintaining custom features while tracking upstream |
README.md |
Adds example of openapi-description in configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9a209c2 to
ff4ba95
Compare
ff4ba95 to
c6258e9
Compare
|
First, thank you for your contribution. A request before future pull requestsI really wish we could have discussed this proposal before you opened the PR. It would have saved some effort and clarified direction early. Let’s walk through what’s happening here. The current behaviorAs described in #1771, Data API builder supports read-only REST operations today by restricting the Example: {
"entities": {
"book": {
"permissions": [
{
"role": "anonymous",
"actions": [ "read" ] // read-only for anonymous
}
]
}
}
}Even in this simple case, the OpenAPI output still lists all HTTP methods, which is incorrect. Now consider a second role: {
"entities": {
"book": {
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] },
{ "role": "authorized", "actions": [ "create", "read", "update" ] }
]
}
}
}Again, the OpenAPI output still includes every REST method, ignoring that And if we add a third role: {
"entities": {
"book": {
"permissions": [
{ "role": "anonymous", "actions": [ "read" ] },
{ "role": "authorized", "actions": [ "create", "read", "update" ] },
{ "role": "administrator", "actions": [ "create", "read", "update", "delete" ] }
]
}
}
}The OpenAPI document still shows all methods. That’s the core problem: the available REST methods depend on the user’s role, yet the OpenAPI document ignores this and presents them all. Why the proposed
|
|
Closed pending a future conversation. |
Why make this change?
Closes #1771
Currently, the
methodsproperty in REST configuration only applies to stored procedures. For tables and views, all 5 HTTP verbs (GET, POST, PUT, PATCH, DELETE) are always exposed in the OpenAPI document and allowed at runtime, regardless of themethodsconfiguration. This creates a mismatch between the API contract (OpenAPI) and the intended API surface.Users need the ability to expose read-only REST APIs for views/tables used in reporting and analytics scenarios, and to generate clean OpenAPI documents for API Management (APIM) integration. This change extends
methodsfiltering to tables and views, making the configuration work consistently across all entity types.What is this change?
This change extends the REST
methodsconfiguration property to work with tables and views, not just stored procedures. Previously, configuringmethodson tables/views was ignored - all 5 HTTP verbs were always exposed in the OpenAPI document and allowed at runtime.The implementation includes:
_NoAutoPKfor POST,_NoPKfor PUT/PATCH)--rest.methodsfrom being used with tables/views, and updates help text to reflect support for all entity typesmethodsapplies to all entity typesKey design decisions:
methodsarray or null/undefined values continue to allow all 5 HTTP verbs (backward compatible default behavior)How was this tested?
New Test Files:
src/Service.Tests/RestApiTests/MethodEnforcementTests.cs- Runtime method enforcement for tables/viewssrc/Service.Tests/OpenApiDocumentor/MethodFilteringTests.cs- OpenAPI operation filteringModified Test Files:
src/Service.Tests/OpenApiDocumentor/PathValidationTests.cs- Verify filtered operations in OpenAPI documentsrc/Service.Tests/OpenApiDocumentor/DocumentVerbosityTests.cs- Verify schema pruningsrc/Service.Tests/Configuration/ConfigurationTests.cs- Existing stored procedure tests continue to pass