Swagger Integeration .NetcoreApp3.1
See original GitHub issueI created a sample app where I copied the basic example from the website (MyFirstService).
The unity integration works out of the box, but when I tried to add the Swagger integration, I just get a
localhost is currently unable to handle this request.
HTTP ERROR 500
I added the following packages:
- MagicOnion (2.6.3)
- MagicOnionHosting (2.6.3)
- MagicOnionHttpGateway (2.6.3)
Are there any other packages I need to add to have the swagger integration work properly?
I tested the swagger in the Sandbox application of the source, and it seemed to work flawlessly, but I noticed it uses .NetCoreApp 2.1.
Might it be an issue with the .NetCoreApp 3.1 which I currently have based my application on or might there be anything else missing?
If it would help I can also upload an example repo with minimal code, if that might help in pinpointing the problem.
The main code I used is:
class Program
{
static async Task Main(string[] args)
{
var magicOnionHost = MagicOnionHost.CreateDefaultBuilder()
.UseMagicOnion(
new MagicOnionOptions(isReturnExceptionStackTraceInErrorDetail: true),
new ServerPort("localhost", 12345, ServerCredentials.Insecure))
.UseConsoleLifetime()
.Build();
var webHost = new WebHostBuilder()
.ConfigureServices(collection =>
{
collection.AddSingleton<MagicOnionServiceDefinition>(magicOnionHost.Services.GetService<MagicOnionHostedServiceDefinition>().ServiceDefinition);
})
.UseKestrel()
.UseStartup<Startup>()
.UseUrls("http://localhost:5432")
.Build();
await Task.WhenAll(webHost.RunAsync(), magicOnionHost.RunAsync());
}
}
public class Startup
{
public void Configure(IApplicationBuilder app, MagicOnionServiceDefinition magicOnion)
{
app.UseMagicOnionSwagger(magicOnion.MethodHandlers, new SwaggerOptions("MagicOnion.Server", "Swagger Integration Test", "/")
{
});
app.UseMagicOnionHttpGateway(magicOnion.MethodHandlers, new Channel("localhost:12345", ChannelCredentials.Insecure));
}
}
}
public interface IMyFirstService : IService<IMyFirstService>
{
UnaryResult<int> SumAsync(int x, int y);
}
public class MyFirstService : ServiceBase<IMyFirstService>, IMyFirstService
{
public async UnaryResult<int> SumAsync(int x, int y)
{
Logger.Debug($"Received:{x}, {y}");
return x + y;
}
}
Any help would be appreciated.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
thanks! I’ve confirmed this bug and fixed in
3.0.8
, all code uses asynchronous only.Hi! Our team found a solution for the Swagger Integration on netcoreapp3.1.
It is working fine. Please check it and update README.md.