From 5b2b5bbab985143113f78b8fe27f62e2509d8ac4 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Sun, 20 Dec 2020 11:28:25 +0200 Subject: [PATCH] app & swagger fixes --- .../Properties/launchSettings.json | 19 ----------- .../Swagger/PathParamsOperationFilter.cs | 8 +++++ .../Swagger/SwaggerExtensions.cs | 32 ++----------------- IdentityServer.Api/appsettings.json | 2 +- 4 files changed, 11 insertions(+), 50 deletions(-) diff --git a/IdentityServer.Api/Properties/launchSettings.json b/IdentityServer.Api/Properties/launchSettings.json index aabc163..a86dcb0 100644 --- a/IdentityServer.Api/Properties/launchSettings.json +++ b/IdentityServer.Api/Properties/launchSettings.json @@ -1,26 +1,7 @@ { - "$schema": "http://json.schemastore.org/launchsettings.json", - "iisSettings": { - "windowsAuthentication": false, - "anonymousAuthentication": true, - "iisExpress": { - "applicationUrl": "http://localhost:53730", - "sslPort": 0 - } - }, "profiles": { - "IIS Express": { - "commandName": "IISExpress", - "launchBrowser": true, - "launchUrl": "weatherforecast", - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - } - }, "IdentityServer.Api": { "commandName": "Project", - "launchBrowser": true, - "launchUrl": "weatherforecast", "applicationUrl": "http://localhost:5000", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/IdentityServer.Api/Swagger/PathParamsOperationFilter.cs b/IdentityServer.Api/Swagger/PathParamsOperationFilter.cs index 884fffa..21bdeca 100644 --- a/IdentityServer.Api/Swagger/PathParamsOperationFilter.cs +++ b/IdentityServer.Api/Swagger/PathParamsOperationFilter.cs @@ -12,6 +12,14 @@ namespace IdentityServer.Api.Swagger { const string paramCaptureGroup = "param"; + foreach (var parameter in operation.Parameters.ToList()) + { + if (parameter.Name.ToLowerInvariant().StartsWith("metadata")) + { + operation.Parameters.Remove(parameter); + } + } + var openApiPathParameters = operation.Parameters.Where(param => param.In == ParameterLocation.Path).ToList(); var pathParamRegEx = $@"\{{(?<{paramCaptureGroup}>[^\}}]+)\}}"; diff --git a/IdentityServer.Api/Swagger/SwaggerExtensions.cs b/IdentityServer.Api/Swagger/SwaggerExtensions.cs index 52ec645..660cfbb 100644 --- a/IdentityServer.Api/Swagger/SwaggerExtensions.cs +++ b/IdentityServer.Api/Swagger/SwaggerExtensions.cs @@ -16,38 +16,10 @@ namespace IdentityServer.Api.Swagger c.SwaggerDoc("v1", new OpenApiInfo { - Title = "NetworkResurrector API", + Title = "Identity Server API", Version = "v1" }); - c.AddSecurityDefinition("Basic", - new OpenApiSecurityScheme - { - In = ParameterLocation.Header, - Description = @"JWT Authorization header using the Basic scheme. Enter 'Basic' [space] and then your token in the text input below. Example: 'Basic 12345abcdef'", - Name = "Authorization", - Scheme = "Basic", - Type = SecuritySchemeType.ApiKey - }); - - c.AddSecurityRequirement(new OpenApiSecurityRequirement() - { - { - new OpenApiSecurityScheme - { - Reference = new OpenApiReference - { - Type = ReferenceType.SecurityScheme, - Id = "Basic" - }, - Scheme = "Basic", - Name = "Authorization", - In = ParameterLocation.Header - }, - new List() - } - }); - c.OperationFilter(); c.SchemaFilter(); c.CustomSchemaIds(type => type.ToString()); @@ -74,7 +46,7 @@ namespace IdentityServer.Api.Swagger applicationBuilder.UseSwaggerUI(c => { - c.SwaggerEndpoint("v1/swagger.json", "Chatbot API"); + c.SwaggerEndpoint("v1/swagger.json", "IdentityServer API"); c.RoutePrefix = $"swagger"; }); diff --git a/IdentityServer.Api/appsettings.json b/IdentityServer.Api/appsettings.json index 2e73b4d..2b50dfe 100644 --- a/IdentityServer.Api/appsettings.json +++ b/IdentityServer.Api/appsettings.json @@ -1,5 +1,5 @@ { - "urls": "http://*:5062", + "urls": "http://*:5063", "ConnectionStrings": { "DatabaseConnection": "Server=***REMOVED***;Database=IdentityServer_dev;User Id=sa;Password=***REMOVED***;MultipleActiveResultSets=true" },