REST

It is also possible to configure the APIs and the endpoints using the REST endpoints.

API Framework can be configured through the REST endpoints provided by the API Framework's Admin-package.

Note: API Framework's Admin APIs don't provide persistance.

The Admin APIs provide the following functionality:

  • API: Get current APIs (the catalog of APIs) and add API from Nuget
  • Endpoints: Get current endpoints, Create a new endpoint, Initialize a new endpoint
  • Status: Get full status of the API Framework: API Catalog, Endpoints

Here's a full example which showcases all the functionalities provided by the REST endpoints:

curl -X PUT "https://localhost:5001/admin/api/apis?packageName=Weikio.ApiFramework.Plugins.SqlServer&version=2.0.0&feedUrl=https%3A%2F%2Fapi.nuget.org%2Fv3%2Findex.json" -H  "accept: application/octet-stream" -k -d '{}'
curl -X PUT "https://localhost:5001/admin/api/apis?packageName=Weikio.apiframework.plugins.openapi&version=1.0.0&feedUrl=https%3A%2F%2Fapi.nuget.org%2Fv3%2Findex.json" -H  "accept: application/octet-stream" -k -d '{}'
curl -X PUT "https://localhost:5001/admin/api/apis?packageName=Weikio.ApiFramework.Samples.PluginLibrary&version=1.0.0&feedUrl=https%3A%2F%2Fapi.nuget.org%2Fv3%2Findex.json" -H  "accept: application/octet-stream" -k -d '{}'
curl -X POST "https://localhost:5001/admin/api/Endpoints" -H  "accept: application/octet-stream" -H  "Content-Type: application/json" -d '{\"Api\":{\"Name\":\"Weikio.ApiFramework.Plugins.SqlServer\",\"Version\":\"2.0.0.0\"},\"JsonConfiguration\":{\"ConnectionString\":\"Server=tcp:adafydevtestdb001.database.windows.net,1433;User ID=docs;Password=3h1@*6PXrldU4F95;Integrated Security=false;Initial Catalog=adafyweikiodevtestdb001;\"},\"Route\":\"/adventure\"}' -k
curl -X POST "https://localhost:5001/admin/api/Endpoints" -H  "accept: application/octet-stream" -H  "Content-Type: application/json" -d '{\"Api\":{\"Name\":\"Weikio.ApiFramework.Plugins.OpenApi\",\"Version\":\"1.0.0.0\"},\"JsonConfiguration\":{\"SpecificationUrl\":\"https://petstore.swagger.io/v2/swagger.json\"},\"Route\":\"/pets\"}' -k
curl -X POST "https://localhost:5001/admin/api/Endpoints" -H  "accept: application/octet-stream" -H  "Content-Type: application/json" -d '{\"Api\":{\"Name\":\"Weikio.ApiFramework.Samples.PluginLibrary.HelloWorldApi\",\"Version\":\"1.0.0.0\"},\"Route\":\"/hello\"}' -k
curl -X POST "https://localhost:5001/admin/api/Endpoints/%2Fadventure/initialize" -H  "accept: application/octet-stream" -d "{}"
curl -X POST "https://localhost:5001/admin/api/Endpoints/%2Fpets/initialize" -H  "accept: application/octet-stream" -d "{}"
curl -X POST "https://localhost:5001/admin/api/Endpoints/%2Fhello/initialize" -H  "accept: application/octet-stream" -d "{}"