Skip to content

fix: Correct EmailDomain model field deserialization#515

Open
BinoyOza-okta wants to merge 1 commit intomasterfrom
OKTA-1133517
Open

fix: Correct EmailDomain model field deserialization#515
BinoyOza-okta wants to merge 1 commit intomasterfrom
OKTA-1133517

Conversation

@BinoyOza-okta
Copy link
Contributor

Fix EmailDomain Model Deserialization - Missing Fields

🐛 Bug Description

The EmailDomainResponse and EmailDomain models were silently dropping 5-7 fields during deserialization, causing 3 of 6 email domain API endpoints to return incomplete data.

Affected Endpoints

Method Response Model Status Missing Fields
create_email_domain EmailDomainResponse Broken id, domain, validationStatus, dnsValidationRecords, validationSubdomain
replace_email_domain EmailDomainResponse Broken id, domain, validationStatus, dnsValidationRecords, validationSubdomain
verify_email_domain EmailDomainResponse Broken id, domain, validationStatus, dnsValidationRecords, validationSubdomain
get_email_domain EmailDomainResponseWithEmbedded ✅ Works -
list_email_domains List[EmailDomainResponseWithEmbedded] ✅ Works -
delete_email_domain None (204) ✅ N/A -

Reproduction

from okta.models.email_domain_response import EmailDomainResponse

# Before fix:
resp = EmailDomainResponse.from_dict({
    "id": "OeD123",
    "domain": "example.com",
    "displayName": "Test",
    "userName": "noreply",
    "validationStatus": "NOT_STARTED",
    "dnsValidationRecords": [{"fqdn": "...", "recordType": "TXT", "verificationValue": "..."}],
})

assert resp.id is None          # ❌ Expected "OeD123"
assert resp.domain is None      # ❌ Expected "example.com"
assert resp.display_name == "Test"  # ✅ Only these 2 fields worked
assert resp.user_name == "noreply"  # ✅

🔍 Root Cause

The OpenAPI specification (openapi/api.yaml) had incorrect indentation in the allOf composition for three schemas: EmailDomain, EmailDomainResponse, and EmailDomainResponseWithEmbedded.

❌ Before (Incorrect)

EmailDomainResponse:
  allOf:
    - $ref: '#/components/schemas/BaseEmailDomain'
  type: object          # ← Wrong indentation level
  properties:           # ← These properties were ignored
    dnsValidationRecords:
      type: array
    domain:
      type: string
    id:
      type: string

EmailDomainResponseWithEmbedded:
  allOf:
    - $ref: '#/components/schemas/EmailDomainResponse'
  type: object          # ← Wrong indentation level
  properties:           # ← _embedded property structure was malformed
    _embedded:
      type: object
      properties:
        brands:
          type: array

✅ After (Correct)

EmailDomainResponse:
  allOf:
    - $ref: '#/components/schemas/BaseEmailDomain'
    - type: object      # ← Properly nested under allOf
      properties:       # ← Now processed correctly
        dnsValidationRecords:
          type: array
        domain:
          type: string
        id:
          type: string

EmailDomainResponseWithEmbedded:
  allOf:
    - $ref: '#/components/schemas/EmailDomainResponse'
    - type: object      # ← Properly nested under allOf
      properties:       # ← Now generates proper nested model
        _embedded:
          type: object
          properties:
            brands:
              type: array

The OpenAPI generator only processed the schema references, completely ignoring the additional properties due to incorrect YAML structure.

🔧 Solution

1. Fixed OpenAPI Specification

  • Corrected indentation in EmailDomain schema (lines 64674-64683)
  • Corrected indentation in EmailDomainResponse schema (lines 64704-64719)
  • Corrected indentation in EmailDomainResponseWithEmbedded schema (lines 64721-64733)
  • Properties now properly nested under allOf composition for all three schemas

2. Regenerated Models

EmailDomain (Request Model)

  • __properties now includes: displayName, userName, brandId, domain, validationSubdomain
  • from_dict() now deserializes all 5 fields
  • to_dict() serializes all 5 fields

