项目作者: ServiceGovernance

项目描述 :
Library providing an agent for the Service Repository
高级语言: C#
项目地址: git://github.com/ServiceGovernance/ServiceGovernance.Repository.Agent.git
创建时间: 2018-10-29T11:44:43Z
项目社区:https://github.com/ServiceGovernance/ServiceGovernance.Repository.Agent

开源协议:Apache License 2.0

下载


ServiceGovernance.Repository.Agent

Build status
NuGet Version
License

Provides an Agent (client) for the ServiceRepository. This agent publishes the API documentation of your ASP.NET Core application to the repository.

Usage

Either use the base NuGet package ServiceGovernance.Repository.Agent and provide an custom implementation for IApiDescriptionProvider or use the ServiceGovernance.Repository.Agent.SwaggerV3 NuGet package with built-in support for Swagger.

Example configuration for using with Swagger (you only need ServiceGovernance.Repository.Agent.SwaggerV3 package).

  1. public void ConfigureServices(IServiceCollection services)
  2. {
  3. ...
  4. services.AddSwaggerGen(c =>
  5. {
  6. c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
  7. });
  8. services.AddServiceRepositoryAgent(options => {
  9. options.Repository = new Uri("http://localhost:5005");
  10. options.ServiceIdentifier = "Api1";
  11. }).UseSwagger("v1");
  12. }
  13. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  14. {
  15. ...
  16. app.UseSwagger();
  17. app.UseServiceRepositoryAgent();
  18. }

Configuration

It’s also possible to provide these options via the configuration:

  1. public void ConfigureServices(IServiceCollection services)
  2. {
  3. ...
  4. services.AddServiceRepositoryAgent(options => Configuration.Bind("ServiceRepository", options));
  5. }
  1. {
  2. "ServiceRepository": {
  3. "Repository": "https://myservicerepository.mycompany.com",
  4. "ServiceIdentifier": "Api1"
  5. }
  6. }

Background

This agent collects the Api Descriptions as OpenApi document and sends it to the ServiceRepository where it can be viewed among other Api documentations from other services.