Fix JSON schema: fix allow-credentials default, add missing descriptions, and relax required field constraints#3236
Fix JSON schema: fix allow-credentials default, add missing descriptions, and relax required field constraints#3236
Conversation
… to all user-facing booleans Co-authored-by: JerryNixon <1749983+JerryNixon@users.noreply.github.com>
There was a problem hiding this comment.
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
descriptionfields 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.paginationis missingadditionalProperties: false(unlike other runtime sub-objects such asruntime.rest/runtime.graphql). Without it, typos/unknown pagination keys will still pass schema validation and be silently ignored at runtime. Consider adding"additionalProperties": falseunderpagination.
"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 link the associated task with this PR. |
Could you share the issue number to link? I'll update the PR description with the |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
… copilot/fix-json-schema-bugs
|
@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 TestBasicConfigSchemaWithNoEntityFieldsIsInvalid Assert.IsTrue failed. Stack trace MS SQL Integration tests: Validates the complete config. |
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.
…re/data-api-builder into copilot/fix-json-schema-bugs
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
Why make this change?
Several bugs exist in
schemas/dab.draft.schema.jsonrelative to the official DAB documentation and correct JSON schema behavior:runtime.host.cors.allow-credentialshad its schemadefaultincorrectly set to the string"false"instead of the booleanfalse, while all otherboolean-or-stringproperties in the schema used proper boolean defaults.descriptionfields, reducing IntelliSense and tooling discoverability.#/$defs/boolean-or-string, preventing users from supplying@env()/@akv()environment variable references.requiredconstraints were either missing or overly strict relative to the documentation (e.g.runtime.rest.enabled,runtime.graphql.enabledmarked required when they are optional, and entity fields not conditionally required).What is this change?
runtime.host.cors.allow-credentialsdefault from"false"(JSON string) tofalse(JSON boolean), consistent with every otherboolean-or-stringproperty in the schema.descriptionfields across runtime and entity configuration blocks (includinggraphql.type.singular,graphql.type.plural,relationships..cardinality, and others) to improve discoverability and tooling support.#/$defs/boolean-or-string, supporting@env('...')/@akv('...')patterns.requiredconstraints to better match the documented behavior (e.g. makingruntime.rest.enabledandruntime.graphql.enabledoptional, adding conditional requirements for entitykey-fieldswhen source type isview).How was this tested?
Sample Request(s)
A DAB config with CORS enabled — schema tooling (IntelliSense, validation) will now correctly default
allow-credentialsto the booleanfalseinstead of the string"false":{ "runtime": { "host": { "cors": { "origins": ["https://contoso.com"], "allow-credentials": false } } } }Using an environment variable reference (enabled by the
boolean-or-stringtype):{ "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:
Implementation notes:
Deliverables:
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.jsonin Azure/data-api-builder at commit3199765c331340073f77b0c07666f1b1ff97b60cand compared it to the 5 issues.Note: I only found/checked
schemas/dab.draft.schema.jsonvia 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.typeis$ref’d to#/$defs/singular-plural.$defs.singular-plural,singularandpluralhave nodescriptionfields. (So the requested descriptions aren’t present.)entities.<entity>.relationships.<relationship>.cardinalityexists but has nodescription.Evidence (file locations):
relationships.*.cardinalityhas enum but no description:schemas/dab.draft.schema.jsonlines ~1132-1135. citeturn2commentary$defs.singular-pluraldefinessingular/pluralwithout descriptions: lines ~1448-1466. citeturn2commentary#2519 — JSON Schema: Inaccurate Required/Not-Required constraints
Partially resolved, mostly not resolved. (Issue is still open.)
Resolved pieces:
data-source.options.databaseanddata-source.options.schemaare conditionally required whendatabase-typeiscosmosdb_nosql.allOfblock that setsoptions.required: ["database","schema"]and also requires"options"forcosmosdb_nosql.Evidence:
data-sourceallOf/cosmosdb_nosqlbranch requiresdatabaseandschema: lines 88-121. citeturn2commentaryNot resolved / still discrepant:
runtime.rest.enabledandruntime.graphql.enabledare not marked required (good), but they also do not havedefault: truein the schema.$ref’d to#/$defs/boolean-or-stringand no default is specified there either.entities.<entity>.permissionsis 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.