RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.78k stars 1.29k forks source link

Could you provide a sample for OWIN Middleware? #1924

Closed chucklu closed 5 years ago

chucklu commented 5 years ago

Hi @RSuter , I am trying use swagger according https://github.com/RSuter/NSwag/wiki/OWIN-Middleware. There is no sample for it, so I build one by myself.

There are two alternative ways to configure the routes: a) Pipe all request to the .NET pipeline b) Pipe only the Swagger request to the specific middlewares Method a come across a 404 error. And method encounter the 500 error as I report in https://github.com/RSuter/NSwag/issues/1915\

I am wondering if it is possible to use OWIN-Middleware directly. Could you help write a sample? Or maybe you can play with my demo project on https://github.com/ChuckTest/AspNetWebApi2. The repository currently have three branches. owin-global-asax branch is for https://github.com/RSuter/NSwag/wiki/OwinGlobalAsax . owin-middleware branch is for https://github.com/RSuter/NSwag/wiki/OWIN-Middleware .

chucklu commented 5 years ago

The 404 error might caused by lack of Microsoft.Owin.Host.SystemWeb. According this article https://docs.microsoft.com/en-us/aspnet/aspnet/overview/owin-and-katana/getting-started-with-owin-and-katana, the startup class rely on Microsoft.Owin.Host.SystemWeb.

chucklu commented 5 years ago

Finally, I work out a solution on https://github.com/ChuckTest/AspNetWebApi2/tree/owin-middleware

chucklu commented 5 years ago

$ git clone --depth=1 https://github.com/RSuter/NSwag.git Cloning into 'NSwag'... remote: Enumerating objects: 1468, done. remote: Counting objects: 100% (1468/1468), done. remote: Compressing objects: 100% (1190/1190), done. error: RPC failed; curl 56 Failure when receiving data from the peer fatal: the remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed https://stackoverflow.com/questions/6842687/the-remote-end-hung-up-unexpectedly-while-git-cloning tried with git config --global http.postBuffer 1048576000, but did not work