Skip to content

Commit

Permalink
Merge pull request #24 from mkhrapunov/swagger
Browse files Browse the repository at this point in the history
Swagger
  • Loading branch information
danielgerlag authored Aug 27, 2020
2 parents fefd2f1 + 9856f21 commit ed270b3
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 2 deletions.
12 changes: 12 additions & 0 deletions docs/api-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [Activity Workers](#activity-api)
* [Custom Steps](#steps-api)
* [Diagnostics](#diagnostic-api)
* [Swagger documentation](#swagger-documentation)

Download the [Postman Collection](https://raw.githubusercontent.com/danielgerlag/conductor/master/docs/Conductor.postman_collection.json)

Expand Down Expand Up @@ -226,3 +227,14 @@ GET /api/step/<<id>>
```
GET /api/info
```


# Swagger Documentation

It is possible to discover and try out API with [Swagger](https://swagger.io/) in a browser `https://localhost:5001/swagger`.

![Swagger in browser](swagger_browser.png)

It’s also convenient to import a Postman collection as swagger json `https://localhost:5001/swagger/v1/swagger.json`.

![Import Posrmat collection](swagger_import.png)
Binary file added docs/swagger_browser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/swagger_import.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/Conductor/Conductor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.4.10" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" />
<PackageReference Include="WorkflowCore" Version="3.2.2" />
<PackageReference Include="WorkflowCore.Providers.Redis" Version="3.0.0" />
</ItemGroup>
Expand All @@ -38,4 +39,6 @@
<ProjectReference Include="..\Conductor.Storage\Conductor.Storage.csproj" />
</ItemGroup>

<ProjectExtensions><VisualStudio><UserProperties properties_4launchsettings_1json__JsonSchema="" /></VisualStudio></ProjectExtensions>

</Project>
2 changes: 1 addition & 1 deletion src/Conductor/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"Conductor": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/info",
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
Expand Down
18 changes: 17 additions & 1 deletion src/Conductor/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using Microsoft.IdentityModel.Tokens;
using Conductor.Auth;
using Conductor.Middleware;
using Microsoft.OpenApi.Models;

namespace Conductor
{
Expand Down Expand Up @@ -68,7 +69,16 @@ public void ConfigureServices(IServiceCollection services)
})
.AddNewtonsoftJson()
.SetCompatibilityVersion(CompatibilityVersion.Latest);


services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "Conductor API"
});
});

var authConfig = services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
Expand Down Expand Up @@ -132,6 +142,12 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApp
app.UseRouting();
//app.UseMvcWithDefaultRoute();

app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1");
});

app.UseCors(x => x
.AllowAnyOrigin()
.AllowAnyMethod()
Expand Down

0 comments on commit ed270b3

Please sign in to comment.