Skip to content

Support scalar-only union values in generated connector property maps (Python) #104

Open

Description

@daviburg

Problem

The generated connector SDK needs to preserve a scalar-only application-property map contract. A JSON Schema value can allow strings, numbers and Booleans while excluding nested objects and arrays. Treating schema type as only a single string does not represent that contract; an object-only generated value model rejects valid scalar callers, while unrestricted values erase the declared constraint.

This issue tracks SDK/generator support, separately from corrections needed in a connector's published source schema. A generated SDK must not guess scalar support from an empty object definition.

Minimal Schema

{
  "type": "object",
  "properties": {
    "Properties": {
      "type": "object",
      "additionalProperties": {
        "type": ["string", "number", "boolean"]
      }
    }
  }
}

This is a JSON Schema example, not a claim that every Swagger 2.0 importer accepts array-valued type. Equivalent union constructs must be handled according to the supported schema dialect. If the import path cannot preserve a construct, provide an actionable diagnostic rather than silently dropping it or publishing an incorrect generated contract.

Valid property maps include {"eventType":"sample"}, {"attempt":1,"ratio":1.5}, {"enabled":true}, and a mixture of those values. {"eventType":{"value":"sample"}} and {"eventType":["sample"]} are outside this scalar-only contract. JSON Schema number includes integers. Nullability is a separate contract decision, not assumed here.

Expected Result

Emit a dictionary whose value annotation preserves the allowed scalar alternatives, for example dict[str, str | int | float | bool], with the repository-supported spelling. Do not emit ObjectEntity-valued maps or silently widen an explicit scalar-only union to Any.

Acceptance Criteria

  • Generate from a pinned scalar-union schema and verify the emitted API/model, not just generator source text.
  • Type-level positive cases accept each scalar type and mixed maps; negative cases reject object/array entries where the language supports static checking.
  • Serialization preserves JSON strings, numbers and Booleans without coercing every value to text.
  • Exercise supported equivalent union forms and unsupported-dialect diagnostics; do not silently discard union constraints.
  • Preserve genuinely object-valued maps, including referenced structured model schemas. Do not globally reinterpret object-only schemas as scalar unions.
  • Keep generated operation inventories and distinct wire-property names unchanged.
  • Test nullable and non-nullable contracts separately. Designer enforcement is not required for this SDK work.

Public Context

The Event Hubs scalar-property typing symptom was reported in this public Python SDK review discussion. The reproducer above is synthetic and independent of any deployment, subscription, account or non-public repository.

Specification: JSON Schema Draft-4 type validation.


Prepared with GitHub Copilot.

Cross-Language Tracking

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions