Provides an Agent (client) for the ServiceRepository. This agent publishes the API documentation, by using Swagger, to the repository.
Install the NuGet package ServiceGovernance.Repository.Agent.SwaggerV3
.
public void ConfigureServices(IServiceCollection services)
{
...
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Info { Title = "My API", Version = "v1" });
});
services.AddServiceRepositoryAgent(options => {
options.Repository = new Uri("http://localhost:5005");
options.ServiceIdentifier = "Api1";
}).UseSwagger("v1");
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
...
app.UseSwagger();
app.UseServiceRepositoryAgent();
}
It's also possible to provide these options via the configuration:
public void ConfigureServices(IServiceCollection services)
{
...
services.AddServiceRepositoryAgent(options => Configuration.Bind("ServiceRepository", options));
}
{
"ServiceRepository": {
"Repository": "https://myservicerepository.mycompany.com",
"ServiceIdentifier": "Api1"
}
}
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.