Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions quickstart/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Weikio.ApiFramework.Abstractions;
using Weikio.ApiFramework.ApiProviders.PluginFramework;
using Weikio.ApiFramework.AspNetCore;
using Weikio.ApiFramework.AspNetCore.StarterKit;
using Weikio.ApiFramework.Core.Extensions;
using System;
using Weikio.ApiFramework;
using Weikio.ApiFramework.Plugins.OpenApi;
using Weikio.ApiFramework.Plugins.SqlServer;
using Weikio.ApiFramework.Plugins.SqlServer.Configuration;
Expand All @@ -28,43 +24,47 @@ public Startup(IConfiguration configuration)
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();

Func<ILogger<Startup>, string, string> helloApi = (logger, name) =>
{
logger.LogInformation("Running the API using parameter {Name}", name);
return $"Hello {name}!";
};

services.AddControllers();

services.AddApiFrameworkStarterKit()
.AddApi(helloApi)
.AddApi<CalculatorApi>()
.AddSqlServer()
.AddOpenApi()
.AddSqlServer("/sqlserver",
new SqlServerOptions
{
ConnectionString =
"Server=tcp:adafydevtestdb001.database.windows.net,1433;User ID=docs;Password=3h1@*6PXrldU4F95;Integrated Security=false;Initial Catalog=adafyweikiodevtestdb001;"
})
.AddSqlServer("/sqlserver_products",
new SqlServerOptions
{
ConnectionString =
"Server=tcp:adafydevtestdb001.database.windows.net,1433;User ID=docs;Password=3h1@*6PXrldU4F95;Integrated Security=false;Initial Catalog=adafyweikiodevtestdb001;",
Tables = new[] {"Product*"},
})
.AddOpenApi("/pets",
new ApiOptions
{
SpecificationUrl = "https://petstore.swagger.io/v2/swagger.json",
IncludeHttpMethods = new[] { "GET" }
}
)
.AddOpenApi("/pets_writeonly",
new ApiOptions
{
SpecificationUrl = "https://petstore.swagger.io/v2/swagger.json",
ExcludeHttpMethods = new[] { "GET" }
}
)
.AddEndpoint<CalculatorApi>("/mycal", 15)
.AddEndpoint<CalculatorApi>("/second", 100)
.AddEndpoint<CalculatorApi>("/third", 0)
.AddEndpoint("/sqlserver", ("Weikio.ApiFramework.Plugins.SqlServer", Version.Parse("1.1.0.0")), new SqlServerOptions()
{
ConnectionString =
"Server=tcp:adafydevtestdb001.database.windows.net,1433;User ID=docs;Password=3h1@*6PXrldU4F95;Integrated Security=false;Initial Catalog=adafyweikiodevtestdb001;"
})
.AddEndpoint("/sqlserver_products", ("Weikio.ApiFramework.Plugins.SqlServer", Version.Parse("1.1.0.0")), new SqlServerOptions()
{
ConnectionString =
"Server=tcp:adafydevtestdb001.database.windows.net,1433;User ID=docs;Password=3h1@*6PXrldU4F95;Integrated Security=false;Initial Catalog=adafyweikiodevtestdb001;",
Tables = new[] { "Product*" },
})
.AddEndpoint("/pets", "Weikio.ApiFramework.Plugins.OpenApi",
new ApiOptions() { SpecificationUrl = "https://petstore.swagger.io/v2/swagger.json", IncludeHttpMethods = new[] { "GET" } });

var endpointDefinition = new EndpointDefinition("/pets_writeonly", "Weikio.ApiFramework.Plugins.OpenApi",
new ApiOptions()
{
SpecificationUrl = "https://petstore.swagger.io/v2/swagger.json", ExcludeHttpMethods = new[] { "GET" }
});

services.AddSingleton(endpointDefinition);
.AddEndpoint<CalculatorApi>("/third", 0);
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -87,7 +87,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
});
}
}

public class CalculatorApi
{
public int Configuration { get; set; }
Expand All @@ -96,4 +96,4 @@ public int Sum(int x, int y)
return x + y + Configuration;
}
}
}
}
6 changes: 3 additions & 3 deletions quickstart/quickstart.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Weikio.ApiFramework.AspNetCore.Starterkit" Version="1.0.0-alpha.0.82" />
<PackageReference Include="Weikio.ApiFramework.Plugins.OpenApi" Version="1.0.0-alpha.0.23" />
<PackageReference Include="Weikio.ApiFramework.Plugins.SqlServer" Version="1.1.0-alpha.0.8" />
<PackageReference Include="Weikio.ApiFramework.AspNetCore.Starterkit" Version="1.1.0" />
<PackageReference Include="Weikio.ApiFramework.Plugins.OpenApi" Version="1.0.0" />
<PackageReference Include="Weikio.ApiFramework.Plugins.SqlServer" Version="2.2.0" />
</ItemGroup>


Expand Down