private void VerifyCreateSelectParameter(IEdmElement edmElement, ODataContext context, string selectItemsText = null) { // Arrange & Act OpenApiParameter parameter; switch (edmElement) { case IEdmEntitySet entitySet: parameter = context.CreateSelect(entitySet); break; case IEdmSingleton singleton: parameter = context.CreateSelect(singleton); break; case IEdmNavigationProperty navigationProperty: parameter = context.CreateSelect(navigationProperty); break; default: return; } string itemsText = selectItemsText == null ? @"""type"": ""string""" : $@"{selectItemsText} ""type"": ""string"""; // Assert Assert.NotNull(parameter); string json = parameter.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0); string expected = $@"{{ ""name"": ""$select"", ""in"": ""query"", ""description"": ""Select properties to be returned"", ""style"": ""form"", ""explode"": false, ""schema"": {{ ""uniqueItems"": true, ""type"": ""array"", ""items"": {{ {itemsText} }} }} }}"; Assert.Equal(expected.ChangeLineBreaks(), json); }
public static OpenApiParameter CreateSelect(this ODataContext context, IEdmNavigationProperty navigationProperty) { Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(navigationProperty, nameof(navigationProperty)); return(context.CreateSelect(navigationProperty, navigationProperty.ToEntityType())); }
public static OpenApiParameter CreateSelect(this ODataContext context, IEdmSingleton singleton) { Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(singleton, nameof(singleton)); return(context.CreateSelect(singleton, singleton.EntityType())); }
public static OpenApiParameter CreateSelect(this ODataContext context, IEdmEntitySet entitySet) { Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(entitySet, nameof(entitySet)); return(context.CreateSelect(entitySet, entitySet.EntityType())); }
/// <summary> /// Create $select parameter for the <see cref="IEdmVocabularyAnnotatable"/>. /// </summary> /// <param name="context">The OData context.</param> /// <param name="target">The Edm target.</param> /// <param name="entityType">The Edm entity type.</param> /// <returns>The created <see cref="OpenApiParameter"/> or null.</returns> public static OpenApiParameter CreateSelect(this ODataContext context, IEdmVocabularyAnnotatable target, IEdmEntityType entityType) { // patchwork to avoid breaking changes return(context.CreateSelect(target, entityType as IEdmStructuredType)); }