Skip to content

Remove per-type imports in generated files - #981

Merged
czechboy0 merged 1 commit into
apple:mainfrom
JonathanDowning:jdowning/scoped-imports
Nov 5, 2026
Merged

czechboy0 merged 1 commit into
apple:mainfrom
JonathanDowning:jdowning/scoped-imports

Conversation

@JonathanDowning

Copy link
Copy Markdown
Contributor

Motivation

The generator emits scoped Foundation imports (import struct Foundation.URL, .Data, .Date). The compiler warns about these whenever it emits a module interface (scoped imports are not yet supported in module interfaces). The scoping was only there to track @preconcurrency sendability (#114), @preconcurrency was removed in #969.

Modifications

  • Import Foundation as a whole module instead of per type.
  • Remove the now-unused moduleTypes from ImportDescription and the renderer, along with its test.
  • Update the Petstore reference sources and the file-splitting test.

Result

Generated code has a single import Foundation (with the configured access modifier, e.g. package import Foundation) and no longer triggers the warning.

Test Plan

  • Reproduced the warning with swiftc -enable-library-evolution -emit-module-interface-path on scoped public, package and plain imports. A whole-module package import Foundation compiles cleanly.
  • Updated the reference sources and tests.
  • swift test: All suites pass (0 failures)

…ot yet supported in module interfaces" warning
@czechboy0

Copy link
Copy Markdown
Contributor

A net-negative LOC PR, I love it. Thanks, @JonathanDowning 🙏

@czechboy0 czechboy0 added the 🔨 semver/patch No public API change. label Nov 4, 2026
@czechboy0
czechboy0 enabled auto-merge (squash) November 4, 2026 20:19
@czechboy0 czechboy0 changed the title Output of swift-openapi-generator compiles with "Scoped imports are not yet supported in module interfaces" warning Remove granular per-type imports in generated files Nov 4, 2026
@czechboy0 czechboy0 changed the title Remove granular per-type imports in generated files Remove per-type imports in generated files Nov 4, 2026
@czechboy0 czechboy0 self-assigned this Nov 4, 2026
@czechboy0
czechboy0 merged commit fbf4512 into apple:main Nov 5, 2026
93 of 98 checks passed
@JonathanDowning
JonathanDowning deleted the jdowning/scoped-imports branch November 5, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants