Problem
When quicktype generates code from multiple input sources, child types are emitted at the top level instead of being nested inside the corresponding root type.
For example, Swift output may look like:
public struct RspAPIV1AIToolTemplateToImageExecutionGet: Codable {
public let id: String
public let images: [Image]
public let status: String
}
public struct Image: Codable {
public let id: String
public let url: String
}
If another input source also produces a child type named Image, the generated declarations collide. This is especially problematic when combining independently generated API models from multiple sources.
Proposed feature
Add a --nest-types (or equivalent nest-type) option that nests generated child types inside their owning/root type when the target language supports nested types.
The example above would become conceptually:
public struct RspAPIV1AIToolTemplateToImageExecutionGet: Codable {
public let id: String
public let images: [Image]
public let status: String
public struct Image: Codable {
public let id: String
public let url: String
}
}
References should use the nested type as appropriate, e.g. [RspAPIV1AIToolTemplateToImageExecutionGet.Image] where required by the target language.
Scope
- Primarily needed for multi-source generation.
- Preserve current flat output as the default for backwards compatibility.
- Enable nesting only with the new option.
- For target languages without nested type support, document the behavior or report a clear unsupported-option error.
This would provide namespace isolation and prevent symbol collisions without requiring users to manually rename generated types.
Problem
When quicktype generates code from multiple input sources, child types are emitted at the top level instead of being nested inside the corresponding root type.
For example, Swift output may look like:
If another input source also produces a child type named
Image, the generated declarations collide. This is especially problematic when combining independently generated API models from multiple sources.Proposed feature
Add a
--nest-types(or equivalentnest-type) option that nests generated child types inside their owning/root type when the target language supports nested types.The example above would become conceptually:
References should use the nested type as appropriate, e.g.
[RspAPIV1AIToolTemplateToImageExecutionGet.Image]where required by the target language.Scope
This would provide namespace isolation and prevent symbol collisions without requiring users to manually rename generated types.