Elykx
Elykx
CC#
Created by Elykx on 10/10/2024 in #help
Can't override OpenApiSchema
Hello devs, Someone can tell me what is wrong in this code:
.WithOpenApi(
opts =>
{
OpenApiParameter? sourcesParameter = opts.Parameters[0];
sourcesParameter.Description = "Sources";
sourcesParameter.Schema = new()
{
Type = "array",
Items = new OpenApiSchema
{
Type = "string",
Enum = new List<IOpenApiAny>()
{
new OpenApiString("value1"),
new OpenApiString("value2")
}
}
};

return opts;
}
.WithOpenApi(
opts =>
{
OpenApiParameter? sourcesParameter = opts.Parameters[0];
sourcesParameter.Description = "Sources";
sourcesParameter.Schema = new()
{
Type = "array",
Items = new OpenApiSchema
{
Type = "string",
Enum = new List<IOpenApiAny>()
{
new OpenApiString("value1"),
new OpenApiString("value2")
}
}
};

return opts;
}
It seems that i can't override the Schema property in my OpenApi documentation. In debug, the property is correctly overriden, but in my swagger.json, it is not displayed
1 replies
CC#
Created by Elykx on 9/1/2023 in #help
❔ How to implement integration test asp.net with .net 7 using client certificates ?
When i try to create an httpclient custom in a WebApplicationFactory, the test server is not running
builder.ConfigureTestServices(services =>
{
services
.AddHttpClient("client-with-certificate", client =>
{
client.BaseAddress = new Uri("https://localhost");
})
.ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler();
handler.ClientCertificates.Add(clientCertificate);
return handler;
});
});
builder.ConfigureTestServices(services =>
{
services
.AddHttpClient("client-with-certificate", client =>
{
client.BaseAddress = new Uri("https://localhost");
})
.ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler();
handler.ClientCertificates.Add(clientCertificate);
return handler;
});
});
2 replies