build : cambio de OpenApi nativo a Swashbuckle para tener un mejor schema openapi.
This commit is contained in:
parent
3591ba2015
commit
572547b356
|
|
@ -17,7 +17,8 @@ public class InvoicesController : ControllerBase
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(typeof(List<InvoiceDto>), StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<ActionResult<List<InvoiceDto>>> GetInvoices(
|
public async Task<ActionResult<List<InvoiceDto>>> GetInvoices(
|
||||||
[FromQuery] int limit = 50,
|
[FromQuery] int limit = 50,
|
||||||
[FromQuery] [Range(1, int.MaxValue)] int page = 1,
|
[FromQuery] [Range(1, int.MaxValue)] int page = 1,
|
||||||
|
|
@ -28,8 +29,9 @@ public class InvoicesController : ControllerBase
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id:int}")]
|
[HttpGet("{id:int}")]
|
||||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
[ProducesResponseType(typeof(InvoiceDetailDto), StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
|
||||||
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)]
|
||||||
public async Task<ActionResult<InvoiceDetailDto>> GetInvoice(int id)
|
public async Task<ActionResult<InvoiceDetailDto>> GetInvoice(int id)
|
||||||
{
|
{
|
||||||
var invoice = await _dolibarrClient.GetInvoiceAsync(id);
|
var invoice = await _dolibarrClient.GetInvoiceAsync(id);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
|
||||||
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,9 @@ builder.Services.AddControllers()
|
||||||
// Usar camelCase para propiedades (id en vez de Id)
|
// Usar camelCase para propiedades (id en vez de Id)
|
||||||
options.JsonSerializerOptions.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;
|
options.JsonSerializerOptions.PropertyNamingPolicy = System.Text.Json.JsonNamingPolicy.CamelCase;
|
||||||
});
|
});
|
||||||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
// Swagger/OpenAPI con Swashbuckle (genera schemas completos)
|
||||||
builder.Services.AddOpenApi();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
|
builder.Services.AddSwaggerGen();
|
||||||
|
|
||||||
|
|
||||||
// Typed Client - Inyecta HttpClient directamente en DolibarrApiClient
|
// Typed Client - Inyecta HttpClient directamente en DolibarrApiClient
|
||||||
|
|
@ -106,7 +107,11 @@ app.UseExceptionHandler(errorApp =>
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.MapOpenApi();
|
app.UseSwagger();
|
||||||
|
app.UseSwaggerUI(options =>
|
||||||
|
{
|
||||||
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "DoliMiddlewareApi v1");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue