I have a .NET core app I update to the last versión 2.2.0 but the swagger doesn't work, correctly the post login in the response show
Unknown response type
https://www.screencast.com/t/yb8UNne4
This is the previous versión
https://www.screencast.com/t/GMiG1RLK
I can't authorize too I try to set the bearer and token with the Word bearer token or token but doesn't works
Does the curl request that it's generating look correct? What happens when you run that directly from the command line?
Regarding the bearer token - you need to provide a security requirement as per the swagger spec. Read through the comments in #603
the curls is correct If I try with postman works perfectly the last version all works fine
Same problem juts upgraded from 1.x
works from browser url and curl. Its a simple get with no params.
In the UI
Response body
Unknown response type
Response headers
Server: nginx/1.13.4
Date: Fri, 09 Mar 2018 01:24:43 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: no-cache, no-store, max-age=0
Pragma: no-cache
Expires: -1
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: *
Access-Control-Allow-Origin: *
Request-Context: appId=cid-v1:dd8e84f8-b600-4121-808f-0666727522b9
It hits it correctly eg
dbug: Microsoft.AspNetCore.Mvc.Internal.ObjectResultExecutor[2]
Selected output formatter 'Microsoft.AspNetCore.Mvc.Formatters.JsonOutputFormatter' and content type 'application/json' to write the response.
Is the default ; charset causing an issue ?
I am seeing the same behavior in my app regarding the response type showing Unknown Response Type.
I’m not seeing this behavior in any of my sample apps. Could the folks on this thread help me find a repro, perhaps by starting from a blank project?
I'm actually seeing this to, I thought it was just me. I'll see if I can
break down a small repo on it.
On 8 Mar. 2018 8:33 pm, "domaindrivendev" notifications@github.com wrote:
I’m not seeing this behavior in any of my sample apps. Could the folks on
this thread help me find a repro, perhaps by starting from a blank project?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/631#issuecomment-371703142,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFIxOrbIe0gD3KWoPaFKIwjMhXnYkE8sks5tcfgNgaJpZM4SaP3C
.
I'm having the same issue. With version 1.0.0 of Swashbuckle.AspnetCore everything works fine. I think it is a problem in the Swagger UI.
Same issue here with v2.2.0. Content-Type of the response is application/json; charset=utf-8, I wonder if that ; charset=utf-8 is the source of confusion.
EDIT: nope, still happening even if I explicitly set a Content-Type of application/json. This very simple action still results in an "Unknown response type" error.
[HttpGet]
public IActionResult Get() {
return Content("{\"result\": true}", "application/json");
}
I suspect we are all adding oauth2 ... I rolled back ui to 1.2 and left everything else at 2.* and its fine. So definitely the ui package.
This is clearly an issue that needs to be addressed but unfortunately I can’t repro. It would be very helpful if someone could create complete repro steps, starting with a blank app. That will definitely help me get to a resolution sooner
I got the same behavior, but only on MS Edge browser (16.xxx). IE11 and Firefox work ok.
Tested on the basic demo.
Indeed, the problem seems to be related to the Edge browser. I'm using Edge 15.x. It works fine on Chrome.
Here's a repro, it's a very simple project. Nothing really special about it.
https://github.com/BrightSoul/Swashbuckle-Issue-631-Repro
I've used the .NET Core SDK v2.0.3 for this, even though the 2.1-preview1 is installed in my system.
I've noticed Kestrel is returning this chunked response when I invoke the /api/values endpoint.
HTTP/1.1 200 OK
Date: Sat, 10 Mar 2018 08:48:27 GMT
Content-Type: application/json; charset=utf-8
Server: Kestrel
Transfer-Encoding: chunked
13
["value1","value2"]
0
Please note the 13 and 0 are normal, since this is a chunked response. I wonder if they're the culprit?
Ah good someone got to this, that's what I wanted to demonstrate.
On Sat., 10 Mar. 2018, 1:58 am BrightSoul, notifications@github.com wrote:
Here's a repro, it's a very simple project. Nothing really special about
it.
https://github.com/BrightSoul/Swashbuckle-Issue-631-ReproI've used the .NET Core SDK v2.0.3 for this, even though the 2.1-preview1
is installed in my system.
I've noticed Kestrel is returning this chunked response when I invoke the
/api/values endpoint.HTTP/1.1 200 OK
Date: Sat, 10 Mar 2018 08:48:27 GMT
Content-Type: application/json; charset=utf-8
Server: Kestrel
Transfer-Encoding: chunked13
["value1","value2"]
0Please note the 13 and 0 are normal, since this is a chunked response.
I wonder if they're the culprit?—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/631#issuecomment-372014866,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFIxOocYxD1EAxOUXf095oRpQFIDnV-yks5tc5WogaJpZM4SaP3C
.
Response encoded? Does that matter? I can't get time to put the repro together to help but hoping the one that BrightSoul put down.
I can confirm though it works differently between IE/Edge and Chrome.
Yes I test on chrome and firefox, and internet explorer 11 works, in edge doesn't work
http://petstore.swagger.io/#/pet/addPet
Can anyone try this under edge? I don't think this is an issue with swashbuckle, i ran edge on the swagger.io site and it fails with unknown response.
<meta http-equiv="x-ua-compatible" content="IE=edge">
Is missing from 3.12 and is in the older revisions of swagger.
Confirmed. I see the 'Unknown response type' error on petstore.swagger.io as well.
I don't think this is an issue with swashbuckle
Now that you mention it, I see a similar issue opened in the Swagger UI repository.
https://github.com/swagger-api/swagger-ui/issues/3533
It seems to be related to a bug in Edge.
There was another issue; I've lost the link now, that they removed the meta tag in 3.x. I assume that's all it is to fix it again. Until they sort out 3533 properly... doesn't seem it was done.
Found the link : https://github.com/swagger-api/swagger-ui/issues/1355
https://github.com/swagger-api/swagger-editor/issues/1371 has a workaround fix, either @domaindrivendev can input or everyone has a way to work around me thinks.
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/9370062/
Looks like it'll be fixed in edge... eventually, i think i'm linking this properly.
I’m happy to bake this into the embedded version in SB. If I do, can folks on this thread test it out (via builds of master on myget.org). With this help, especially around cross-browser regression testing, I can get an official release out sooner.
I’ll post here when the preview is available
I just tested a custom index.html in my local with the override, works.
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Security.API V1");
c.IndexStream = () => GetType().GetTypeInfo().Assembly
.GetManifestResourceStream("Security.API.CustomSwagger.html");
});
And i dropped the script tag in that was in the link above.
<meta charset="UTF-8">
<title>%(DocumentTitle)</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./swagger-ui.css">
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<script>
if(window.navigator.userAgent.indexOf("Edge") > -1) {
console.log("Removing native Edge fetch implementation");
window.fetch = undefined;
}
</script>
I can get some time to test your myget hopefully sometime .. :)
The preview is now available at https://myget.org/feed/domaindrivendev/package/nuget/Swashbuckle.AspNetCore.
Looks good for me so will close issue but please test and let me know. If I get 1 or 2 confirmations I’ll release an official nuget
Thumbs up, it's now working for me.
@domaindrivendev did you release this? I can not install the v2.4 from above and its not available in official nuget site
Me too. Really need a fix.
don't use Microsoft Edge and you'll find a new world 23333333
Hello
with the new version of swagger the authorization does not working in the swagger documentation page but when we use curl or postman all things workes fine so the problem was in the swagger does not put the new field in the header
you can use this code to solve this problem
` public class BasicAuthFilter : IDocumentFilter
{
public void Apply(SwaggerDocument swaggerDoc, DocumentFilterContext context)
{
var securityRequirements = new Dictionary
{
{ "bearer", new string[] { } }
};
swaggerDoc.Security = new[] { securityRequirements };
}
}
//in startup file
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1.0", new Info { Title = "Demo App API", Version = "v1.0" });
c.AddSecurityDefinition("bearer", new ApiKeyScheme
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: bearer {token}\"",
Name = "Authorization",
In = "header",
Type = "apiKey"
});
c.DocumentFilter<BasicAuthFilter>();
});
`
Most helpful comment
The preview is now available at https://myget.org/feed/domaindrivendev/package/nuget/Swashbuckle.AspNetCore.
Looks good for me so will close issue but please test and let me know. If I get 1 or 2 confirmations I’ll release an official nuget