'Create nuget package from a REST Web API Application

I have a REST API web service in ASP.NET CORE 2.0 several projects (layers) in it. However, by larger forces, it can not be used as a service.

It was then suggested to create a nuget package for this WEB API. I've never created a nuget package and I've seen examples on the internet of simple projects being used as a nuget package and not a WEB REST API. The question is:

Can I generate a nuget package from my WEB API REST application?-

** Edit

--

Larger Forces => Fearful stackeholders

Application Type => Audit Log (for several other applications)

** Situation **

Applications will not be able to accomplish anything without logging in before, and stackeholders are concerned that this API will eventually stop working for some reason, and all applications that consume this service will stop working.

--

** Application Architecture **

  • Controller
  • Application
  • Domain
  • Repository
  • etc ...

1) Do I need to change an Architecture?

2) If it is possible to use this API as a nuget package, do I use it as if it were a service? For example, I have a route => GET: http://localhost/api/logs. I would use these routes of the Controllers? Or would I access API resources in another way?



Solution 1:[1]

The existing api can be converted into razor class library with controller support but all other configurations need to be done from the main application. The razor class library can be packed and referenced.

The Swashbuckle.AspNetCore (https://github.com/domaindrivendev/Swashbuckle.AspNetCore.git) provides an endpoint which serves the static files from the embedded resource from the Swashbuckle.AspNetCore.SwaggerUI Doesn't this work the way you want it to be? Isn't it a api which can be configured and used into other api? I think following this architecture should solve this issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1