swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Swagger UI hangs and become very slow after expanding the end point

Open prataparunsingh opened this issue 5 years ago • 16 comments

Hi Team,

I have integrated swagger to my API controller. The UI gets hanged once I click to expand any of the endpoint. I some analysis I figured out this is because of the complexity of the Response schema. Please find the class definition below.

public class AddressTypeInformation : IInformationWithKey, IDataTransferObjectBase { public AddressTypeInformation(); public AddressTypeInformation(string id, long myId, int? addressTypeNumber, string name, string description, int status, IList<PersonAddressInformation> personAddresses, IList<NodeAddressInformation> nodeAddresses, IList<CompanyAddressInformation> companyAddresses, IList<BankAddressInformation> bankAddresses);

    public virtual string InformationKey { get; set; }
    public virtual string Id { get; set; }
    public virtual long MyId { get; set; }
    public virtual int? AddressTypeNumber { get; set; }
    public virtual string Name { get; set; }
    public virtual string Description { get; set; }
    public virtual int Status { get; set; }
    public virtual IList<PersonAddressInformation> PersonAddresses { get; set; }
    public virtual IList<NodeAddressInformation> NodeAddresses { get; set; }
    public virtual IList<CompanyAddressInformation> CompanyAddresses { get; set; }
    public virtual IList<BankAddressInformation> BankAddresses { get; set; }

Once I remove the last four properties (of IList type) from the response class definition, it works fine.

Can you please help me on this. Is there any work around to handle complex schema in swagger.

Thanks, Arun

prataparunsingh avatar Jan 07 '21 07:01 prataparunsingh

@prataparunsingh please provide the generated swagger definition.

mathis-m avatar Jan 07 '21 07:01 mathis-m

Please find attached swagger.json file. swagger.zip

prataparunsingh avatar Jan 07 '21 09:01 prataparunsingh

Very large one! Nearly 1M lines of json sample that is beeing generated for the GetAddressesResponse. I tracked it down to the response rendering. I have tried to disable highlighting the sample. But still does not render.

mathis-m avatar Jan 07 '21 11:01 mathis-m

Any update on this? I am seeing a similar issue with half the spec size

ferrantejake avatar May 27 '21 20:05 ferrantejake

For a quick fix, is it possible not to allow the expansions?

russm3086 avatar Aug 03 '21 12:08 russm3086

https://github.com/argoproj/argo-workflows/issues/6645

alexec avatar Sep 01 '21 21:09 alexec

Any progress on this, I am having the same issue, even with much smaller specs. Thanks

SkinnyPete63 avatar May 16 '22 15:05 SkinnyPete63

Any progress? I also have the same issue, even with 40 thousand rows of json. Thanks in advance.

MelihCelik00 avatar Oct 14 '22 12:10 MelihCelik00

Facing same issue here is my schema https://pastebin.com/efCJgYRN

prash-kr-meena avatar Oct 17 '22 12:10 prash-kr-meena

On my part, it's not only the expanding that is slow, but writing in the request body section (free text json).

billybraga avatar Oct 17 '22 12:10 billybraga

Hey y'all, in my case, the problem is the swagger ui itself. I tested in Postman and my api works very well even in large JSON response body. This solved my issue maybe it will be useful for you either.

MelihCelik00 avatar Oct 18 '22 06:10 MelihCelik00

Same issue here.

See https://app.screencast.com/28ukAb1Wq2iG4

mdchafin avatar Nov 14 '22 13:11 mdchafin

I m also getting the same issue.When i open any of the endpoints the ui hang after a quite long time i found the response body the json generated for the entire db schema

image image

msures4 avatar Nov 15 '22 17:11 msures4

On my part, it's not only the expanding that is slow, but writing in the request body section (free text json).

I am also facing this issue on dev.

mnkhtrbukhbold avatar Aug 27 '23 13:08 mnkhtrbukhbold

This solved the problem for me: swaggerOptions: { syntaxHighlight: false, },

josteint avatar Mar 01 '24 09:03 josteint

Still experiencing this issue. Example generator eagerly generates all nested properties w/o depth limitation. Is there any way to override this behaviour?

As a workaround I had to switch model rendering to render model by default. This helps with the initial operation expansion.

defaultModelRendering: 'model',

yuryturing avatar Jul 12 '24 15:07 yuryturing