-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is the expected behavior of default
in the Swagger specification?
#1607
Comments
Note that this is in some way philosophically related to my other question: #1583 |
My take on |
It's ok for the client to be smart, just not "smart" :D IMHO, I don't particularly like the current assumption/behavior, but we can't change that right now. AutoRest 1.0 has a number of implicit, not-well-documented assumptions that are not overridable; this will change drastically in AutoRest 2.0, where we will document every single assumption and provide the ability to change the assumption via configuration. |
added to #2448 |
When I read
default
in the Swagger spec, what I see is "optional, and if omitted the server will use the following value."It seems like what actually happens at least in some languages is that AutoRest uses the
default
in the signature (for languages which support that such as Python and C#) and we end up with a signature which looks like this:DoFoo(string required, string optional = null, string default = "Test")
This actually ends up always serializing the string "Test" to the server. Which means as far as the server is concerned, this value is now never omitted.
So I have a few questions about the expected behavior of
default
in the clients:default
in operations anddefault
in the body? I know that the body supportsdefault
but I can't seem to find any tests for it exceptComplex-Model
which only seems to be generated for Node.JS -- although from some investigation into the Python generator by @annatisch on my team it seems at least python treats the two consistently.required
anddefault
-- and is the behavior the same in the body and the operation parameters?Overall I think the win of including
default
probably outweighs the awkwardness of always serializing that value to the server (better method signatures, etc), but curious what others think or if anybody has an alternative option that is the best of both worlds.The text was updated successfully, but these errors were encountered: