-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
use one of behind a flag instead for nullable enums #3428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3428 +/- ##
==========================================
+ Coverage 94.28% 94.32% +0.04%
==========================================
Files 109 109
Lines 3728 3756 +28
Branches 707 719 +12
==========================================
+ Hits 3515 3543 +28
Misses 213 213
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/Swashbuckle.AspNetCore.SwaggerGen/DependencyInjection/SwaggerGenOptionsExtensions.cs
Outdated
Show resolved
Hide resolved
src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs
Outdated
Show resolved
Hide resolved
src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGenerator.cs
Outdated
Show resolved
Hide resolved
src/Swashbuckle.AspNetCore.SwaggerGen/SchemaGenerator/SchemaGeneratorOptions.cs
Outdated
Show resolved
Hide resolved
test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs
Outdated
Show resolved
Hide resolved
test/Swashbuckle.AspNetCore.Newtonsoft.Test/SchemaGenerator/NewtonsoftSchemaGeneratorTests.cs
Outdated
Show resolved
Hide resolved
...Swashbuckle.AspNetCore.SwaggerGen.Test/SchemaGenerator/JsonSerializerSchemaGeneratorTests.cs
Show resolved
Hide resolved
Can you bump this to
|
@captainsafia Any thoughts on this change, as I imagine null handling has come up in the OpenAPI work for .NET 10? As the original change caused unintended issues this PR is aiming to make opt-in to resolve them, I'd like to make sure we're doing it right this time around 😅. |
1fc0b3a
to
6b63720
Compare
@ItsVeryWindy The original change has been manually reverted in #3436 so I can push out a new patch release - you'll need to merge with the default branch and restore the relevant changes in this PR for 8.2.0. |
My updated thinking here is:
|
9c9568b
to
df2027d
Compare
df2027d
to
a1e89ed
Compare
Now that it's opt-in I'm kinda OK with this change, but I'd like a second opinion first: #3428 (comment) |
Pull Request
The issue or feature being addressed
Fixes #3225.
Details on the issue fix or feature implementation
This changes how the nullable enums work so that instead of creating a reference to a separate type, it uses one of with a reference and a null enum. This is behind a flag
UseOneOfForNullableEnums
which defaults to off.Also for non body parameters it will always default to non nullable as there is no way of specifying a nullable parameter.
I've extended the snapshot tests to include more nullable examples. This did uncover another example where if the enum itself is the body of the request it should be marked as nullable.
At the moment I've left inline enums to include null, I'm not sure if this should also behind a flag.