Open Holek opened 3 years ago
Hi @Holek. You should be able to use --option modelInheritance:false
Interesting, that will work, indeed! So now the question I would have is whether modelType:struct
should imply modelInheritance:false
?
Yes it probably should, but currently they are unlinked
First, I want to preface that I am not a Swift developer, but I've noticed an odd behaviour in model template generation.
Using
--option "modelType:struct"
the generator creates models as structs, but allows them to inherit from each other. As far as I understand, a struct cannot inherit from another kind of struct.Example
Here's an example
struct-issue.yaml
that recreates this:I've recreated this problem by running:
In the generated files you can see
struct-issue/Sources/Models/AdminUser.swift
which looks like a compilation error to me.
Possible workarounds for now
This is a list of possible workarounds for people who might also encounter this issue.
$ref
s in openapi to generate structsPossible fix
A possible fix would be to read any references in models that occur and hard-code schemas that are inherited in structs. I don't know how hard would such fix look like, but I believe you would have some ideas for that.
Thanks otherwise for a very helpful tool!