RicoSuter/NSwag

required field on response header spec not parsed correctly

Open

#2.928 geöffnet am 29. Juni 2020

Auf GitHub ansehen
 (1 Kommentar) (1 Reaktion) (0 zugewiesene Personen)C# (1.189 Forks)batch import
help wantedproject: NSwag.Core.Yamltype: bug

Repository-Metriken

Stars
 (6.291 Stars)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

The following response header YAML definition gives an error while generating C# Core 3.1 code:

  responses:
    '200':
      description: OK
      headers:
        Last-Modified:
          description: The UTC datetime at when the item was last modified
          required: true
          schema:
            type: string

Exception: Newtonsoft.Json.JsonSerializationException: Error converting value "true" to type 'System.Collections.Generic.ICollection1[System.String]'. Path 'paths['/item/{id}'].head.responses.200.headers.Last-Modified.required', line 1, position 2518. ---> System.ArgumentException: Could not cast or convert from System.String to System.Collections.Generic.ICollection1[System.String].

It looks like the generator is expecting a string array, while the required parameter should be parsed as a boolean, just like path parameters

(version 13.6.2)

Contributor Guide