You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It would be useful to add Default to the list of derived traits here. This would make it simpler to create defaults for types. This would allow a consumer to create defaults of structs like
let default_pet = Pet::default();
This is really helpful when mocking things out, writing tests, etc, where you just need a valid instance to fulfill some list of arguments.
Describe the solution you'd like
Add Default to the list of derived attributes on generated struct models. I am assuming this is possible because all structs are serializable to and from JSON so they must eventually resolve to the set of primitive types that have defaults defined in the Rust standard library.
Describe alternatives you've considered
The alternative is to implement the Default trait per type which adds a lot of boiler plate. For example,
I wasn't sure if Default can be derived for everything so I'm using some templates where Default is implemented when there are no variables needed.
In case anybody is interested, have a look here: https://github.com/horacimacias/openapi-generator-rust
@horacimacias Your template is pretty amazing. It fixed our client generation to a large extent. I added a PR for more fixes, in case you are interested.
Is your feature request related to a problem? Please describe.
It would be useful to add
Default
to the list of derived traits here. This would make it simpler to create defaults for types. This would allow a consumer to create defaults of structs likeThis is really helpful when mocking things out, writing tests, etc, where you just need a valid instance to fulfill some list of arguments.
Describe the solution you'd like
Add
Default
to the list of derived attributes on generatedstruct
models. I am assuming this is possible because all structs are serializable to and from JSON so they must eventually resolve to the set of primitive types that have defaults defined in the Rust standard library.Describe alternatives you've considered
The alternative is to implement the
Default
trait per type which adds a lot of boiler plate. For example,The text was updated successfully, but these errors were encountered: