You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/openapi/include-metadata.md
+65
Original file line number
Diff line number
Diff line change
@@ -493,6 +493,8 @@ of the property in the schema.
493
493
494
494
### type and format
495
495
496
+
:::moniker range="< aspnetcore-10.0"
497
+
496
498
The JSON Schema library maps standard C# types to OpenAPI `type` and `format` as follows:
497
499
498
500
| C# Type | OpenAPI `type`| OpenAPI `format`|
@@ -520,6 +522,69 @@ Note that object and dynamic types have _no_ type defined in the OpenAPI because
520
522
521
523
The `type` and `format` can also be set with a [Schema Transformer](xref:fundamentals/openapi/customize-openapi#use-schema-transformers). For example, you may want the `format` of decimal types to be `decimal` instead of `double`.
522
524
525
+
:::moniker-end
526
+
527
+
:::moniker range=">= aspnetcore-10.0"
528
+
529
+
#### Numeric types
530
+
531
+
The JSON Schema library maps standard C# numeric types to OpenAPI `type` and `format` based on the
532
+
<xref:System.Text.Json.JsonSerializerOptions.NumberHandling> property of the <xref:System.Text.Json.JsonSerializerOptions>
533
+
used in the app. In ASP.NET Core Web API apps, the default value of this property is `JsonNumberHandling.AllowReadingFromString`.
534
+
535
+
When the <xref:System.Text.Json.JsonSerializerOptions.NumberHandling> property is set to `JsonNumberHandling.AllowReadingFromString`, the numeric types are mapped as follows:
536
+
537
+
| C# Type | OpenAPI `type`| OpenAPI `format`| Other assertions |
If the app is configured to produce OpenAPI 3.0 or OpenAPI v2 documents, where the `type` field cannot have an array value, the `type` field is dropped.
548
+
549
+
When the <xref:System.Text.Json.JsonSerializerOptions.NumberHandling> property is set to `JsonNumberHandling.Strict`, the numeric types are mapped as follows:
0 commit comments