EmailDomainResponse (Response Model)

  • __properties now includes: displayName, userName, dnsValidationRecords, domain, id, validationStatus, validationSubdomain
  • from_dict() now deserializes all 7 fields with proper type conversion
  • to_dict() properly serializes dnsValidationRecords array by calling to_dict() on each EmailDomainDNSRecord

EmailDomainResponseWithEmbedded (Response Model with Embedded Brands)

  • ✅ Inherits correct field mapping from EmailDomainResponse (all 7 fields)
  • _embedded field now uses proper type EmailDomainResponseWithEmbeddedAllOfEmbedded instead of generic object
  • from_dict() correctly deserializes nested _embedded.brands array
  • to_dict() properly serializes nested _embedded object

EmailDomainResponseWithEmbeddedAllOfEmbedded (New Model - Generated)

  • ✅ New model generated for the _embedded property structure
  • ✅ Contains brands field as List[Brand]
  • ✅ Properly handles serialization/deserialization of brand relationships

3. Updated Documentation

  • Regenerated markdown documentation for all four models
  • All fields now properly documented

✅ Verification

After the fix, all fields are correctly deserialized:

from okta.models.email_domain_response import EmailDomainResponse

resp = EmailDomainResponse.from_dict({
    "id": "OeD123",
    "domain": "example.com",
    "displayName": "Test",
    "userName": "noreply",
    "validationStatus": "NOT_STARTED",
    "validationSubdomain": "mail",
    "dnsValidationRecords": [
        {"fqdn": "mail.example.com", "recordType": "TXT", "verificationValue": "okta-verify-xyz"}
    ],
})

# All assertions now pass:
assert resp.id == "OeD123"                           # ✅
assert resp.domain == "example.com"                  # ✅
assert resp.validation_status == "NOT_STARTED"       # ✅
assert resp.validation_subdomain == "mail"           # ✅
assert len(resp.dns_validation_records) == 1         # ✅
assert resp.display_name == "Test"                   # ✅
assert resp.user_name == "noreply"                   # ✅

📝 Files Changed

OpenAPI Specification

  • openapi/api.yaml - Fixed schema indentation for EmailDomain, EmailDomainResponse, and EmailDomainResponseWithEmbedded

Generated Models

  • okta/models/email_domain.py - Regenerated with all 5 fields
  • okta/models/email_domain_response.py - Regenerated with all 7 fields
  • okta/models/email_domain_response_with_embedded.py - Regenerated with proper _embedded type
  • okta/models/email_domain_response_with_embedded_all_of_embedded.py - New model for _embedded structure

Module Exports

  • okta/__init__.py - Added export for EmailDomainResponseWithEmbeddedAllOfEmbedded
  • okta/models/__init__.py - Added export for EmailDomainResponseWithEmbeddedAllOfEmbedded

Documentation

  • docs/EmailDomain.md - Updated field list
  • docs/EmailDomainResponse.md - Updated field list
  • docs/EmailDomainResponseWithEmbedded.md - Updated with proper _embedded type
  • docs/EmailDomainResponseWithEmbeddedAllOfEmbedded.md - New documentation for nested model

🎯 Impact

  • Breaking Change: No - This is a bug fix that adds missing functionality
  • Backward Compatible: Yes - Existing code continues to work, but now receives complete data
  • Affected Users: Anyone using create_email_domain(), replace_email_domain(), or verify_email_domain() methods

🔗 Related Issues

Fixes: OKTA-1133517

📋 Checklist

  • Root cause identified (incorrect YAML indentation in OpenAPI spec)
  • OpenAPI specification corrected
  • Models regenerated using OpenAPI generator
  • All 7 fields properly deserialized in EmailDomainResponse
  • All 5 fields properly deserialized in EmailDomain
  • Documentation updated
  • Verified fix with test cases
  • No breaking changes introduced

Fix OpenAPI spec indentation causing EmailDomainResponse, EmailDomainResponseWithEmbedded and EmailDomain
to drop 5-7 fields during deserialization. API responses now include all
fields: id, domain, validationStatus, dnsValidationRecords, etc.

Fixed incorrect YAML indentation in allOf composition that prevented
OpenAPI generator from processing properties beyond BaseEmailDomain.

Fixes: OKTA-1133517
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant