Optional type for parameters

32 views
Skip to first unread message

Burak Emre Kabakcı

unread,
Jul 1, 2015, 10:56:13 PM7/1/15
to swagger-sw...@googlegroups.com
I have a parameter that doesn't have a type. (Consider an endpoint that takes an arbitrary key (string) and value (any type) parameters and store them in a database.) It seems "parameter" object requires "type" field name and the value of "type" field must be one of "string", "number", "integer", "boolean", "array" or "file". Is there an "any" type or workaround for this use case?

Josh Ponelat

unread,
Jul 2, 2015, 1:28:56 AM7/2/15
to swagger-sw...@googlegroups.com
Does the type 'string' not work for you?
The only cases I can see where string wouldn't work is if you wanted to send an array or file, but if you're storing that in a database... a string might be best



On 2 July 2015 at 04:56, Burak Emre Kabakcı <emrek...@gmail.com> wrote:
I have a parameter that doesn't have a type. (Consider an endpoint that takes an arbitrary key (string) and value (any type) parameters and store them in a database.) It seems "parameter" object requires "type" field name and the value of "type" field must be one of "string", "number", "integer", "boolean", "array" or "file". Is there an "any" type or workaround for this use case?

--
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.

Burak Emre Kabakcı

unread,
Jul 2, 2015, 11:07:01 AM7/2/15
to swagger-sw...@googlegroups.com
All the existing types except file is valid values for that parameter. Why do you think 'string' would work for me? The API documentation will display the type as 'string', which is confusing, swagger-ui and swagger-codegen (I assume) will cast all values of that parameter to 'string'.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.

Josh Ponelat

unread,
Jul 2, 2015, 11:25:35 AM7/2/15
to swagger-sw...@googlegroups.com
You're right, and casting is a very implementation-specific affair. The spec is for all implementations and as far as I can see, doesn't have a generic 'type'.


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.

--
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.

Josh Ponelat

unread,
Jul 2, 2015, 11:29:05 AM7/2/15
to swagger-sw...@googlegroups.com
You're welcome to suggest this feature to the next specification, if it's something that's important to you...
https://github.com/swagger-api/swagger-spec/

Burak Emre

unread,
Jul 2, 2015, 11:48:39 AM7/2/15
to swagger-sw...@googlegroups.com

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/jJSo2YbOe1U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to swagger-swaggers...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages