OpenAPITools / OpenAPITools/openapi-generator
[REQ] [swift] Make typealias optional, as swiftUseApiNamespace isn't as useful otherwise
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
The value of swiftUseApiNamespace seems to be immediately revoked because each model has a typealias created which pulls the namespaced value into the module namespace.
I'm using internal, namespaced, read-only models - but at the top of each file I get this:
internal typealias Foobar = MyNamespace.Foobar
I discovered these because when I pulled these generated source files into a project, my project failed to compile due to one of the models clashing with a domain entity.
Describe the solution you'd like
I would like an option for making the typealias optional (enabled by default when using namespaces). Something like:
swiftUseTypealias- Flag for generating atypealiasin the module's namespace whenswiftUseApiNamespace=true, in order to lift the API class out of the {{projectName}}API inner-class.
Examples (swiftUseApiNamespace=true)
// swiftUseTypealias=true
@available(*, deprecated, renamed: "MyNamespace.Foobar")
internal typealias Foobar = MyNamespace.Foobar
extension MyNamespace {
internal struct Foobar: Codable {
...
// swiftUseTypealias=false
extension MyNamespace {
internal struct Foobar: Codable {
...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the Swift generator handling for swiftUseApiNamespace and the generated typealias shown in the issue. Trace how generator options reach the Swift templates, then identify the relevant generation tests; done means the typealias can be disabled while namespaced models still generate correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100