question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
connelhooleycommented, Oct 24, 2022

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.

1reaction
ncjvdcommented, May 27, 2021

@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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

open api error: request should have required property '. ...
I have no property '.headers' mentioned in the open-api.yaml file. I tried removing the validator middleware, and the request went through just ...
Read more >
Describing Responses
OAS 3 This guide is for OpenAPI 3.0. ... A response is defined by its HTTP status code and the data returned in...
Read more >
OpenAPI Specification v3.1.0 | Introduction, Definitions, & ...
The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.
Read more >
Common Mistakes Developers Make In Their OpenAPI 3 ...
Declaring response headers as a list of Header objects. It looks like some developers are trying to generate their OAS 3 files from...
Read more >
Generate Server Code Using OpenAPI Generator
OpenAPI Generator can generate code based on an OpenAPI yaml ... When the ID does not exist, a NOT FOUND response will be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found