문제

I was wondering if it's possible to have swagger to serve pages at place of SS metadata page... I'm asking this since SS metadata is quite usefull when you've a lot of services

as far I've seen I can remove the feature on SS configuration, disable the httphandler but don't know how to go further

Thanks

도움이 되었습니까?

해결책

So remove the MetaDataFeature in the AppHost Configure method:

SetConfig(new HostConfig { 
    EnableFeatures = Feature.All.Remove(Feature.Metadata)
});

Then create this simple MetaData service, that redirects to Swagger.

[Route("/metadata/{cmds*}", "GET")]
public class RedirectToSwaggerRequest : IReturnVoid 
{
    public string cmds { get; set; }
}

[Restrict(VisibleLocalhostOnly = true)]
public class MetadataService : Service
{
    public void Get(RedirectToSwaggerRequest request)
    {
        base.Response.Redirect("/swagger-ui");
    }
}

Note: {cmds*} in the route above will catch requests for /metadata, /metadata/something & /metadata/somethingelse etc.

Then when a request goes to /metadata then it will redirect to Swagger instead.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top