Open alex-leroux opened 6 years ago
Hi, if I generate an Asp Net Core MVC controller using SwaggerToCSharpControllerGenerator, with the following operation specification:
"/api/Values/echoheaders": { "get": { "tags": [ "Values" ], "operationId": "Values_EchoHeaders", "parameters": [ { "type": "string", "name": "Authorization", "in": "header", "required": true, "x-nullable": true }, { "type": "string", "name": "customHeader", "in": "header", "required": true, "x-nullable": true } ], "responses": { "200": { "x-nullable": true, "description": "", "schema": { "type": "array", "items": { "type": "string" } } } } } },
I get the following code for the operation:
[Microsoft.AspNetCore.Mvc.HttpGet, Microsoft.AspNetCore.Mvc.Route("api/Values/echoheaders")] public System.Threading.Tasks.Task<System.Collections.ObjectModel.ObservableCollection<string>> EchoHeaders(string authorization, string customHeader) { return _implementation.EchoHeadersAsync(authorization, customHeader); }
I think that for this method to work, the parameters require the [FromHeader] attribute. Is this correct, or does this work some other way?
Thank you for your time. Alex le Roux
You are right, we need to generate [FromHeader] attributes here, but they don't exist for ASP.NET (not core) so maybe we need to exclude header parameters for old ASP.NET and add [FromHeader] for ASP.NET Core
PR: https://github.com/RicoSuter/NSwag/pull/2033
Hi, if I generate an Asp Net Core MVC controller using SwaggerToCSharpControllerGenerator, with the following operation specification:
I get the following code for the operation:
I think that for this method to work, the parameters require the [FromHeader] attribute. Is this correct, or does this work some other way?
Thank you for your time. Alex le Roux