Closed ymg2006 closed 1 week ago
c# code to reproduce
public class CreateOrEditUnprocessedDto
{
[Required]
public TransactionTypeEnum Type { get; set; }
[Required]
public long FiscalYearId { get; set; }
}
public enum TransactionTypeEnum
{
Credit = 1,
Debit = 2
}
public async Task<bool> CreateOrEditAsync([FromForm] CreateOrEditUnprocessedDto input, CancellationToken cancellationToken = default)
{
return true;
}
Please provide an example of the C# code that produces the incorrect OpenAPI document. The more information we have, the easier you make it for people to fix issues, and do so accurately.
Please provide an example of the C# code the produces the incorrect OpenAPI document. The more information we have, the easier you make it for people to fix issues, and do so accurately.
I was making it, Should I make a full c# app for it or this examlpe is enough?
I tested it in the Basic Website ( This behaviour and it was working). I need to take a look at these. I will do asap
Please provide a configuration of your swagger config because I tested it here https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/test%2FSwashbuckle.AspNetCore.IntegrationTests%2FSwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Basic_DotNet_6.verified.txt#L668-L726
Which version of aspnetcore you are using also would be nice
Also does the representation of the OpenApi affect your tests using Swagger-ui?
Please provide a configuration of your swagger config because I tested it here https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/test%2FSwashbuckle.AspNetCore.IntegrationTests%2FSwaggerVerifyIntegrationTest.SwaggerEndpoint_ReturnsValidSwaggerJson_Basic_DotNet_6.verified.txt#L668-L726
Which version of aspnetcore you are using also would be nice
Also does the representation of the OpenApi affect your tests using Swagger-ui?
.net 8 services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo() { Title = "My API", Version = AppVersionHelper.Version }); });
Yes, there is no Type Enum at the swagger ui too.
Thank you very much for the issue!. In the PR I could see that the schema was OK for dotnet6, but nod for dotnet8 :(, due to the integration of the ApiDescription of aspnetcore
@martincostello can you please trigger release pipeline with that fix for nuget? 7.0.1 maybe?
@jgarciadelanoceda I am writing because this commit removed enums from FromForm. Here is simple example from v6.9.0 and 7.0.0 output: v7.0.0:;
createOrEdit(fiscalYearId: number): Observable;
I don't understand why Enum should be removed from required and moved to allOf, isn't it a type? can't enums be passed optional?
@martincostello why the contribution is not separated in multiple pullrequests?
"multipart/form-data": {
"schema": {
"allOf": [
{
"$ref": "#/components/schemas/TransactionTypeEnum"
},
{
"required": [
"FiscalYearId"
],
"type": "object",
"properties": {
"FiscalYearId": {
"type": "integer",
"format": "int64"
},
"Id": {
"type": "integer",
"format": "int64"
}
}
}
]
}
}
v6.9.0:"multipart/form-data": {
"schema": {
"required": [
"FiscalYearId",
"Type"
],
"type": "object",
"properties": {
"Type": {
"$ref": "#/components/schemas/TransactionTypeEnum"
},
"FiscalYearId": {
"type": "integer",
"format": "int64"
}
}
}
}
This makes nswag to remove Type enum from output api. createOrEdit(type?: TransactionTypeEnum | undefined, fiscalYearId: number): Observable