Skip to content

Commit

Permalink
Features/supportcomplexconfiguration (#8)
Browse files Browse the repository at this point in the history
* Add demo project for pet store swagger example

* Add Todo

* Refactor unit tests

* Adding unit tests for complex configuration

* Remove unused paths and definitions

* Removing unused tokens

* Dont remove definition if exist reference in response

* Refactor removing tags and definitions

* Configuration split by method type.

* Fix incorrect test

* no message

* Code factor fix
  • Loading branch information
Burgyn authored Jan 17, 2019
1 parent b0b5cd6 commit 756e588
Show file tree
Hide file tree
Showing 23 changed files with 3,668 additions and 43 deletions.
7 changes: 7 additions & 0 deletions MMLib.SwaggerForOcelot.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{A9111054
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MMLib.SwaggerForOcelot.Tests", "tests\MMLib.SwaggerForOcelot.Tests\MMLib.SwaggerForOcelot.Tests.csproj", "{D66F3C86-8D57-4802-B2F9-15F91262F12D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PetstoreService", "demo\PetstoreService\PetstoreService.csproj", "{0C20742E-0D4E-4407-AC5B-4162EEBD8FC5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -45,6 +47,10 @@ Global
{D66F3C86-8D57-4802-B2F9-15F91262F12D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D66F3C86-8D57-4802-B2F9-15F91262F12D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D66F3C86-8D57-4802-B2F9-15F91262F12D}.Release|Any CPU.Build.0 = Release|Any CPU
{0C20742E-0D4E-4407-AC5B-4162EEBD8FC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C20742E-0D4E-4407-AC5B-4162EEBD8FC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C20742E-0D4E-4407-AC5B-4162EEBD8FC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C20742E-0D4E-4407-AC5B-4162EEBD8FC5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -55,6 +61,7 @@ Global
{AD0D6610-E216-49DA-9FC6-3EC62879C34C} = {75938D16-D280-4200-A970-8D33B719D252}
{5D0346CB-0F8B-4D0F-94E5-0D7BAAAA0C5D} = {D0CA2BCE-C362-4C5A-8AC9-319742DDCDD8}
{D66F3C86-8D57-4802-B2F9-15F91262F12D} = {A9111054-B663-41BA-AE67-E6FE3E7515AF}
{0C20742E-0D4E-4407-AC5B-4162EEBD8FC5} = {75938D16-D280-4200-A970-8D33B719D252}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AAA408E9-E738-4F2B-A6C2-B35AAADDB00F}
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ Example:
- [x] Add capability for confiuragtion SwaggerUI and configure EndpointBasePath.
- [x] Unit tests
- [ ] Complex Ocelot configuration.
- [x] Add `Petstore` swagger Example.
- [x] Group more reroutes with same `SwaggerKey`.
- [x] Filter `UpstreamHttpMethod`.
- [ ] Query parameters.
- [ ] Aggregates.
- [x] Documentations
- [x] Continuous delivery
- [ ] Custom Index.html.
18 changes: 18 additions & 0 deletions demo/ApiGateway/ocelot.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@
"UpstreamPathTemplate": "/api/projects/{everything}",
"UpstreamHttpMethod": [ "Get" ],
"SwaggerKey": "projects"
},
{
"DownstreamPathTemplate": "/{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5300
}
],
"UpstreamPathTemplate": "/api/pets/{everything}",
"UpstreamHttpMethod": [ "Get" ],
"SwaggerKey": "pets"
}
],
"SwaggerEndPoints": [
Expand All @@ -37,6 +50,11 @@
"Key": "contacts",
"Name": "Contacts API",
"Url": "http://localhost:5100/swagger/v1/swagger.json"
},
{
"Key": "pets",
"Name": "Petsstore API",
"Url": "http://localhost:5300/swagger.json"
}
],
"GlobalConfiguration": {
Expand Down
12 changes: 12 additions & 0 deletions demo/PetstoreService/PetstoreService.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions demo/PetstoreService/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace PetstoreService
{
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}
45 changes: 45 additions & 0 deletions demo/PetstoreService/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace PetstoreService
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}

app.UseStaticFiles();
}
}
}
9 changes: 9 additions & 0 deletions demo/PetstoreService/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
8 changes: 8 additions & 0 deletions demo/PetstoreService/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
Loading

0 comments on commit 756e588

Please sign in to comment.