I recently started using hyphens in my route urls and it causing me some issues, which I hope we can clarify.
In my ServiceModel, I change an API endpoint route attribute to use a hyphen as follows:
Original
[Tag("App")]
[Route("/api/app/usersetting", "GET")]
New
[Tag("App")]
[Route("/api/app/user-setting", "GET")]
After making the change, the correct entry appears in swagger-ui and the route works correctly:
https://localhost:72560/api/app/user-setting works correctly.
However:
-
an additional entry is also listed in swagger-ui, which was not there before using the hyphen:
-
the additional route https://localhost:72560/usersettings is also working
-
I do not define the {IndexId} or PATCH routes
As part of the changes, I also upgraded from ServiceStack 5.12.1 to 6.0.3, so in AppHost, I made the following changes as discussed in After upgrading from 5.13.2 to 6.0.3 swagger-ui is not working
public override void Configure(Container container)
{
// ...
// Disable /api prefix on all services
ConfigurePlugin<PredefinedRoutesFeature>(feature => feature.JsonApiRoute = null);
// Add OpenApiFeature link to /metadata page as /swagger-ui
var swaggerUrl = "swagger-ui/";
ConfigurePlugin<MetadataFeature>(
feature => feature.AddPluginLink(swaggerUrl, "Swagger UI"));
// ...
}
Strangely, if I remove the hyphen from the above route, the additional entry and route remain. I have also cloned the code to a clean laptop and have the same results.
Any ideas?
I am using ServiceStack 6.0.3 (Net6/C#10/Windows10).