Mark ApiProperty as input only, or output only?

457 views
Skip to first unread message

Ben Lisbakken

unread,
Jun 14, 2013, 9:57:54 AM6/14/13
to swagger-sw...@googlegroups.com
Hello --

I've been searching through the source for a way to mark a property as input or output only.

For example, if there was a property in a model that can only be set by the system and any input for it will be ignored. It would be nice to have it show up in the documentation for any request that returns that model type, but not in the documentation for a request that is for creating that model. Is this something that is supported, or is there interest in supporting it?
@ApiProperty(value = "Password", inputOnly = true)
@ApiProperty(value = "Unsettable setting", outputOnly = true)

I saw that there is "access" within ApiProperty, as well as ApiParam. What is this used for?

Thanks,
Ben
Message has been deleted

Ben Lisbakken

unread,
Jun 14, 2013, 1:21:38 PM6/14/13
to swagger-sw...@googlegroups.com
Also, if this is not supported and is a reasonable request, I am happy to contribute.

tony tam

unread,
Jun 14, 2013, 1:30:54 PM6/14/13
to swagger-sw...@googlegroups.com
Wow, google groups seems really screwed up for me.  I did reply:

Supporting different modes for a single model type (i.e. input or output) won't work with swagger, since each model has just one-and-only-one definition.  We can, though add a readOnly property to the model property, which would be really valuable for id fields, etc.

Would that solve your needs?  It's a simple change now, since the 1.2 spec hasn't been released.  It will be very soon, and changing the structure will be really discouraged afterwards. 
Message has been deleted

Ben Lisbakken

unread,
Jun 14, 2013, 2:27:42 PM6/14/13
to swagger-sw...@googlegroups.com
Do you mean to the model property, or to an api property? A readOnly
property e.g. @ApiProperty(value = 'The id of this model' readOnly =
true) is specifically what we need. Also, I wonder if there is enough
of a use case for a writeOnly property as well, such as with a
password?

-Ben
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Swagger" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/swagger-swaggersocket/4FlMMOX2fUo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> swagger-swaggers...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Ben Lisbakken

unread,
Jun 14, 2013, 2:29:22 PM6/14/13
to swagger-sw...@googlegroups.com
I see a few "This message has been deleted" on the thread. Is google
groups auto-deleting your posts?
Message has been deleted

tony tam

unread,
Jun 14, 2013, 4:27:34 PM6/14/13
to swagger-sw...@googlegroups.com
ARG google groups just deleted my message again.  I am proposing that the (newly renamed) @ApiModelProperty annotation gets a "readOnly" property

Ben Lisbakken

unread,
Jun 14, 2013, 4:43:18 PM6/14/13
to swagger-sw...@googlegroups.com
That sounds good to me.
Reply all
Reply to author
Forward
0 new messages