Delivery API nested property expansion and output limiting (#15124)

* V2 output expansion + field limiting incl. deprecation of V1 APIs

* Performance optimizations for Content and Block based property editors

* A little formatting

* Support API versioning in Delivery API endpoint matcher policy

* Add V2 "expand" and "fields" to Swagger docs

* Renamed route for "multiple items by ID"

* Review changes

* Update src/Umbraco.Cms.Api.Delivery/Controllers/Media/ByIdMediaApiController.cs

Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>

* Update src/Umbraco.Cms.Api.Delivery/Filters/SwaggerDocumentationFilterBase.cs

Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>

* Update src/Umbraco.Cms.Api.Delivery/Filters/SwaggerDocumentationFilterBase.cs

Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>

* Revert "Performance optimizations for Content and Block based property editors"

This reverts commit 0d5a57956b36e94ce951f1dad7a7f3f43eb1f60b.

* Introduce explicit API cache levels for property expansion

* Friendly handling of bad expand/fields parameters

---------

Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>
This commit is contained in:
Kenn Jacobsen
2023-11-14 11:16:12 +01:00
committed by GitHub
parent 16a27a4c52
commit 4d98937af9
34 changed files with 1366 additions and 481 deletions

View File

@@ -419,7 +419,7 @@ public static class StringExtensions
/// returns <see langword="false" />.
/// </returns>
public static bool IsNullOrWhiteSpace([NotNullWhen(false)] this string? value) => string.IsNullOrWhiteSpace(value);
[return: NotNullIfNotNull("defaultValue")]
public static string? IfNullOrWhiteSpace(this string? str, string? defaultValue) =>
str.IsNullOrWhiteSpace() ? defaultValue : str;
@@ -1557,4 +1557,9 @@ public static class StringExtensions
yield return sb.ToString();
}
// having benchmarked various solutions (incl. for/foreach, split and LINQ based ones),
// this is by far the fastest way to find string needles in a string haystack
public static int CountOccurrences(this string haystack, string needle)
=> haystack.Length - haystack.Replace(needle, string.Empty).Length;
}