Skip to content

[Minor][Engg]: Add Swift Lab API models: enums and LabTestApplication#1796

Draft
josephpab wants to merge 2 commits into
devfrom
josephpab/labapi-swift-pr1
Draft

[Minor][Engg]: Add Swift Lab API models: enums and LabTestApplication#1796
josephpab wants to merge 2 commits into
devfrom
josephpab/labapi-swift-pr1

Conversation

@josephpab

Copy link
Copy Markdown
Contributor

Part 1 of incremental Lab API Swift migration. Adds new Swift types alongside existing ObjC lab_api code (no behavior change).

  • LabAPIEnums.swift: 12 Swift enums replacing ObjC string constants (AccountType, MFAType, ProtectionPolicy, B2CProvider, etc.)
  • LabTestApplication.swift: Codable struct replacing MSIDTestAutomationApplication with type-safe decoding

These files compile in IdentityAutomationTestLib but are not yet referenced by any consumers. Old ObjC code continues to run.

PR Checklist (must be completed before review)

  • All tests pass locally
  • PR size is <= 500 LOC per PR Size Check policy
  • PR is independently mergeable (no hidden dependencies)
  • Appropriate reviewers are assigned
  • PR reviewed by code owner (required if Copilot-generated)
  • SME or Senior IC assigned where required

PR Title Format

Required Format: [Keyword1] [Keyword2]: Description

  • Keyword1: major, minor, or patch (case-insensitive)
  • Keyword2: feature, bugfix, engg, or tests (case-insensitive)

Examples:

  • [MAJOR] [Feature]: new API
  • [minor] [bugfix]: fix crash
  • [PATCH][tests]:add coverage

Proposed changes

Describe what this PR is trying to do.

Type of change

  • Feature work
  • Bug fix
  • Documentation
  • Engineering change
  • Test
  • Logging/Telemetry

Risk

  • High – Errors could cause MAJOR regression of many scenarios. (Example: new large features or high level infrastructure changes)
  • Medium – Errors could cause regression of 1 or more scenarios. (Example: somewhat complex bug fixes, small new features)
  • Small – No issues are expected. (Example: Very small bug fixes, string changes, or configuration settings changes)

Additional information

Part 1 of incremental Lab API Swift migration. Adds new Swift types
alongside existing ObjC lab_api code (no behavior change).

- LabAPIEnums.swift: 12 Swift enums replacing ObjC string constants
  (AccountType, MFAType, ProtectionPolicy, B2CProvider, etc.)
- LabTestApplication.swift: Codable struct replacing
  MSIDTestAutomationApplication with type-safe decoding

These files compile in IdentityAutomationTestLib but are not yet
referenced by any consumers. Old ObjC code continues to run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@josephpab josephpab changed the title Add Swift Lab API models: enums and LabTestApplication [Minor][Engg]: Add Swift Lab API models: enums and LabTestApplication Apr 23, 2026
Comment thread IdentityCore/IdentityCore.xcodeproj/project.pbxproj
@josephpab

Copy link
Copy Markdown
Contributor Author

@copilot review this PR

Copilot AI commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

@copilot review this PR

Reviewed. The enums in LabAPIEnums.swift are correct and match the ObjC constants exactly. I found and fixed several issues in LabTestApplication.swift (commit a78f6db):

Bugs fixed:

  1. Abbreviated license headers — Both new files used a 4-line shorthand; updated to the full MIT license text matching every other file in the repo.

  2. multiTenantApp decoding — The original code tried to decode this as Bool, but the Lab API returns "Yes"/"No" strings (matching ObjC: isEqualToString:@"Yes"). Fixed with caseInsensitiveCompare("yes").

  3. JSON key mismatches — The CodingKeys used Swift property names instead of the actual API field names:

    • redirectUri (singular, from ObjC @"redirectUri") → was incorrectly mapped to "redirectUris"
    • authority (from ObjC @"authority") → was incorrectly mapped to "defaultAuthorities"
  4. defaultScopes/defaultAuthorities type — The ObjC model parses these from comma-separated strings (via msidOrderedSetFromCommaSeparatedString:), not native JSON arrays. Updated Swift decoding to split by comma consistently.

Note for future PRs: The ObjC b2cAuthorities is a NSDictionary (policy name → authority URL), while the Swift struct models it as [String]. This will need to be reconciled in a later PR when consumers migrate. Also, b2cAuthorityForPolicy(_:tenantId:) has no Swift equivalent yet.

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.

2 participants