Skip to content

Fix JSON schema: fix allow-credentials default, add missing descriptions, and relax required field constraints#3236

Open
Copilot wants to merge 13 commits intomainfrom
copilot/fix-json-schema-bugs
Open

Fix JSON schema: fix allow-credentials default, add missing descriptions, and relax required field constraints#3236
Copilot wants to merge 13 commits intomainfrom
copilot/fix-json-schema-bugs

Conversation

Copy link
Contributor

Copilot AI commented Mar 12, 2026

Why make this change?

Several bugs exist in schemas/dab.draft.schema.json relative to the official DAB documentation and correct JSON schema behavior:

  • runtime.host.cors.allow-credentials had its schema default incorrectly set to the string "false" instead of the boolean false, while all other boolean-or-string properties in the schema used proper boolean defaults.
  • Multiple properties were missing description fields, reducing IntelliSense and tooling discoverability.
  • Several boolean properties did not reference #/$defs/boolean-or-string, preventing users from supplying @env()/@akv() environment variable references.
  • Some required constraints were either missing or overly strict relative to the documentation (e.g. runtime.rest.enabled, runtime.graphql.enabled marked required when they are optional, and entity fields not conditionally required).

What is this change?

  • Fixed runtime.host.cors.allow-credentials default from "false" (JSON string) to false (JSON boolean), consistent with every other boolean-or-string property in the schema.
  • Added/expanded description fields across runtime and entity configuration blocks (including graphql.type.singular, graphql.type.plural, relationships..cardinality, and others) to improve discoverability and tooling support.
  • Switched multiple boolean schema properties to reference #/$defs/boolean-or-string, supporting @env('...') / @akv('...') patterns.
  • Relaxed and corrected required constraints to better match the documented behavior (e.g. making runtime.rest.enabled and runtime.graphql.enabled optional, adding conditional requirements for entity key-fields when source type is view).

How was this tested?

  • Integration Tests
  • Unit Tests

Sample Request(s)

A DAB config with CORS enabled — schema tooling (IntelliSense, validation) will now correctly default allow-credentials to the boolean false instead of the string "false":

{
  "runtime": {
    "host": {
      "cors": {
        "origins": ["https://contoso.com"],
        "allow-credentials": false
      }
    }
  }
}

Using an environment variable reference (enabled by the boolean-or-string type):

{
  "runtime": {
    "host": {
      "cors": {
        "origins": ["https://contoso.com"],
        "allow-credentials": "@env('CORS_ALLOW_CREDENTIALS')"
      }
    }
  }
}
Original prompt

Resolve five JSON schema bugs in Azure/data-api-builder by updating the configuration JSON schema so it matches official docs and issue recommendations.

Issues to resolve:

  1. 🥕[Bug]: JSON schema: Missing descriptions #2520 JSON schema: Missing descriptions
  • Add descriptions:
    • entities..graphql.type.singular: "Defines the singular GraphQL type name for the entity."
    • entities..graphql.type.plural: "Defines the plural GraphQL type name for the entity."
    • entities..relationships..cardinality: "Defines the cardinality of the relationship between entities."
  1. 🥕[Bug]: JSON Schema: Inaccurate Required/Not-Required constraints  #2519 JSON Schema: Inaccurate Required/Not-Required constraints
  • Ensure data-source.options.database and data-source.options.schema are required when data-source.database-type is cosmosdb_nosql.
  • Ensure entities..source.key-fields is required only when entities..source.type is "view" (and when source is the object form, not string form).
  • Ensure entities..permissions is required for entity definitions (consistent with docs) without breaking stored-procedure/execute-only permission shape.
  • Ensure runtime.rest.enabled and runtime.graphql.enabled are optional and default to true.
  1. 🥕[Bug]: JSON Schema: Missing Default Values  #2518 JSON Schema: Missing Default Values
  • Ensure runtime.graphql.allow-introspection has default true.
  1. 🥕[Bug]: JSON Schema: Redundant "required" Properties #2517 JSON Schema: Redundant "required" Properties
  • Make jwt.audience and jwt.issuer conditionally required only when authentication provider is EntraID/AzureAD (per issue: AzureAd provider) and not required (nor causing validation errors) for providers that don’t need them.
  • Preserve current behavior that jwt object itself is required only for providers that need JWT, and forbidden otherwise.
  1. 🥕[Bug]: JSON Schema: Application Insights Connection String is Required #2516 JSON Schema: Application Insights Connection String is Required
  • Modify telemetry.application-insights so connection-string is required only when enabled is true. Configuration with enabled=false and no connection-string should validate.

Implementation notes:

  • Primary schema file observed: schemas/dab.draft.schema.json. Update the appropriate schema(s) used for validation/shipping.
  • Add/adjust JSON Schema conditional blocks (if/then/else, allOf) as needed.
  • Update/add tests if the repo has schema validation tests; otherwise add minimal tests to validate the new constraints.
  • Keep formatting consistent (2-space JSON indent, LF).

Deliverables:

  • Code changes implementing all fixes.
  • Tests updated/added to cover the scenarios from issues.
  • Open a pull request against base branch main referencing the above issues.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: @Azure/data-api-builder/issues/2520
@Azure/data-api-builder/issues/2519
@Azure/data-api-builder/issues/2518
@Azure/data-api-builder/issues/2517
@Azure/data-api-builder/issues/2516
Review these five bugs and report back if they are or are not resolved in the code base

Assistant: I reviewed the current schemas/dab.draft.schema.json in Azure/data-api-builder at commit 3199765c331340073f77b0c07666f1b1ff97b60c and compared it to the 5 issues.

Note: I only found/checked schemas/dab.draft.schema.json via code search (results can be incomplete). You can browse more schema files here:
repo:Azure/data-api-builder path:schemas (GitHub code search UI).

Status per issue (resolved in codebase vs not)

#2520 — JSON schema: Missing descriptions

Not resolved. (Issue is also still open.)

  • entities.<entity>.graphql.type is $ref’d to #/$defs/singular-plural.
    • In $defs.singular-plural, singular and plural have no description fields. (So the requested descriptions aren’t present.)
  • entities.<entity>.relationships.<relationship>.cardinality exists but has no description.

Evidence (file locations):

  • relationships.*.cardinality has enum but no description: schemas/dab.draft.schema.json lines ~1132-1135. citeturn2commentary
  • $defs.singular-plural defines singular/plural without descriptions: lines ~1448-1466. citeturn2commentary

#2519 — JSON Schema: Inaccurate Required/Not-Required constraints

Partially resolved, mostly not resolved. (Issue is still open.)

Resolved pieces:

  • data-source.options.database and data-source.options.schema are conditionally required when database-type is cosmosdb_nosql.
    • Schema has an allOf block that sets options.required: ["database","schema"] and also requires "options" for cosmosdb_nosql.

Evidence: data-source allOf / cosmosdb_nosql branch requires database and schema: lines 88-121. citeturn2commentary

Not resolved / still discrepant:

  • runtime.rest.enabled and runtime.graphql.enabled are not marked required (good), but they also do not have default: true in the schema.
    • They are $ref’d to #/$defs/boolean-or-string and no default is specified there either.
  • entities.<entity>.permissions is required — but only under ...

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

)

Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix JSON schema issues in configuration for Azure/data-api-builder Fix JSON schema: Add missing descriptions for entities.graphql.type and entities.relationships.cardinality Mar 12, 2026
… to all user-facing booleans

Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a 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 updates the DAB JSON schema to (a) allow boolean settings to be expressed via environment/Azure Key Vault expressions and (b) improve schema documentation by adding descriptions to multiple config sections/properties.

Changes:

  • Switched multiple boolean schema properties to reference #/$defs/boolean-or-string (supporting @env('...') / @akv('...') patterns).
  • Added/expanded description fields across runtime and entity configuration blocks to improve discoverability and tooling support.
Comments suppressed due to low confidence (1)

