apple / apple/swift-openapi-generator

Consider adding typealiases for Operations.*.Input.* types for referenced types

Open
#32 1 comment 0 reactions 0 assignees View on GitHub
area/generator kind/usability 🆕 semver/minor status/needs-design
Dominant language
Swift
Stars
2k
Forks
182
Avg merge
13h 28m
Merged PRs (30d)
5

Description

When all types are inline, you get consistent names for all operations:

* `Operations..Input.Path`
* `Operations..Input.Query`
* `Operations..Input.Headers`
* `Operations..Input.Cookies`
* `Operations..Input.Body`

And similar for `Operations..Output`.

When using reusable types for `requestBody`, `parameter`, and `response`, however, these can point directly to e.g. `Components.RequestBodies.Foo`, etc, which breaks the symmetry.

Consider emitting a typealias here that would make all the names predictable, e.g.

```swift
enum Operations {
enum {
struct Input {
typealias Body = Components.RequestBodies.Foo
}
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start by locating the generator paths that emit Operations..Input and Output types for inline and reusable requestBody, parameter, and response types. Compare their naming behavior and identify the relevant generation tests; done when reusable references also expose predictable typealiases without changing the referenced types.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, swift
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.