maskx / OData

easy access your database by OData WebApi
http://maskx.github.io/OData/
MIT License
15 stars 4 forks source link

how can add swagger support? #8

Open liminany opened 5 years ago

liminany commented 5 years ago

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 5 years ago

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

idemery commented 4 years ago

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().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;
        });`