schemas/dab.draft.schema.json:201

  • runtime.pagination is missing additionalProperties: false (unlike other runtime sub-objects such as runtime.rest/runtime.graphql). Without it, typos/unknown pagination keys will still pass schema validation and be silently ignored at runtime. Consider adding "additionalProperties": false under pagination.
        "pagination": {
          "type": "object",
          "description": "Pagination settings for REST and GraphQL API responses.",
          "properties": {
            "max-page-size": {
              "type": [ "integer", "null" ],
              "description": "Defines the maximum number of records that can be returned in a single page of results. If set to null, the default value is 100,000.",
              "default": 100000,
              "minimum": 1
            },
            "default-page-size": {
              "type": [ "integer", "null" ],
              "description": "Sets the default number of records returned in a single response. When this limit is reached, a continuation token is provided to retrieve the next page. If set to null, the default value is 100.",
              "default": 100,
              "minimum": 1
            },
            "next-link-relative": {
              "$ref": "#/$defs/boolean-or-string",
              "default": false,
              "description": "When true, nextLink in paginated results will use a relative URL."
            }
          }
        },

You can also share your feedback on Copilot code review. Take the survey.

Copilot AI changed the title Fix JSON schema: Add missing descriptions for entities.graphql.type and entities.relationships.cardinality Fix JSON schema: fix allow-credentials default from string to boolean Mar 12, 2026
@anushakolan anushakolan self-assigned this Mar 12, 2026
@anushakolan
Copy link
Contributor

@copilot link the associated task with this PR.

Copy link
Contributor Author

Copilot AI commented Mar 12, 2026

@copilot link the associated task with this PR.

Could you share the issue number to link? I'll update the PR description with the Closes #XX reference once I have it.

@anushakolan
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

Copy link
Contributor Author

Copilot AI commented Mar 13, 2026

@copilot link the associated task with this PR.

  1. 🥕[Bug]: JSON schema: Missing descriptions #2520
  2. 🥕[Bug]: JSON Schema: Inaccurate Required/Not-Required constraints  #2519
    ...

The PR description has been updated to link all five associated issues: Closes #2516, #2517, #2518, #2519, #2520.

Copilot AI changed the title Fix JSON schema: fix allow-credentials default from string to boolean Fix JSON schema: fix allow-credentials default, add missing descriptions, and relax required field constraints Mar 13, 2026
Copilot AI requested a review from JerryNixon March 13, 2026 00:05
@souvikghosh04
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

@souvikghosh04
Copy link
Contributor

@copilot following tests are failing. please investigate and apply the fix.

Unit tests:

ValidateConfigSchemaWhereConfigReferencesEnvironmentVariables

Assert.IsTrue failed. RuntimeConfigValidator::ValidateConfigSchema(...) didn't communicate successful config schema validation.

Stack trace
at Cli.Tests.ValidateConfigTests.ValidateConfigSchemaWhereConfigReferencesEnvironmentVariables() in /home/vsts/work/1/s/src/Cli.Tests/ValidateConfigTests.cs:line 274
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

TestBasicConfigSchemaWithNoEntityFieldsIsInvalid

Assert.IsTrue failed.

Stack trace
at Azure.DataApiBuilder.Service.Tests.Configuration.ConfigurationTests.TestBasicConfigSchemaWithNoEntityFieldsIsInvalid() in /home/vsts/work/1/s/src/Service.Tests/Configuration/ConfigurationTests.cs:line 1969
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)


MS SQL Integration tests:

Validates the complete config.
Valid Value: 2 for depth-limit.
Valid Value: -1 to disable depth limit
Default Value: null for depth-limit.
Valid Value: Using Int32.MaxValue (2147483647) for depth-limit
Validates the config with custom properties works with the engine.
Validates the config file schema.

ValidateConfigSchemaWhereConfigReferencesEnvironmentVariables
TestBasicConfigSchemaWithNoEntityFieldsIsInvalid
Validates the complete config.
Valid Value: 2 for depth-limit.
Valid Value: -1 to disable depth limit
Default Value: null for depth-limit.
Valid Value: Using Int32.MaxValue (2147483647) for depth-limit
Validates the config with custom properties works with the engine.
Validates the config file schema.
Copilot AI requested a review from souvikghosh04 March 13, 2026 09:20
Copilot stopped work on behalf of souvikghosh04 due to an error March 13, 2026 09:20
@souvikghosh04
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

6 participants