Skip to content

[BUG][SWIFT6] unalias additionalProperties before building map type declaration#23668

Open
winrid wants to merge 1 commit intoOpenAPITools:masterfrom
winrid:pr/swift6-map-alias
Open

[BUG][SWIFT6] unalias additionalProperties before building map type declaration#23668
winrid wants to merge 1 commit intoOpenAPITools:masterfrom
winrid:pr/swift6-map-alias

Conversation

@winrid
Copy link
Copy Markdown
Contributor

@winrid winrid commented Apr 30, 2026

Closes #23666.

A nested map property whose additionalProperties is a $ref to an aliased map schema produced [String: Dictionary] (no generic args, doesn't compile in Swift 6) instead of the resolved [String: [String: String]].

StringMap:
  type: object
  additionalProperties: { type: string }
EmailTemplate:
  properties:
    translationOverridesByLocale:
      type: object
      additionalProperties:
        $ref: '#/components/schemas/StringMap'

Fix

Wrap ModelUtils.getAdditionalProperties(p) with unaliasSchema(...) in Swift6ClientCodegen.getTypeDeclaration so the alias resolves to the actual schema before recursion.

Test

New nestedMapRefTypeTest in Swift6ClientCodegenModelTest against swift6_nested_map.yaml asserts the resolved type. Full swift6 suite (39 tests) passes.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package
    
  • File the PR against the correct branch: master (5.x.x) (patches will be cascaded from master to other branches by the maintainers)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

cc @4brunu @yutailang0119

…eclaration

A nested map property whose additionalProperties is a $ref to an aliased
map schema (e.g. StringMap = type: object, additionalProperties: { type:
string }) resolved to `[String: Dictionary]` (no generic args, doesn't
compile in Swift 6) instead of `[String: [String: String]]`.

Wrap ModelUtils.getAdditionalProperties(p) with unaliasSchema(...) in
getTypeDeclaration so the alias resolves to the actual schema before
recursion.

Closes OpenAPITools#23666
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

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.

[BUG] [Swift6] Map type with $ref'd additionalProperties resolves to [String: Dictionary]

1 participant