apple / swift-openapi-generator

Generate Swift client and server code from an OpenAPI document.
https://swiftpackageindex.com/apple/swift-openapi-generator/documentation
Apache License 2.0
1.45k stars 121 forks source link

Warnings due to `@frozen` attribute on non-public enums with Xcode 16 Beta 3 #586

Closed ojun9 closed 4 months ago

ojun9 commented 4 months ago

Description

Using Xcode 16 Beta 3, the generated Type.swift file now shows multiple warnings due to the @frozen attribute being applied to non-public enums. The Type.swift file is generated with non-public enums that include the @frozen attribute. For example:

@frozen internal enum Output: Sendable, Hashable { /* ... */ }

This results in the following warning:

@frozen has no effect on non-public enums

Reproduction

To reproduce the issue, it is necessary to generate the Type.swift file.

openapi-generator-config.yaml

generate:
  - types
  - client

Package version(s)

1.2.1

Expected behavior

The @frozen attribute should not be applied to non-public enums to avoid unnecessary warnings.

Environment

Additional information

This issue arises from a new warning introduced in Xcode 16 Beta 3.

czechboy0 commented 4 months ago

Thanks for reporting this, @ojun9! I think the fix here is what you suggested - only generate the frozen attribute when the access modifier is public or package. Would you consider opening a PR for that?

ojun9 commented 4 months ago

Thank you for the feedback! I’ll work on the fix over the weekend and open a PR to ensure the frozen attribute is only generated when the access modifier is public or package.

czechboy0 commented 4 months ago

Looks like #587 is already fixing this issue

ojun9 commented 4 months ago

@czechboy0

Since there were no changes in the PR https://github.com/apple/swift-openapi-generator/pull/587, I created a new PR https://github.com/apple/swift-openapi-generator/pull/595. Please let me know if there are any issues!

czechboy0 commented 4 months ago

Fixed and released in 1.3.0: https://github.com/apple/swift-openapi-generator/releases/tag/1.3.0