-
Notifications
You must be signed in to change notification settings - Fork 147
Open
Labels
area/generatorAffects: plugin, CLI, config file.Affects: plugin, CLI, config file.area/runtimeAffects: the runtime library.Affects: the runtime library.kind/enhancementImprovements to existing feature.Improvements to existing feature.
Description
When using a schema that has a field from a reference that is both non-required and "nullable" this is a common way of defining it in OpenAPI: 3.1.0
UpdateTaskOccurrenceCompletionResponse:
properties:
old_task:
$ref: '#/components/schemas/TaskOccurenceDTO'
next_task:
oneOf:
- $ref: '#/components/schemas/TaskOccurenceDTO'
- type: 'null'
type: object
required:
- old_taskbut this currently generates the following API:
/// - Remark: Generated from `#/components/schemas/UpdateTaskOccurrenceCompletionResponse`.
public struct UpdateTaskOccurrenceCompletionResponse: Codable, Hashable, Sendable {
/// - Remark: Generated from `#/components/schemas/UpdateTaskOccurrenceCompletionResponse/old_task`.
public var old_task: Components.Schemas.TaskOccurenceDTO
/// - Remark: Generated from `#/components/schemas/UpdateTaskOccurrenceCompletionResponse/next_task`.
@frozen public enum next_taskPayload: Codable, Hashable, Sendable {
/// - Remark: Generated from `#/components/schemas/UpdateTaskOccurrenceCompletionResponse/next_task/case1`.
case TaskOccurenceDTO(Components.Schemas.TaskOccurenceDTO)
/// - Remark: Generated from `#/components/schemas/UpdateTaskOccurrenceCompletionResponse/next_task/case2`.
case case2(OpenAPIRuntime.OpenAPIValueContainer)
}
/// - Remark: Generated from `#/components/schemas/UpdateTaskOccurrenceCompletionResponse/next_task`.
public var next_task: Components.Schemas.UpdateTaskOccurrenceCompletionResponse.next_taskPayload
This is quite confusing syntax at the callsite, since we have this weird case2, instead of just having only an optional TaskOccurenceDTO. Is this expected behaviour or could we do something to improve the ergonomics before the 1.0.0 release? I'll happily work on a PR, if you could point me in the right direction to where in the codebase the relevant parts are!
yousifalraheem
Metadata
Metadata
Assignees
Labels
area/generatorAffects: plugin, CLI, config file.Affects: plugin, CLI, config file.area/runtimeAffects: the runtime library.Affects: the runtime library.kind/enhancementImprovements to existing feature.Improvements to existing feature.