Type 'ModelWithAdditionalProperties' does not conform to protocol 'Equatable'
Cy-4AH opened this issue · comments
Petstore spec generates
Type 'ModelWithAdditionalProperties' does not conform to protocol 'Equatable'
if generated with options modelType:struct modelInheritance:false
Happy to accept an easy PR for this
I just hit what I think is a related issue, where an OpenAPI spec that includes a bare object
field generates a model with [String: Any]?
that isn't Equatable
.
In our codebase we have an enum that looks like this:
enum JSONAny: Codable, Equatable {
case bool(_ value: Bool)
case int(_ value: Int)
case float(_ value: Double)
case string(_ value: String)
case array(_ value: [JSONAny])
case dict(_ value: [String: JSONAny])
case null
...
Generating with --option anyType:JSONAny
would fix it (and maybe ModelWithAdditionalProperties
too) if I could get JSONAny
in scope. Some possible ways of doing that:
- Make my own template and add JSONAny.swift (but I'd prefer to stick to the standard one!)
- Add JSONAny.swift to the standard template (happy to contribute this if there's interest)
- Have the generator include an extra file -- could this be added? e.g.
--option addFile:JSONAny.swift
? - Have the generator add an import statement -- could this be added? e.g.
--option addImport:JSONAny
?
@yonaskolb let me know if you like any of those options, and I can put together a PR.
@Cy-4AH --option anyType:Data
may be another workaround