NSwag: property 'required' of response header in OAS 3 yaml files returns error on code generation

We have a OAS 3 yaml file with the following response header:

X_Pagination_Page:
  required: true
  schema:
    type: integer
    description: Current page.
    example: 3

I download the latest NSwag studio for windows and when I try to generate client code, I get the following error:

Error converting value “true” to type ‘System.Collections.Generic.ICollection`1[System.String]’

The same happens when I change ‘true’ into ‘false’

Is this property not supported in the current version?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Why is this closed? Is there another bug open? Is there a disagreement over the open API spec?

https://github.com/RicoSuter/NSwag/issues/2576#issuecomment-613146417

This comment would indicate the issue needs re-opening.

EDIT: The example for parameters in the link below, documents the required value as a boolean, not as a collection: https://swagger.io/docs/specification/describing-parameters/

    paths:
      /users/{userId}:
        get:
          summary: Get a user by ID
          parameters:
            - in: path
              name: userId
              schema:
                type: integer
              required: true
              description: Numeric ID of the user to get

The swagger output I have appears to have the same format (with some $refs) and is giving me this error.

@RicoSuter

The components object examples has a required:true https://swagger.io/specification/#componentsObject The header object https://swagger.io/specification/#header-object follows structure of a Parameter object https://swagger.io/specification/#parameter-object which has a “required” boolean. Also says here that it is a boolean: https://swagger.io/docs/specification/describing-parameters/#header-parameters

This “Simple Model” structure from the picture doesn’t seem to apply to headers I suppose? Or maybe this has changed recently?