Open
Description
What is it?
- Introduce a
fields
property under anentity
.
This gives us:
- a unified field description (in OpenAPI & GQL Schema)
- a toggle to include fields (in read operations)
- a net-new place for additional metadata
- a net-new place for metadata/input-validation (in mutation ops)
{
"entities": [
{
"<entity-name>": {
...
"fields": [
{
"<field-name>": {
"metadata": {
"key": <true> | <false> (default) // supersedes entity/key-fields
"alias": <alias-name> (optional) // supersedes entity/mapping
"description": <string> (optional)
"read-include": <true> (default) | <false> // supersedes entity/key-fields
},
"input-validation": {
"range": {
"min": <integer/inclusive>
"max": <integer/inclusive>
} (optional)
"regex-pattern": <string/.NET syntax> (optional)
"script": <string/TBD> (optional)
"required": <true> | <false> (default)
"error-message": <string> (optional)
} (optional)
...
List new properties
fields/
(array)
Defines a list of fields within an entity.fields/field-name
(string)
The name of a specific field within an entity.field-name/metadata
(object)
Contains metadata information for a field.metadata/key
(boolean)
Indicates if the field is a primary key.metadata/alias
(string)
An optional alias for the field.metadata/description
(string)
An optional description of the field.metadata/read-include
(boolean)
Determines if the field is included in read operations.field-name/input-validation
(object)
Validates the value of fields when submitted to an endpoint for mutations like insert or update.input-validation/range
(object)
Defines inclusive minimum and maximum values for the field.range/min
(integer)
Minimum inclusive value for the field.range/max
(integer)
Maximum inclusive value for the field.input-validation/regex-pattern
(string)
A "must match" pattern using .NET regular expression syntax.input-validation/script
(string)
A TBD feature for custom validation logic, requires further discussion.input-validation/required
(boolean)
Optional indicator that null/empty are invalid. Allows for field to be omitted during insert & update when false.input-validation/error-message
(string)
Optional custom error message for validation failure.
Explain metadata
Allows the developer to include field-specific description
. And more in the future.
Where does description show up?
- OpenAPI (descriptions associated with fields)
- GraphQL Schema (descriptions associated with fields)
Explain validation
Validation is input validation intended to validate values for inserts & updates.
Questions
- If a field is not included in the fields array, is it returned in the GET operation? (see
read-include
) Needs discussion. - If more than one type of input-validation is included, does that mean we run them all?
- How are we going to support script?
- Roslyn Scripting: https://github.com/dotnet/roslyn/blob/main/docs/wiki/Scripting-API-Samples.md
- POC: https://github.com/JerryNixon/embedded-csharp
Related items that will be closed
- [Improvement]: Mappings are ignored when using stored procedures #1773
- Add entity field/parameter mapping support for Stored Procedures #661
- [Enhancement] Add support for mappings feature for Cosmos DB #1512
- Excluding columns from entities by default (without permissions) #1376
- [Bug]: Cannot start DAB when a table has a non-supported data type, even if the column has been added to the exclude list #1503