It could be, but it depends on the scenario.

 

The producer/consumer isn’t necessarily the server/client.

When an API call is executed by the client to the server – the server is the 
consumer of the request. When the server returns a response, the client is the 
consumer of the response.

Basically, what it means, is that it’s up to the side that receives the data to 
assume a default value if one is not being sent in the data.

 

 

 

From: <[email protected]> on behalf of hasa 
<[email protected]>
Reply-To: "[email protected]" 
<[email protected]>
Date: Tuesday, December 5, 2017 at 18:28
To: Swagger <[email protected]>
Subject: Default value used in swagger query parameters

 

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 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 typefor 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 [email protected].
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to