diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/Startup.cs b/OpenAPI/LearningHub.Nhs.OpenApi/Startup.cs index 68981d05..b2948c8d 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi/Startup.cs +++ b/OpenAPI/LearningHub.Nhs.OpenApi/Startup.cs @@ -93,11 +93,16 @@ public void ConfigureServices(IServiceCollection services) services.AddMvc() .AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); + var swaggerTitle = this.Configuration["Swagger:Title"]; + var swaggerVersion = this.Configuration["Swagger:Version"]; + var swaggerDescription = $"A set of API endpoints for retrieving learning resource information from the Learning Hub learning platform. The [Learning Hub](https://learninghub.nhs.uk/) is a platform for hosting and sharing learning resources for health and social care provided by Technology Enhanced Learning (TEL) at NHS England. An application API key must be used to authorise calls to the API from external applications. To contact TEL to discuss connecting your external system to the Learning Hub, email england.tel@nhs.net.\n\n Build Number: {this.Configuration["Swagger:BuildNumber"]} \n\n"; + services.AddSwaggerGen( c => { // For docs see https://github.com/domaindrivendev/Swashbuckle.AspNetCore - c.SwaggerDoc("dev", new OpenApiInfo { Title = "LearningHub.NHS.OpenAPI", Version = "dev" }); + c.SwaggerDoc("dev", new OpenApiInfo { Title = swaggerTitle, Version = swaggerVersion, Description = swaggerDescription }); + c.CustomSchemaIds(type => type.FullName); c.AddSecurityDefinition( "ApiKey", @@ -220,12 +225,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseSwagger(); app.UseSwaggerUI(c => { - if (env.IsDevelopment()) - { - c.SwaggerEndpoint("/swagger/dev/swagger.json", "Auto-generated"); - } - - c.SwaggerEndpoint("/SwaggerDefinitions/v1.3.0.json", "v1.3.0"); + c.SwaggerEndpoint("/swagger/dev/swagger.json", "v1.4.0"); c.OAuthClientId(this.Configuration.GetValue("LearningHubAuthServiceConfig:ClientId")); c.OAuthClientSecret(this.Configuration.GetValue("LearningHubAuthServiceConfig:ClientSecret")); c.OAuthScopes(this.Configuration.GetValue("LearningHubAuthServiceConfig:Scopes")); diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/SwaggerDefinitions/v1.3.0.json b/OpenAPI/LearningHub.Nhs.OpenApi/SwaggerDefinitions/v1.3.0.json index d0fa21e8..1fd6fa2d 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi/SwaggerDefinitions/v1.3.0.json +++ b/OpenAPI/LearningHub.Nhs.OpenApi/SwaggerDefinitions/v1.3.0.json @@ -3,7 +3,7 @@ "info": { "title": "LearningHub.NHS.OpenAPI", "version": "1.3.0", - "description": "A set of API endpoints for retrieving learning resource information from the Learning Hub learning platform. The [Learning Hub](https://learninghub.nhs.uk/) is a platform for hosting and sharing learning resources for health and social care provided by Technology Enhanced Learning (TEL) at NHS England. An application API key must be used to authorise calls to the API from external applications. To contact TEL to discuss connecting your external system to the Learning Hub, email england.tel@nhs.net. \n\n**Build Number:** __BUILD_NUMBER__\n\n" + "description": "A set of API endpoints for retrieving learning resource information from the Learning Hub learning platform. The [Learning Hub](https://learninghub.nhs.uk/) is a platform for hosting and sharing learning resources for health and social care provided by Technology Enhanced Learning (TEL) at NHS England. An application API key must be used to authorise calls to the API from external applications. To contact TEL to discuss connecting your external system to the Learning Hub, email england.tel@nhs.net." }, "paths": { "/Bookmark/GetAllByParent": { diff --git a/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.json b/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.json index 155a27dd..dfaaafa6 100644 --- a/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.json +++ b/OpenAPI/LearningHub.Nhs.OpenApi/appsettings.json @@ -7,6 +7,11 @@ "Microsoft.Hosting.Lifetime": "Information" } }, + "Swagger": { + "Title": "Swagger XML DOC LearningHub.NHS.OpenAPI", + "Version": "v4.1.0", + "BuildNumber": "" + }, "AllowedHosts": "*", "ConnectionStrings": { "ElfhHubDbConnection": "",