Given that we tend to generate clients from Swagger, we've been looking to 
have a default value used for these scenarios. For example, we support many 
api versions, but we want to embed in the swagger which version the 
*clients* should be sending to the *server*. We never want the server to 
have a default value.
More like a default value that the client should assume if the user doesn't 
input anything.

In swagger 2.0, the language around this was very clear:
>From the following 
doc: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md

If in 
<https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterIn>
 is 
any value other than "body":

default * Declares the value of the parameter that the *server* will use if 
none is provided, for example a "count" to control the number of results 
per page might default to 100 if not supplied by the client in the request. 
(Note: "default" has no meaning for required parameters.) See 
https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-6.2. 
Unlike JSON Schema this value MUST conform to the defined type 
<https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameterType>for
 
this parameter.

 In swagger v3, it's a bit less clear.:
>From the following doc (under Fixed 
Fields): https://swagger.io/specification/#schemaObject

   - default - The default value represents what would be assumed by the 
*consumer 
   of the input* as the value of the schema if one is not provided. Unlike 
   JSON Schema, the value MUST conform to the defined type for the Schema 
   Object defined at the same level. For example, if type is string, then 
   default can be "foo" but cannot be 1.

In this case, who is the consumer of the input? Could it be the client that 
is generated from the swagger?

Thanks in advance.

-- 
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-swaggersocket+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to