ByteCrumb / Umbraco.Community.DeliveryApiExtensions

Umbraco Delivery API extensions⚡
Mozilla Public License 2.0
17 stars 2 forks source link

Expanding content endpoints in Umbraco Delivery API is hanging when TypedSwagger is enabled #30

Open bjarnef opened 2 months ago

bjarnef commented 2 months ago

Which version of the package are you using?

12.0.0

Which Umbraco version are you using? For example: 12.2.0 - don't just write v12

12.3.9

Bug summary

I noticed on a project we have Delivery API extensions package enabled expanding content endpoints under Umbraco Delivery API made the application hanging until the browser failed.

We had this configuration:

"DeliveryApiExtensions": {
  "Preview": {
    "Enabled": true,
    "Media": {
      "Enabled": true
    },
    "AllowedUserGroupAliases": [], // All allowed by default
    "ContentAppWeight": -50
  },
  "TypedSwagger": {
    "Enabled": true,
    "Mode": "Auto"
  }
}

after changing TypedSwagger with Enabled": false the Swagger content endpoints expands just fine.

Steps to reproduce

Expand any content endpoints under Umbraco Delivery API and notice difference with TypedSwagger enabled and disabled.

TypedSwagger enabled

image

image

image

TypedSwagger disabled

image

Expected result / actual result

No response

bjarnef commented 2 months ago

It seems to be related to this logic executing here, when TypedSwagger is enabled.

https://github.com/ByteCrumb/Umbraco.Community.DeliveryApiExtensions/blob/v13/main/src/UmbracoDeliveryApiExtensions/Configuration/UmbracoBuilderExtensions.cs#L53-L74

lauraneto commented 2 months ago

Hi @bjarnef ,

I think the issue you are experiencing is most likely due to https://github.com/swagger-api/swagger-ui/issues/6787, so slightly out of our hands. Either way, when I have the time, I will double check the generated models to make sure we are not generating more than we should. 🙂

Just to confirm, the actual swagger json loads correctly, and only the UI is slow when you try to expand an operation?

vsilvar commented 2 months ago

Hi @bjarnef I took a look at the swagger ui bundled with Swashbuckle, and it seems to be quite a bit outdated. After updating it, performance was much better, so that might be something we can take a look at.

Would you be able to confirm if doing the following solves your issues?

bjarnef commented 2 months ago

Hi @lauraneto

I was only notable when expanding content endpoints, not media. I guess it is related to many content models including element types, where there often only are a few media types/models.

Swagger UI loaded correctly, but expanding the endpoints made the CPU spike.

However it also seems to have an impact on the Delivery API as the it seemed to shutting down on development environment on Umbraco Cloud. After we disabled TypedSwagger we haven't noticed the same issues.