Swagger require all properties
Asked Answered
B

2

23

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.

Boomer answered 8/9, 2016 at 10:30 Comment(0)
C
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
Compressor answered 9/9, 2016 at 3:26 Comment(0)
R
0

Set additionalProperties: false in your schema

Risible answered 2/3, 2023 at 1:25 Comment(1)
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.Apanage

© 2022 - 2024 — McMap. All rights reserved.