-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
affected/v12area/backendstate/reproducedstate/sprint-candidateWe're trying to get this in a sprint at HQ in the next few weeksWe're trying to get this in a sprint at HQ in the next few weekstype/bug
Description
Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)
12.0.0-rc2
Bug summary
The OpenAPI v3 specification does not support path parameters with multiple segments (OAI/OpenAPI-Specification#892).
This means that any OpenApi tooling won't support it either, and will simply encode the slashes when doing API requests.
This can already be seen in the swagger UI itself, which means you get a 404 when trying to, for example, retrieve the root /
In order for Umbraco to have a compliant spec and allow consumers to use code generation tools, I think it should support both encoded and non-encoded paths.
Specifics
No response
Steps to reproduce
- Install the latest Umbraco 12 RC2
- Create some dummy content types and content
- Use the swagger UI to retrieve content by path
/
or configure a code generation tool by following the following steps - Save the
/umbraco/swagger/delivery/swagger.json
file in the project asUmbracoDeliveryApiSwagger.json
- Add the following to the
.csproj
file:
<ItemGroup>
<PackageReference Include="NSwag.ApiDescription.Client" Version="13.19.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Microsoft.Extensions.ApiDescription.Client" Version="7.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<OpenApiReference Include="UmbracoDeliveryApiSwagger.json" CodeGenerator="NSwagCSharp" Namespace="Umbraco.DeliveryApi" ClassName="DeliveryApiClient" />
</ItemGroup>
- Add the following to the end of
WithEndpoints
inStartup.cs
:
u.EndpointRouteBuilder.MapGet("/delivery-test", async (HttpContext context, IOptions<WebRoutingSettings> webRoutingSettings, IHttpClientFactory httpClientFactory) =>
{
DeliveryApiClient client = new(context.Request.GetApplicationUri(webRoutingSettings.Value).ToString(), httpClientFactory.CreateClient(nameof(DeliveryApiClient)));
return await client.GetContentItemByPathAsync("/");
});
- When you call the
/delivery-test
endpoint you'll get an exception due to the 404
Expected result / actual result
No response
rbottema
Metadata
Metadata
Assignees
Labels
affected/v12area/backendstate/reproducedstate/sprint-candidateWe're trying to get this in a sprint at HQ in the next few weeksWe're trying to get this in a sprint at HQ in the next few weekstype/bug