Given the following schema definition (which is a valid way to define required properties):
MySchema:
type: object
required: [property1, property2, property3]
properties:
property1:
type: integer
property2:
type: integer
property3:
type: integer
Is there a way to specify that all the properties are required?
Clarification: I'm looking for a way to say that all the properties are required, without specifying it one by one.
To be even more explicit: this does not answer my question.
If you are trying to send a body with multiple parameters, add an object model in the definitions section and refer it in your body parameter, see below (works with editor.swagger.io):
The properties keyword is used to define the object properties – you need to list the property names and specify a schema for each property.
You can use the default key to specify the default value for an optional parameter. The default value is the one that the server uses if the client does not supply the parameter value in the request. The value type must be the same as the parameter's data type.
That's the correct way to define model properties as required and I'm not aware of any other way to specify that all the properties are required.
For parameters, the required
attribute is a boolean (true/false) instead of a list of required parameter's name. e.g.
name: avatar
in: formData
description: The avatar of the user
required: true
type: file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With