Swagger Import Will Now Assume Parameter is Optional by Default

Release DateFeb 2, 2017
Change Type
Platforms Affected

    When defining the Parameter Object in Swagger v1.2 or v2.0, they asssume default value for required property as false. We were previously keeping the default value for it to be true but now we conform strictly to the Swagger specification.

    Details

    The Parameter Object in Swagger (both v1.2 and v2.0) consists of a boolean flag called required which helps indicate whether the parameter is optional or not. If this property is not explicitly declared then by default, Swagger assumes it to have the value set to false.

    Here is what Swagger 1.2 specification says about the required flag of a Parameter Object:

    A flag to note whether this parameter is required. If this field is not included, it is equivalent to adding this field with the value false. If paramType is “path” then this field MUST be included and have the value true.

    See more at Swagger 1.2 Parameter Object

    Here is what Swagger 2.0 specification says about the required flag of a Parameter Object:

    Determines whether this parameter is mandatory. If the parameter is in “path”, this property is required and its value MUST be true. Otherwise, the property MAY be included and its default value is false.

    See more at Swagger 2.0 Parameter Object

    When converting to Swagger (v1.2 or v2.0), the Parameter will have the required property as true strictly in case the parameter exists in the path (i.e. it is a template parameter). This is also in accordance with the Swagger specification as mentioned above.

    Related Links


    Have questions? Submit a request.