data-api-builder icon indicating copy to clipboard operation
data-api-builder copied to clipboard

🥕[Bug]: JSON Schema: Redundant "required" Properties

Open JerryNixon opened this issue 1 year ago • 0 comments

The jwt.audience and jwt.issuer properties are not currently marked as required. However, for the AzureAd provider, these properties are essential for proper authentication configuration and should be required. For other providers, such as StaticWebApps, AppService, or Simulator, they are unnecessary and should not trigger schema validation errors.

Suggestion

Update the schema to include conditional validation:

Current Schema

"authentication": {
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "provider": {
      "type": "string",
      "description": "The name of the authentication provider",
      "default": "StaticWebApps"
    },
    "jwt": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "audience": {
          "type": "string"
        },
        "issuer": {
          "type": "string"
        }
      }
    }
  }
}

Updated Schema

"authentication": {
  "type": "object",
  "properties": {
    "provider": {
      "type": "string",
      "enum": ["StaticWebApps", "AppService", "AzureAd", "Simulator"]
    },
    "jwt": {
      "type": "object",
      "properties": {
        "audience": { "type": "string" },
        "issuer": { "type": "string" }
      }
    }
  },
  "required": ["provider"],
  "allOf": [
    {
      "if": {
        "properties": { "provider": { "const": "AzureAd" } }
      },
      "then": {
        "properties": {
          "jwt": {
            "required": ["audience", "issuer"]
          }
        }
      }
    }
  ]
}

JerryNixon avatar Jan 13 '25 21:01 JerryNixon