ServiceRepository is a combination of middleware and services. All configuration is done in your startup class.
You add the ServiceRepository services to the DI system by calling:
public void ConfigureServices(IServiceCollection services)
{
services.AddServiceRepository();
}
public void Configure(IApplicationBuilder app)
{
...
app.UseServiceRepository();
...
app.UseMvc();
}
Optionally you can pass in options into this call.
This will return you a builder object that in turn has a number of convenience methods to wire up additional services.
The "in-memory" configuration APIs allow for configuring ServiceRepository from an in-memory list of configuration objects.
Use of these configuration APIs are designed for use when prototyping, developing, and/or testing where it is not necessary to dynamically consult database at runtime for the configuration data.
AddInMemoryApiStore
RegistersIApiStore
implementation storing apis as in-memory list. Optional arguments are api documents which will be added to the store.
public void ConfigureServices(IServiceCollection services)
{
services.AddServiceRepository()
.AddInMemoryApiStore();
}
Available persistence libraries are:
Use one of the following extension method to register your custom store:
AddApiStore
AddsIApiStore
implementation for reading and storing api descriptions.
Following APIs are provided by this library:
This endpoint publishes an api description in the service repository.
Url | Method | Type |
---|---|---|
/v1/api/{serviceId} | POST | application/json |
serviceId
The unique service identitier to publish the document to.
body:
{
OpenApiDocument (v3)
}
Specification for the OpenApi v3 see here.
text/plain
HTTP 200
This endpoint returns the published api description.
Url | Method | Type |
---|---|---|
/v1/api/{serviceId} | Get |
serviceid
The service you want to retrieve
application/json
HTTP 200
The endpoint returns the published api description.
{
"serviceId": "UniqueServiceId",
"apiDocument": OpenApiDocument (v3)
}
Specification for the OpenApi v3 see here.
This endpoint returns all published api descriptions.
Url | Method | Type |
---|---|---|
/v1/api | Get |
application/json
HTTP 200
The endpoint returns all published api descriptions.
[
{
"serviceId": "UniqueServiceId",
"apiDocument": OpenApiDocument (v3)
},
{
...
}
]
Specification for the OpenApi v3 see here.