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