Forum Discussion

kannanr's avatar
kannanr
New Member
4 years ago

Could not make "api-version" Header parameter mandatory in Swagger v 6.1.4

The below "api-version" is populated as HttpParameter when configuring any API with versioning and it is working fine in both swaggerUI and postman. 

If user doesn't enter the "api-version" and click on "Execute" then the below error message will be displayed in both SwaggerUI and postman. But our org wants  that field as mandatory(ie *  required as shown in the below screenshot), so any user should enter "api-version" before clicking on "Execute" button in SwaggerUI.

 

So, making the same parameter mandatory as other parameters by using below "SwaggerRequestHeaderParam" code, 

[SwaggerRequestHeaderParam("ClientAppId", "Client app ID.", true)]
[SwaggerRequestHeaderParam("api-version", "Api version.", true)]

 

The SwaggerUI will populate the both fields as mentioned below. So far SwaggerUI and code are fine.

 

But SwaggerUI is unresponsive even after entering valid "api-version" number as shown below screenshot and other fields are working fine.

 

Is there any one faced this issue? I have written our own custom filter as well but still facing same behavior. We really appreciate your response. Thanks in advance.

 

 

  • Hi kannanr 

    Is it possible to share the swagger.json (or openapi.json) ) file that generated that? Even if it's just the part for the parameter. It would help to be able to reproduce it in editor.swagger.io to see if it's a bug or something unusual with the specification.