apple / apple/swift-openapi-generator

Deprecated variables used in generated inits, could the init be marked deprecated as well?

Open
#932 1 comment 0 reactions 0 assignees View on GitHub
area/generator kind/bug
Dominant language
Swift
Stars
2k
Forks
182
Avg merge
13h 28m
Merged PRs (30d)
5

Description

### Question

When a struct includes a deprecated variable, the generated variable correctly gets a `@available(*, deprecated)` notation. However, the struct also gets an autogenerated init which **uses** this deprecated variable, and is not itself marked as deprecated, thus generating a workspace-wide warning message.

Image

I was initially hoping you could just autogenerate a pragma silence to the specific line in the init that uses the deprecated value, but I now realize it's not possible to do so in Swift.
However - if the entire init is marked as deprecated, it would silence the use within.

Image

I don't know, maybe this just moves the problem elsewhere, or maybe it's better with one deprecated init (including all deprecated variables) and one non-deprecated init that just omits the deprecated variabels and just don't set them (as long as they are optional, I think they should implicitly resolve to nil without warnings?)

I'm not sure what's best, I'm just sad about the warnings we're getting.

Contributor guide

Open the contributing guide

Research direction

Reproduce the warning with a struct containing a deprecated variable and an autogenerated initializer, then trace the generated initializer path. Compare the available handling options described in the issue; done means generated code no longer produces the reported workspace-wide deprecation warning without introducing a replacement warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.