22

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.

JeB
  • 11,653
  • 10
  • 58
  • 87

2 Answers2

4

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
William Cheng
  • 10,137
  • 5
  • 54
  • 79
0

Set additionalProperties: false in your schema

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 09 '23 at 01:04