Closed leedsalex closed 1 year ago
I realize this is a new change mentioned in the README:
v2.7 takes default values into account - either those specified in Scala contructors or via swagger annotations. A field might be marked as not required if a default value is specified.
I can see how this would be beneficial to some people, however, scala JSON libraries such as spray-json
do not interpret default values in a similar fashion.
Can't you just use v2.6? It's impossible to keep everyone happy.
If you want to do a PR, there is a possibility to add a new setting like https://github.com/swagger-akka-http/swagger-scala-module/blob/develop/src/main/scala/com/github/swagger/scala/converter/SwaggerScalaModelConverter.scala#L41
The existing main branch behaviour would remain the default but a configuration could make it behave differently.
I will happily do a PR to add this behavior as a setting, thanks!
In the current state, a non-annotated model with a default value, such as:
will resolve to the following schema:
However, most code generators will interpret this schema as:
In other languages, where
Option
types don't exist, this property would be a pointer or something similar.I propose that we change the ability to use the
default value
as a determining factor for optionality (i.e marking a property required) a configurable option.