Forum Discussion

HenrikHL's avatar
HenrikHL
Frequent Contributor
2 months ago

It does not seem like setting a header in a response as required makes any difference

I would expect a little red `*` to appear next to the header-name when I specify the header as a required-header.

Here is an example

As can be seen - no required "red star" next to the `API Version` header.

Is this a bug or just not possible? (According to the schema of a header it should be possible)

6 Replies

  • Thank you Tom_S 

    In our case we are a standardization organization - so both sides need to comply (supplier and consumer). We don't implement any of our APIs...

    • Tom_S's avatar
      Tom_S
      Icon for Staff rankStaff

      Understood. We will consider your example for discussion about further improvements to the editor and the visual representation of responses. 

      We appreciate you bringing this to our attention, as it helps us better understand the needs of users using our product! 

  • After consulting with our product team, we found that this use case may not have been considered in the past. We're aware that SwaggerUI might also act as a documentation tool for server developers. 

    This seems like a good idea for a feature request. Thank you for bringing this to our attention. 

  • HenrikHL's avatar
    HenrikHL
    Frequent Contributor

    Hi Tom_S ,

    Thank you for the prompt reply :-)

    When you write:

    However, for headers, even though they can be defined as required (required: true), Swagger UI does not display a red asterisk or similar indicator for them. This is by design and not an issue with the tool. The required header will still be enforced during validation.

    I assume you mean required fields on headers in responses - because it works fine for headers in requests:

     

    • Tom_S's avatar
      Tom_S
      Icon for Staff rankStaff

      Hi Henrik, yes, you're correct. The red asterix is displayed for headers in requests, as this field is required by the user of the API to fill in when sending a request. 

  • Hello HenrikHL, 

    Required fields are visually marked with a red asterisk (*) in the Query Parameters section to ensure users provide necessary inputs during requests.

    However, for headers, even though they can be defined as required (required: true), Swagger UI does not display a red asterisk or similar indicator for them. This is by design and not an issue with the tool. The required header will still be enforced during validation.