Is it mandatory to add "required" field in parameter in swagger json to display input field on dev portal?

In my swagger json if I specify:

"required":"true" or "false" and some "default" value then only input field is displayed on dev-portal.

0 5 11.7K
5 REPLIES 5

Not applicable

Hi @Sonali

For path parameters ( in: path ) it is set mandatory and it is true. As per Open API spec as below,

requiredbooleanDetermines 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.

In the case of setting default value to a parameter, required must be false.

@seshi Thanks. I have header parameter. "in":"header" and if I did not use 'required' property and give some default value input field is not showing.

yes..you are absolutely right. When the default is set we must set required to false.

@seshi, If I give my parameter details as:

{
					"name": "header1",
					"in": "header",
					"description": "description",
					"type": "string"
				}

Then it displayed on dev portal as:

1787-headers.jpg

No input field for header1 value. To display input field I need to use following:
{
					"name": "header1",
					"in": "header",
					"required":false,
					"default": "default value",
					"description": "description",
					"type": "string"
				}
So is it the expected behavior of dev-portal? I am using free instance of dev-portal.

Hi @Sonali

yes..the below mentioned is expected when default is used, required must be set to false.

"default": "default value",