apple / apple/swift-openapi-generator
Questions re: anyOf/allOf/oneOf, and one more thing
- Dominant language
- Swift
- Stars
- 2k
- Forks
- 182
- Avg merge
- 13h 28m
- Merged PRs (30d)
- 5
Description
### Question
I'm sure there are details I'm unaware of that impact these things, so forgive me if this has been discussed before. I have a few questions/thoughts regarding `anyOf`/`allOf`/`oneOf`:
- Could `oneOf` be translated to an enum with associated values of the possible options?
- For `anyOf`/`oneOf` where the only options are `"null"` and some `$ref`, could it be translated to an optional instance of that type? Because as of now, it's this:
```swift
struct itemPayload: Codable, Hashable, Sendable {
var value1: OpenAPIRuntime.OpenAPIValueContainer?
var value2: Components.Schemas.NamedAPIResource?
}
```
from this:
```json
"item": {
"anyOf": [
{
"type": "null"
},
{
"$ref": "./NamedAPIResource.json"
}
]
}
```
when it would ideally just be:
```swift
typealias itemPayload: Components.Schemas.NamedAPIResource?
```
Separately, is it possible to set the configuration so the generated types from `components/schemas` are `public`, but the initializers and underlying stuff is `internal`? Or would I just have to do 2 separate targets that generate the types and clients separately, then I combine them for public-facing stuff in a 3rd target?
Contributor guide
Research direction
No file, test, or entry point is named. Start by tracing how the generator maps anyOf/allOf/oneOf and how access control is configured for generated component schemas; done would mean a maintainer decision on optional/reference and enum representations plus public schema and internal initializer support, or documented constraints.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, swift
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100