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: README.md
+35-4
Original file line number
Diff line number
Diff line change
@@ -1166,7 +1166,8 @@ services.AddSwaggerGen(c =>
1166
1166
});
1167
1167
```
1168
1168
1169
-
_NOTE:Ifyou're using the [Swashbuckle Annotations library](#swashbuckleaspnetcoreannotations), it contains a custom selector that'sbasedonthepresenceof `SwaggerSubType` attributesonbaseclassdefinitions. Thisway, youcanusesimpleattributestoexplicitlylisttheinheritanceand/orpolymorphismrelationshipsyouwanttoexpose. Toenablethisbehavior, checkoutthe [Annotationsdocs](#list-known-subtypes-for-inheritance-and-polymorphism)._
1169
+
> [!NOTE]
1170
+
>Ifyou're using the [Swashbuckle Annotations library](#swashbuckleaspnetcoreannotations), it contains a custom selector that'sbasedonthepresenceof `[JsonDerivedType]` (or `[SwaggerSubType]` for .NET6orearlier) attributesonbaseclassdefinitions. Thisway, youcanusesimpleattributestoexplicitlylisttheinheritanceand/orpolymorphismrelationshipsyouwanttoexpose. Toenablethisbehavior, checkoutthe [Annotationsdocs](#list-known-subtypes-for-inheritance-and-polymorphism).
1170
1171
1171
1172
#### Describing Discriminators ####
1172
1173
@@ -1232,7 +1233,8 @@ services.AddSwaggerGen(c =>
1232
1233
});
1233
1234
```
1234
1235
1235
-
_NOTE:Ifyou're using the [Swashbuckle Annotations library](#swashbuckleaspnetcoreannotations), it contains custom selector functions that are based on the presence of `SwaggerDiscriminator` and `SwaggerSubType` attributes on base class definitions. This way, you can use simple attributes to explicitly provide discriminator metadata. To enable this behavior, check out the [Annotations docs](#enrich-polymorphic-base-classes-with-discriminator-metadata)._
1236
+
> [!NOTE]
1237
+
>Ifyou're using the [Swashbuckle Annotations library](#swashbuckleaspnetcoreannotations), it contains custom selector functions that are based on the presence of `[JsonPolymorphic]` (or `[SwaggerDiscriminator]` for .NET 6 or earlier) and `[JsonDerivedType]` (or `[SwaggerSubType]` for .NET 6 or earlier) attributes on base class definitions. This way, you can use simple attributes to explicitly provide discriminator metadata. To enable this behavior, check out the [Annotations docs](#enrich-polymorphic-base-classes-with-discriminator-metadata).
### Enrich Polymorphic Base Classes with Discriminator Metadata ###
1551
1562
1552
-
Ifyou're using annotations to _explicitly_ indicate the "known" subtypes for a polymorphic base type, you can combine the `SwaggerDiscriminatorAttribute` with the `SwaggerSubTypeAttribute` to provide additional metadata about the "discriminator" property, which will then be incorporated into the generated schema definition:
1563
+
Ifyou're using annotations to _explicitly_ indicate the "known" subtypes for a polymorphic base type, you can combine the `JsonPolymorphicAttribute` with the `JsonDerivedTypeAttribute` to provide additional metadata about the "discriminator" property, which will then be incorporated into the generated schema definition:
0 commit comments