diff --git a/docs/migrating-to-v10.md b/docs/migrating-to-v10.md index 3ba302518a..c7ad61af54 100644 --- a/docs/migrating-to-v10.md +++ b/docs/migrating-to-v10.md @@ -73,7 +73,18 @@ Migrating to Swashbuckle.AspNetCore v10+ will likely involve changes in the foll - Update any NuGet package references for Swashbuckle.AspNetCore and Microsoft.OpenApi to v10.0.0+ and v2.3.0+ respectively. - Update any `using` directives that reference types from the `Microsoft.OpenApi.Models` namespace to use the new namespace `Microsoft.OpenApi`. -- Update model references (e.g. `OpenApiSchema`) to use the new interfaces (e.g. `IOpenApiSchema`) and the relevant concrete types to mutate them (e.g. `OpenApiSchema`). +- Update model references (e.g. `OpenApiSchema`) to use the new interfaces (e.g. `IOpenApiSchema`) and use the relevant concrete types to mutate them (e.g. `OpenApiSchema`). An example of this is shown below for an `ISchemaFilter` implementation: + + ```csharp + public void Apply(IOpenApiSchema schema, SchemaFilterContext context) + { + if (schema is OpenApiSchema openApiSchema) + { + // The properties are only mutable on the concrete type + openApiSchema.Type = JsonSchemaType.String; + } + } + ``` - Update any use of `.Reference` properties (e.g. `OpenApiSchema.ReferenceV3`) to use the new `*Reference` class instead (e.g. `OpenApiSchemaReference`). - Replace usage of the `OpenApiSchema.Type` property using a string (e.g. `"string"` or `"boolean"`) with the `JsonSchemaType` flags enumeration. - Replace usage of the `OpenApiSchema.Nullable` property by OR-ing the `JsonSchemaType.Null` value to `OpenApiSchema.Type` (e.g. `schema.Type |= JsonSchemaType.Null;`).