maskx/OData

how can add swagger support?

liminany opened this issue · 2 comments

how can add swagger support?

or any Reference Article?

BTW, the nuget pkg is not Latest version(it is net version,not support netcore), I clone the source code and add Reference to my project that it work!!

maskx commented

you can reference this: https://github.com/Microsoft/aspnet-api-versioning/tree/master/samples/aspnetcore/SwaggerODataSample

The master branch is just worked, not ready to release a nuget pkg

To add support for swagger have this in the Startup.cs: ConfigureServices method

` services.AddOData();
services.AddMvcCore(options =>
{
foreach (var outputFormatter in options.OutputFormatters.OfType<Microsoft.AspNetCore.Mvc.Formatters.OutputFormatter>().Where(x => x.SupportedMediaTypes.Count == 0))
{
outputFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/prs.odatatestxx-odata"));
}

            foreach (var inputFormatter in options.InputFormatters.OfType<Microsoft.AspNetCore.Mvc.Formatters.InputFormatter>().Where(x => x.SupportedMediaTypes.Count == 0))
            {
                inputFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/prs.odatatestxx-odata"));
            }
        });

        // If using Kestrel:
        services.Configure<KestrelServerOptions>(options =>
        {
            options.AllowSynchronousIO = true;
        });

        // If using IIS:
        services.Configure<IISServerOptions>(options =>
        {
            options.AllowSynchronousIO = true;
        });`