-
|
Version 1.5.2 Controllerpublic void Register(Router router, HashSet registeredPaths) [SwaggerApi($"{BasePrefix}/delete/{{id}}", RouteMethod.Delete, Registerpublic static void RegisterFromInstance(this Router router, object instance, SiskHttpServerpublic async void Start() |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
Hello, thanks for the issue. I couldn't reproduce the problem. The Sisk.HttpServer package doesn't come with a native Swagger mechanism, and I don't know which package you're using for Swagger. Can you provide a reproducible and compilable code for us to investigate better? On the other hand, there's the Sisk.Documenting package (not yet published, it's under development) that was made to export documentation in Sisk applications. If you're interested, you can help develop this extension. using Sisk.Core.Entity;
using Sisk.Core.Http;
using Sisk.Core.Routing;
using Sisk.Documenting;
using Sisk.Documenting.Annotations;
using var host = HttpServer.CreateBuilder(5555)
.UseCors(CrossOriginResourceSharingHeaders.CreatePublicContext())
.UseApiDocumentation(
context: new ApiGenerationContext()
{
ApplicationName = "My application",
ApplicationDescription = "It greets someone."
},
routerPath: "/api/docs",
exporter: new OpenApiExporter() { ServerUrls = ["http://localhost:5555/"] })
.UseRouter(router =>
{
router.SetObject(new MyController());
})
.Build();
await host.StartAsync();
class MyController
{
[RouteGet]
[ApiEndpoint(Description = "Returns a greeting message.")]
[ApiQueryParameter(name: "name", IsRequired = false, Description = "The name of the person to greet.", Type = "string")]
public HttpResponse Index(HttpRequest request)
{
string? name = request.Query["name"].MaybeNullOrEmpty() ?? "world";
return new HttpResponse($"Hello, {name}!");
}
} |
Beta Was this translation helpful? Give feedback.
-
|
Found the problem. In the Note: I also saw that in this method, you rewrite wildcard routes private static string ConvertSwaggerPathToSisk(string swaggerPath)
{
if (string.IsNullOrEmpty(swaggerPath))
return swaggerPath;
// rewrite {param} to <param>
swaggerPath = Regex.Replace(
swaggerPath,
@"\{([a-zA-Z0-9_]+)\}",
@"<$1>"
);
return swaggerPath;
}Link to route path patterns. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you so much for your reply – it’s working now! |
Beta Was this translation helpful? Give feedback.
Thank you so much for your reply – it’s working now!