Skip to content

Commit fa574e1

Browse files
committed
Clean up moniker hell
1 parent 65223e4 commit fa574e1

File tree

2 files changed

+589
-25
lines changed

2 files changed

+589
-25
lines changed

aspnetcore/fundamentals/openapi/include-metadata.md

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,6 @@ app.MapGet("/todos",
314314
async (TodoDb db) => await db.Todos.ToListAsync());
315315
```
316316

317-
:::moniker range=">= aspnetcore-10.0"
318-
319317
[`[ProducesResponseType]`](xref:Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute), [`[Produces]`](xref:Microsoft.AspNetCore.Mvc.ProducesAttribute), and [`[ProducesDefaultResponseType]`](xref:Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute) also support an optional string property called `Description` that can be used to describe the response. This is useful for explaining why or when clients can expect a specific response:
320318

321319
```csharp
@@ -327,8 +325,6 @@ app.MapGet("/todos/{id}",
327325
async (int id, TodoDb db) => /* Code here */);
328326
```
329327

330-
:::moniker-end
331-
332328
Using <xref:Microsoft.AspNetCore.Http.TypedResults> in the implementation of an endpoint's route handler automatically includes the response type metadata for the endpoint. For example, the following code automatically annotates the endpoint with a response under the `200` status code with an `application/json` content type.
333329

334330
```csharp
@@ -398,8 +394,6 @@ Only one [`[Produces]`](xref:Microsoft.AspNetCore.Mvc.ProducesAttribute) or <xre
398394

399395
All of the above attributes can be applied to individual action methods or to the controller class where it applies to all action methods in the controller.
400396

401-
:::moniker range=">= aspnetcore-10.0"
402-
403397
[`[ProducesResponseType]`](xref:Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute), [`[Produces]`](xref:Microsoft.AspNetCore.Mvc.ProducesAttribute), and [`[ProducesDefaultResponseType]`](xref:Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute) also support an optional string property called `Description` that can be used to describe the response. This is useful for explaining why or when clients can expect a specific response:
404398

405399
```csharp
@@ -412,8 +406,6 @@ All of the above attributes can be applied to individual action methods or to th
412406
public async Task<ActionResult<Todo>> GetTodoItem(string id, Todo todo)
413407
```
414408

415-
:::moniker-end
416-
417409
When not specified by an attribute:
418410

419411
* The status code for the response defaults to 200.
@@ -493,8 +485,6 @@ of the property in the schema.
493485

494486
### type and format
495487

496-
:::moniker range="< aspnetcore-10.0"
497-
498488
The JSON Schema library maps standard C# types to OpenAPI `type` and `format` as follows:
499489

500490
| C# Type | OpenAPI `type` | OpenAPI `format` |
@@ -522,10 +512,6 @@ Note that object and dynamic types have _no_ type defined in the OpenAPI because
522512

523513
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`.
524514

525-
:::moniker-end
526-
527-
:::moniker range=">= aspnetcore-10.0"
528-
529515
#### Numeric types
530516

531517
The JSON Schema library maps standard C# numeric types to OpenAPI `type` and `format` based on the
@@ -593,8 +579,6 @@ Other C# types are represented in the generated OpenAPI document as shown in the
593579
| object | _omitted_ | |
594580
| dynamic | _omitted_ | |
595581

596-
:::moniker-end
597-
598582
### Use attributes to add metadata
599583

600584
ASP.NET uses metadata from attributes on class or record properties to set metadata on the corresponding properties of the generated schema.
@@ -675,13 +659,6 @@ An enum type without a [`[JsonConverter]`](xref:System.Text.Json.Serialization.
675659

676660
#### nullable
677661

678-
:::moniker range="< aspnetcore-10.0"
679-
680-
Properties defined as a nullable value or reference type have `nullable: true` in the generated schema. This is consistent with the default behavior of the <xref:System.Text.Json> deserializer, which accepts `null` as a valid value for a nullable property.
681-
682-
:::moniker-end
683-
:::moniker range=">= aspnetcore-10.0"
684-
685662
Properties defined as a nullable value or reference type appear in the generated schema with a `type` keyword whose value is an array that includes `null` as one of the types. This is consistent with the default behavior of the <xref:System.Text.Json> deserializer, which accepts `null` as a valid value for a nullable property.
686663

687664
For example, a C# property defined as `string?` is represented in the generated schema as:
@@ -698,8 +675,6 @@ For example, a C# property defined as `string?` is represented in the generated
698675

699676
If the app is configured to produce OpenAPI v3.0 or OpenAPI v2 documents, nullable value or reference types have `nullable: true` in the generated schema because these OpenAPI versions do not allow the `type` field to be an array.
700677

701-
:::moniker-end
702-
703678
#### additionalProperties
704679

705680
Schemas are generated without an `additionalProperties` assertion by default, which implies the default of `true`. This is consistent with the default behavior of the <xref:System.Text.Json> deserializer, which silently ignores additional properties in a JSON object.
@@ -722,3 +697,7 @@ A schema transformer can be used to override any default metadata or add additio
722697

723698
* <xref:fundamentals/openapi/using-openapi-documents>
724699
* [OpenAPI specification](https://spec.openapis.org/oas/v3.0.3)
700+
701+
:::moniker-end
702+
703+
[!INCLUDE[](~\fundamentals\openapi\includes\include-metadata9.md)]

0 commit comments

Comments
 (0)