Swaggeratr icon indicating copy to clipboard operation
Swaggeratr copied to clipboard

Selectively show nullable DataMembers as optional

Open makotogitdev opened this issue 10 years ago • 3 comments

By default Swaggeratr show nullable DataMembers as optional. This is kind of strange particularly in a read response contract.

makotogitdev avatar Jun 25 '14 20:06 makotogitdev

What would a mandatory nullable parameter look like? Not that I'm opposed to an option to override that default, I'm just having trouble picturing the use case.

superstator avatar Jun 25 '14 20:06 superstator

I was just thinking it would be nice to be able to remove the "optional" text in data type description of a parameter within a contract. But I guess "optional" text can just imply that it is possible that the parameter can be null for read responses.

makotogitdev avatar Jun 25 '14 20:06 makotogitdev

Yeah, I think given we're talking about JSON/XML datacontracts, "optional" should be read as "nullable" most of the time. Especially given part of the value with Swagger is the ability to generate code from those contracts. Imagine generating code according to a Swagger spec, expecting that a given value in a response is required and will always be present - if it's actually nullable, eventually a JSON response may leave it out, and that code might fail.

superstator avatar Jun 25 '14 21:06 superstator