Not possible to set a default value using ApiModelProperty

1,954 views
Skip to first unread message

Yuri Matrosovs

unread,
Aug 4, 2017, 11:39:13 AM8/4/17
to Swagger, Lukasz Kwasek
Hi,

In our project we use Swagger via SpringFox. And in our API description we want to provide a default value for some fields in a Model Property.

But, unfortunately there is no standard way of doing it, i.e. by using ApiModelProperty annotation, like:

   @ApiModelProperty (
            name
= "Name",
            required
= true,
            defaultValue
= "John Doe" // <--- this is not available in ApiModelProperty interface
   
)

And according to the Swagger specification, properties should be able to have "default" values. See: https://swagger.io/specification/#properties-99

Are you ok if we fork your project, add the field in to the annotation and push it back? Or is there any other way of providing a default value for the property?

Regards,
Yuri

Ron Ratovsky

unread,
Aug 4, 2017, 1:08:07 PM8/4/17
to swagger-sw...@googlegroups.com, Lukasz Kwasek

Hi Yuri,

 

We’re not the ones maintaining SpringFox. Would suggest filing a ticket on the project directly.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yuri Matrosovs

unread,
Aug 4, 2017, 1:27:09 PM8/4/17
to Swagger, luk...@billforward.net
Hi Ron,

Thanks for your quick reply.

The annotation I am referring to is actually part of swagger-core's swagger-annotation module, not spring-fox. You can find it here.

Regards,
Yuri

To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

PJ Fanning

unread,
Aug 6, 2017, 5:51:23 AM8/6/17
to Swagger, luk...@billforward.net
Reply all
Reply to author
Forward
0 new messages