I have the following situation:

  • ASP.NET Core WebAPI solution which uses Swagger
  • Automatically generated client for WebAPI using Autorest, extended with custom authorization. This client also will be packed into NuGet to be used by other services. Question: should I place the client into the same solution(and thus in the same VCS) or should I create the separate solution and repository for it?

My thought is that it's better to move client into separate repository since changes to it must not trigger build of the WebAPI project. On the other hand, changes to WebAPI should(in my opinion) trigger build and packaging of the client.

Suggestions are welcome. Thanks!

有帮助吗?

解决方案

Any project that is going to be pushed to a NuGet server works better if it is in a separate repository for the following reasons:

  • It helps encapsulate all testing and support code in one place
  • It forces client code to use NuGet instead of project dependencies
  • It helps find and identify missing assets required for your code's use more quickly--assuming you have example client code that pulls the latest and greatest from NuGet and attempts to use it/verify it.

That said, I do want to address a misconception:

On the other hand, changes to WebAPI should(in my opinion) trigger build and packaging of the client.

The types of changes to the WebAPI that require you to rebuild your client code are ones that require changes to your client code. I'll provide a couple examples to make it a bit clearer:

  • Changes to the implementation of a REST call don't require the client to be recompiled. All clients that can call that method will get the new functionality whether they are upgraded or not.
  • Changes to the REST interface itself do require changes to the client code, and it requires that you manage your versioning well so that that outdated clients can recognize when they can't work with the REST API implementation.
许可以下: CC-BY-SA归因
scroll top