Meged swagger changes from server version

This commit is contained in:
Santhosh S 2023-09-03 18:56:01 -04:00
commit f5ae6a2f3f
11 changed files with 444 additions and 4 deletions

View File

@ -0,0 +1,50 @@
using DamageAssesment.Api.Answers.Db;
using DamageAssesment.Api.Answers.Interfaces;
using DamageAssesment.Api.Answers.Providers;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
//builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(c =>
{
// Include XML comments from your assembly
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
builder.Services.AddScoped<IAnswersProvider, AnswersProvider>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<AnswerDbContext>(option =>
{
option.UseInMemoryDatabase("Answers");
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/answers/swagger/v1/swagger.json","" );
});
}
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,53 @@
using DamageAssesment.Api.Attachments.Db;
using DamageAssesment.Api.Attachments.Interfaces;
using DamageAssesment.Api.Attachments.Providers;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.FileProviders;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
//builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(c =>
{
// Include XML comments from your assembly
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
builder.Services.AddScoped<IAttachmentsProvider, AttachmentsProvider>();
builder.Services.AddScoped<IUploadService, UploadService>();
builder.Services.AddScoped<IAzureBlobService,AzureBlobService>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<AttachmentsDbContext>(option =>
{
option.UseInMemoryDatabase("Attachments");
});
builder.Services.Configure<FormOptions>(o =>
{
o.ValueLengthLimit = int.MaxValue;
o.MultipartBodyLengthLimit = int.MaxValue;
o.MemoryBufferThreshold = int.MaxValue;
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(options => { options.SwaggerEndpoint("/attachments/swagger/v1/swagger.json", ""); });
}
app.UseAuthorization();
app.UseHttpsRedirection();
app.MapControllers();
app.UseStaticFiles();
app.Run();

View File

@ -0,0 +1,47 @@
using DamageAssesment.Api.Employees.Db;
using DamageAssesment.Api.Employees.Interfaces;
using DamageAssesment.Api.Employees.Providers;
using Microsoft.EntityFrameworkCore;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
//builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(c =>
{
// Include XML comments from your assembly
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
builder.Services.AddScoped<IEmployeesProvider, EmployeesProvider>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<EmployeeDbContext>(option =>
{
option.UseInMemoryDatabase("Employees");
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/employees/swagger/v1/swagger.json", "");
// options.RoutePrefix = ""; // Serve Swagger UI at the root URL
});
}
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -0,0 +1,100 @@
using DamageAssesment.Api.Locations.Interfaces;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace DamageAssesment.Api.Locations.Controllers
{
//[Route("api")]
[ApiController]
public class LocationsController : ControllerBase
{
private ILocationsProvider LocationProvider;
public LocationsController(ILocationsProvider LocationsProvider)
{
this.LocationProvider = LocationsProvider;
}
/// <summary>
/// Get all locations.
/// </summary>
[HttpGet("Locations")]
public async Task<ActionResult> GetLocationsAsync()
{
var result = await LocationProvider.GetLocationsAsync();
if (result.IsSuccess)
{
return Ok(result.locations);
}
return NotFound();
}
/// <summary>
/// Get all locations based on locationdId.
/// </summary>
[HttpGet("Locations/{id}")]
public async Task<ActionResult> GetLocationByIdAsync(string id)
{
var result = await LocationProvider.GetLocationByIdAsync(id);
if (result.IsSuccess)
{
return Ok(result.Location);
}
return NotFound();
}
/// <summary>
/// Update a Location.
/// </summary>
[HttpPut("Locations")]
public async Task<IActionResult> UpdateLocation(Models.Location Location)
{
if (Location != null)
{
var result = await this.LocationProvider.UpdateLocationAsync(Location);
if (result.IsSuccess)
{
return Ok(result.ErrorMessage);
}
return NotFound();
}
return NotFound();
}
/// <summary>
/// Save a new location.
/// </summary>
[HttpPost("Locations")]
public async Task<IActionResult> CreateLocation(Models.Location Location)
{
if (Location != null)
{
var result = await this.LocationProvider.PostLocationAsync(Location);
if (result.IsSuccess)
{
return Ok(result.Question);
}
return NotFound();
}
return CreatedAtRoute("DefaultApi", new { id = Location.Id }, Location);
}
/// <summary>
/// Delete an existing location.
/// </summary>
[HttpDelete("Locations/{id}")]
public async Task<IActionResult> DeleteLocation(string id)
{
var result = await this.LocationProvider.DeleteLocationAsync(id);
if (result.IsSuccess)
{
return Ok(result.ErrorMessage);
}
return NotFound();
}
}
}

View File

@ -0,0 +1,91 @@
using DamageAssesment.Api.Locations.Interfaces;
using Microsoft.AspNetCore.Mvc;
namespace DamageAssesment.Api.Locations.Controllers
{
//[Route("api/[controller]")]
[ApiController]
public class RegionsController : ControllerBase
{
private readonly IRegionsProvider regionProvider;
public RegionsController(IRegionsProvider regionProvider)
{
this.regionProvider = regionProvider;
}
/// <summary>
/// Get all regions.
/// </summary>
[HttpGet]
public async Task<ActionResult> GetRegionsAsync()
{
var result = await regionProvider.GetRegionsAsync();
if (result.IsSuccess)
{
return Ok(result.regions);
}
return NoContent();
}
/// <summary>
/// GET request for retrieving a region by its ID.
/// </summary>
[HttpGet("{Id}")]
public async Task<ActionResult> GetRegionAsync(string Id)
{
var result = await this.regionProvider.GetRegionByIdAsync(Id);
if (result.IsSuccess)
{
return Ok(result.Region);
}
return NotFound();
}
/// <summary>
/// POST request for creating a new region.
/// </summary>
[HttpPost]
public async Task<ActionResult> PostRegionAsync(Models.Region region)
{
var result = await this.regionProvider.PostRegionAsync(region);
if (result.IsSuccess)
{
return Ok(result.Region);
}
return BadRequest(result.ErrorMessage);
}
/// <summary>
/// PUT request for updating an existing region.
/// </summary>
[HttpPut]
public async Task<ActionResult> PutRegionAsync(Models.Region region)
{
var result = await this.regionProvider.PutRegionAsync(region);
if (result.IsSuccess)
{
return Ok(result.Region);
}
if (result.ErrorMessage.Equals("Not Found"))
return NotFound(result.ErrorMessage);
return BadRequest(result.ErrorMessage);
}
/// <summary>
/// DELETE request for deleting a region based on ID.
/// </summary>
[HttpDelete("{Id}")]
public async Task<ActionResult> DeleteRegionAsync(string Id)
{
var result = await this.regionProvider.DeleteRegionAsync(Id);
if (result.IsSuccess)
{
return Ok(result.Region);
}
return NotFound();
}
}
}

View File

@ -0,0 +1,45 @@
using DamageAssesment.Api.Locations.Db;
using DamageAssesment.Api.Locations.Interfaces;
using DamageAssesment.Api.Locations.Providers;
using Microsoft.EntityFrameworkCore;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
//builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGen(c =>
{
// Include XML comments from your assembly
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
builder.Services.AddScoped<ILocationsProvider, LocationsProvider>();
builder.Services.AddScoped<IRegionsProvider, RegionsProvider>();
builder.Services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies()); //4/30
builder.Services.AddDbContext<LocationDbContext>(option =>
{
option.UseInMemoryDatabase("Locations");
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/locations/swagger/v1/swagger.json", "");
});
}
app.UseAuthorization();
app.MapControllers();
app.Run();

View File

@ -36,7 +36,7 @@ var app = builder.Build();
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", ""); }); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/questions/swagger/v1/swagger.json", ""); });
} }
app.UseAuthorization(); app.UseAuthorization();

