This API totally hangs the swagger-ui.js script and I can't debug it (chrome is unresponsive).
I've validated it in the online validator without errors.
The json is here (had to rename to .txt for IIS to serve it):
http://admin40.maildirect.se/sandbox/api.txt
Any obvious errors?
I am experiencing the exact same issue here.
Installed Swashbuckle on a WebApi 2, hosted by IIS 8.5.
me too .
Installed Swashbuckle on an hybrid MVC 5 + WebApi 2, hosted by IIS 8.0
Yup same problem here.... MVC 5 + WebApi 2
Me too, i've just installed it into our "big" project which contains mvc 5 and web api 2 in one solution.
Sorry for being a bit late with posting my solution for this problem.. In my case, the problem was that I used a custom JsonNegotiator. I solved the problem by using a JsonMediaTypeFormatter as part of the webapi's formatters instead. Then everything worked smoothly...
FrederikNygaardSvendsen would you mind expanding on your solution?
I've played a bit with my web api configuration and figured out, that it stops working when I add the following line to enforce security
config.Filters.Add(new AuthorizeAttribute());
@FrederikNygaardSvendsen would you mind pasting some examples of your code ?
Turns out swagger couldn't handle circular references, had to add IgnoreDataMember to all references.
Also added a simple hack for adding oauth-password flow with username/password sent to endpoint. You can look at it here https://api.ungapped.com/swagger. Looks awesome, thank you!
Best regards
Oscar Uribe
Founder / Chief Executive Officer
oscar.[email protected]:oscar.[email protected]
+46 733 526 000
[Ungapped]http://www.ungapped.com/
Ungapped
www.ungapped.comhttp://www.ungapped.com/
R?dmansgatan 65 | 113 60 Stockholm Sweden
Follow: Facebookhttps://www.facebook.com/ungapped | Twitterhttps://twitter.com/ungapped | LinkedInhttps://www.linkedin.com/company/ungapped | Pinteresthttps://www.pinterest.com/ungapped/
10 dec. 2015 kl. 18:18 skrev ToXinE <[email protected]notifications@github.com>:
@FrederikNygaardSvendsenhttps://github.com/FrederikNygaardSvendsen would you mind pasting some examples of your code ?
Reply to this email directly or view it on GitHubhttps://github.com/domaindrivendev/Swashbuckle/issues/486#issuecomment-163691959.
Allthough it's been a while, as i recall, not using our own "custom" jsonFormatter, and setting up the formatter in the WebApiConfig this way, is what fixed the problem for me (but i dont think setting the SerializerSettings will do anything in this regard):
public static class WebApiConfig {
public static void Register(HttpConfiguration config) {
var jsonFormatter = new JsonMediaTypeFormatter();
jsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
config.Formatters.Clear();
config.Formatters.Insert(0, jsonFormatter);
// ... Other stuff
}
}
It was a circular reference problem. Swashbuckle ignored the [IgnoreDataMember] attributes and we got circular references. It would be a good idea to try to follow that standard☺
Best regards
Oscar Uribe
Founder / Chief Executive Officer
oscar.[email protected]:oscar.[email protected] | SE: +46 733 526 000, US: +1 415 505 68 63
www.linkedin.com/in/oscaruribehttp://www.linkedin.com/in/oscaruribe
[Ungapped]http://www.ungapped.com/
Ungapped | ungapped.comhttps://ungapped.com/
RÃ¥dmansgatan 65, 113 60 Stockholm Sweden | +46 8 410 413 13
180 Sansome St, San Francisco, CA 94104 | +1 800 931-6339
Follow: Facebookhttps://www.facebook.com/ungapped | Twitterhttps://twitter.com/ungapped | LinkedInhttps://www.linkedin.com/company/ungapped | Pinteresthttps://www.pinterest.com/ungapped/
Från: Frederik Nygaard Svendsen [mailto:[email protected]]
Skickat: den 10 december 2015 23:27
Till: domaindrivendev/Swashbuckle [email protected]
Kopia: Oscar Uribe Enggren oscar.[email protected]
Ämne: Re: [Swashbuckle] Hangs on "Fetching resource list" (#486)
Allthough it's been a while, as i recall, not using our own "custom" jsonFormatter, and setting up the formatter in the WebApiConfig this way, is what fixed the problem for me (but i dont think setting the SerializerSettings will do anything in this regard):
public static class WebApiConfig {
public static void Register(HttpConfiguration config) {
var jsonFormatter = new JsonMediaTypeFormatter();
jsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
config.Formatters.Clear();
config.Formatters.Insert(0, new GetAllPermissionsCsvFormatter());
config.Formatters.Insert(1, jsonFormatter);
// ... Other stuff
}
}
—
Reply to this email directly or view it on GitHubhttps://github.com/domaindrivendev/Swashbuckle/issues/486#issuecomment-163864229.
How did you solved the circular reference problem ?
I tried
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.None;
without any success :-1:
Turns out Swashbuckle does not use those serializer settings, they’re for web api.
I made new models for the entire web api layer instead of returning EF entities. Felt it was ugly that way anyway. Also did an Oauth sign in hack and redesign, it looks really good:
https://api.ungapped.com/swagger
Best regards
Oscar Uribe
Founder / Chief Executive Officer
oscar.[email protected]:oscar.[email protected] | SE: +46 733 526 000, US: +1 415 505 68 63
www.linkedin.com/in/oscaruribehttp://www.linkedin.com/in/oscaruribe
[Ungapped]http://www.ungapped.com/
Ungapped | ungapped.comhttps://ungapped.com/
RÃ¥dmansgatan 65, 113 60 Stockholm Sweden | +46 8 410 413 13
180 Sansome St, San Francisco, CA 94104 | +1 800 931-6339
Follow: Facebookhttps://www.facebook.com/ungapped | Twitterhttps://twitter.com/ungapped | LinkedInhttps://www.linkedin.com/company/ungapped | Pinteresthttps://www.pinterest.com/ungapped/
Från: ToXinE [mailto:[email protected]]
Skickat: den 10 mars 2016 05:31
Till: domaindrivendev/Swashbuckle [email protected]
Kopia: Oscar Uribe Enggren oscar.[email protected]
Ämne: Re: [Swashbuckle] Hangs on "Fetching resource list" (#486)
How did you solved the circular reference problem ?
I tried
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;
config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.None;
without any success [:-1:]
—
Reply to this email directly or view it on GitHubhttps://github.com/domaindrivendev/Swashbuckle/issues/486#issuecomment-194839281.
I'm going to close as it looks like this issue is resolved. Feel free to re-open if you feel there's something specific that can be done in Swashbuckle
Looks like there's still something to be addressed here. In general, SB should handle self-referencing types: https://github.com/domaindrivendev/Swashbuckle/blob/master/Swashbuckle.Tests/Swagger/SchemaTests.cs#L389
But, I'm guessing a certain level of nesting becomes problematic. On the one hand this is possibly a smell in your API design/implementation but then on the other hand SB should handle it better - at the very least detecting a critical level of nesting and throwing a meaningful exception.
Marking it for investigation
any news here? My Swagger UI is still hanging, but the JSON directly is generated.
Yes, we fixed it. In our case it was circular references from EF objects that messed it up. We ended up changing all EF objects returned into proper domain objects instead.
Poor feedback tho, and you kind of expect it too handle circular references but it doesn't.
Best regards
Oscar Uribe
Founder / Chief Executive Officer
oscar.[email protected]:oscar.[email protected]
+46 733 526 000
[X]
Ungapped
www.ungapped.comhttp://www.ungapped.com/
R?dmansgatan 65 | 113 60 Stockholm Sweden
180 Sansome St | San Francisco | 94 104 CA
Follow: Facebookhttps://www.facebook.com/ungapped | Twitterhttps://twitter.com/ungapped | LinkedInhttps://www.linkedin.com/company/ungapped | Pinteresthttps://www.pinterest.com/ungapped/
21 sep. 2016 kl. 14:24 skrev Eric Schoenholzer <[email protected]notifications@github.com>:
any news here? My Swagger UI is still hanging, but the JSON directly is generated.
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/domaindrivendev/Swashbuckle/issues/486#issuecomment-248595681, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AI_i3iLvYwI3d5JmRj3KY3-tGSj9cKLvks5qsSHvgaJpZM4F4zSP.
@oscaruribe Txs for your response. But are u an user or contributor here? I would like to hear from @domaindrivendev directly if they gonna fix that.
I have no intention to change our EF, before that, I drop Swashbuckle and mark it as not usable.
@EricSch - what happens if you access the swagger JSON endpoint directly? Does it still hang?
@domaindrivendev No, I get the JSON.
@EricSch - please don't drop Swashbuckle and bring my revenue numbers down. Oh wait ... I DON'T ACTUALLY GET PAID FOR THIS :)
I'm happy to try address issues but you should keep in mind that I'm providing this tool to the community with a lot of personal hours and no financial gain. Instead of complaining and calling it "unusable" you could try give something back - maybe dig in and debug the issue yourself?
Given that SB is first and foremost a Swagger generator that leverages an embedded version of the swagger-ui, we should investigate if this is a problem with the generated Swagger or a problem with the UI itself. Have you looked at the generated spec, in particular the definitions for your EF framework objects, and confirmed that it looks right?
@domaindrivendev Sorry, wasn't my intention to offend you. If I would complaining, I would have written: "Fix this immediately! How you dare!" :) With "unusable" I meant only in my special case, not generally. You did a great work here, very useful.
I get the Open Source movement, but I'm also happy to pay for a product and having the corresponding support. Dig into each problem in a open source project, would be a full time job. If I find time, I contribute to projects,
So back to my problem: I will look into swagger-ui and debug the JSON.
Thanks
I am also having a problem with this. I posted all the details as a question on stackoverflow but the just of it is this:
I have 2 classes Person and Order. A Person has a list of Orders, and an Order has a single Person as navigation properties. I have a single Get method on the api that returns a list of 2 people each with 2 orders. I had to configure Json.Net to ignore the circular references to get any output from my API at all, but as it was said above Swashbuckle doesn't use this configuration. As such the example value given in the Swagger UI is displaying Person->Order->Person (person included again in each order). This isn't what is actually returned by the method.
Good news is that by adding the [JsonIgnore] attribute Order.Person fixes the issue and the Person is not included in the Order. The bad news is, I might not want to always exclude the Person from the order.
I have encountered this issue for two different reasons.
1.) I had public controller methods that I had created without the [HttpGet] attribute.
[Route("{Id:int:min(1)}")]
public async Task<IActionResult> Get(int Id, string select = ALL_FIELDS, bool expand = false )
{ ...}
Fixed with:
[HttpGet]
[Route("{Id:int:min(1)}")]
public async Task<IActionResult> Get(int Id, string select = ALL_FIELDS, bool expand = false )
{...}
2.) When using the [FromBody] attribute in the parameter list for my Post method.
[HttpPost]
public async Task<IActionResult> Post([FromBody] TvUnit unit)
{...}
Note that [FromForm],[FromHeader],[FromQuery],[FromRoute] and [FromServices] doesn't cause this issue nor if I leave off the attribute as below:
[HttpPost]
public async Task<IActionResult> Post( TvUnit unit)
{...}
This is using "Swashbuckle": "6.0.0-beta902" and "Microsoft.AspNetCore.Mvc": "1.1.0"
I have the same issue when using "Swashbuckle": "6.0.0-beta901"
Update: The issue doesn't occur with [FromBody] when EF objects aren't used or when using an EF object and not specifying [FromBody]
These work:
public async Task
public async Task
+1
@domaindrivendev
i have try every solution that available online
i have try also IContentNegotiator using this JsonContentNegotiator but its not working
@MurtuzaTravadi What is your specific issue?
Thank you so much for such quick response @aaronralls can you please look at #1011 and #1012
Closing due to inactivity. For anyone still having problems, please ensure you have the latest version. If the original issue persists, please create a new issue with clear and concise repro steps.
I'm not sure if this is any help but I'm on ASP Core 2.0 and I resolved this issue by removing all actions that threw a NotImplementedException which I deliberately left so I remember to implement it.
@oscaruribe How did you work out that it was a circular reference issue?
Hello, I use your library with some modifications and I have this issue. My question is - what actually was fixed? Because I can't found any commit related to #486 or #1205 or #918. Thank you.
Most helpful comment
Sorry for being a bit late with posting my solution for this problem.. In my case, the problem was that I used a custom JsonNegotiator. I solved the problem by using a JsonMediaTypeFormatter as part of the webapi's formatters instead. Then everything worked smoothly...