locked
consume Swagger file for an API RRS feed

  • Question

  • User2140666256 posted

    Hi Guys,
    I just got asked to prepare to get a API up that has a swagger file to connect to the company website to connect some new
    functionality and I have never done it before and the guy that normally does stuff like that has quit and they want it up and running ASAP so I was hoping someone could point me in the right direction.

    I have mapped up and utilized all kinds of webservices and things like that before and worked with integration of them but here I just dont know what to do.

    Thanks

    Monday, September 7, 2020 8:45 AM

All replies

  • User475983607 posted

    Are you asking for an utility that generates a C# client from a Swagger JSON file?  

    https://swagger.io/tools/swagger-codegen/

    https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-nswag?view=aspnetcore-3.1&tabs=visual-studio

    Monday, September 7, 2020 10:52 AM
  • User-2117779121 posted

    very well.cool

    Monday, September 7, 2020 11:22 AM
  • User2140666256 posted

    Yes, and I looked at the swagger-codegen but couldn't make full sense out of it...don't really understand how to use it.
    And the site is an old project that we dont work on anymore its a webforms project which will be replaced buy a
    core website next year. 

    Do we need to make a web api application as a middleware or can we just integrate it directly into the webforms project?

    Monday, September 7, 2020 1:28 PM
  • User-474980206 posted

    its not clear if you want to call a webapi site that supports swagger or write a new webapi site that supports swagger UI.

    if the first case, you download the swagger tools, and use the codegen to generate a client api for the swagger enabled website.

    if the second case, create your web api project. pick a swagger toolkit (say nswag or swashbuckle). then install the nuget package for the webapi framework and toolkit you are using. then follow the documentation for the chosen nuget package to add swagger support to your webapi project.

    note: if you are not using asp.net core you may need to add owin support.

    Tuesday, September 8, 2020 8:38 PM