View File

@ -70,7 +70,7 @@ var app = builder.Build();
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", ""); }); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/surveyresponses/swagger/v1/swagger.json", ""); });
} }
app.UseAuthorization(); app.UseAuthorization();

View File

@ -53,7 +53,7 @@ var app = builder.Build();
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {
app.UseSwagger(); app.UseSwagger();
app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", ""); }); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/survey/swagger/v1/swagger.json", ""); });
} }
app.UseAuthentication(); app.UseAuthentication();

View File

@ -4,6 +4,12 @@
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<<<<<<<< HEAD:DamageAssesmentApi/DamageAssesment.Api.UsersAccess/DamageAssesment.Api.UsersAccess.csproj
========
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
>>>>>>>> origin/server-branch:DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -11,8 +17,12 @@
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.21" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" /> <PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
<<<<<<<< HEAD:DamageAssesmentApi/DamageAssesment.Api.UsersAccess/DamageAssesment.Api.UsersAccess.csproj
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.10" /> <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="7.0.10" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
========
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
>>>>>>>> origin/server-branch:DamageAssesmentApi/DamageAssesment.Api.Surveys/DamageAssesment.Api.Survey.csproj
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup> </ItemGroup>

View File

@ -13,6 +13,12 @@ services:
damageassesment.api.answers: damageassesment.api.answers:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
<<<<<<< HEAD
=======
networks:
nginx-network:
ipv4_address: 172.18.0.150
>>>>>>> origin/server-branch
ports: ports:
- "6001:80" - "6001:80"
@ -20,6 +26,12 @@ services:
damageassesment.api.attachments: damageassesment.api.attachments:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
<<<<<<< HEAD
=======
networks:
nginx-network:
ipv4_address: 172.18.0.151
>>>>>>> origin/server-branch
ports: ports:
- "6002:80" - "6002:80"
@ -27,24 +39,48 @@ services:
damageassesment.api.employees: damageassesment.api.employees:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
<<<<<<< HEAD
=======
networks:
nginx-network:
ipv4_address: 172.18.0.152
>>>>>>> origin/server-branch
ports: ports:
- "6003:80" - "6003:80"
damageassesment.api.locations: damageassesment.api.locations:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
<<<<<<< HEAD
=======
networks:
nginx-network:
ipv4_address: 172.18.0.153
>>>>>>> origin/server-branch
ports: ports:
- "6004:80" - "6004:80"
damageassesment.api.questions: damageassesment.api.questions:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
<<<<<<< HEAD
=======
networks:
nginx-network:
ipv4_address: 172.18.0.154
>>>>>>> origin/server-branch
ports: ports:
- "6005:80" - "6005:80"
damageassesment.api.survey: damageassesment.api.survey:
environment: environment:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
<<<<<<< HEAD
=======
networks:
nginx-network:
ipv4_address: 172.18.0.155
>>>>>>> origin/server-branch
ports: ports:
- "6006:80" - "6006:80"
@ -57,6 +93,14 @@ services:
- services__Employees=http://damageassesment.api.employees:80 - services__Employees=http://damageassesment.api.employees:80
- services__Attachments=http://damageassesment.api.attachments:80 - services__Attachments=http://damageassesment.api.attachments:80
- services__Surveys=http://damageassesment.api.survey:80 - services__Surveys=http://damageassesment.api.survey:80
<<<<<<< HEAD
ports: ports:
- "6007:80" - "6007:80"
=======
networks:
nginx-network:
ipv4_address: 172.18.0.156
ports:
- "6007:80"
>>>>>>> origin/server-branch