add more terms and types in capabilities

This commit is contained in:
Sam Xu 2019-04-11 16:32:21 -07:00
parent 25c65a1191
commit cf8fb692e6
17 changed files with 545 additions and 1 deletions

View file

@ -115,14 +115,49 @@ namespace Microsoft.OpenApi.OData.Capabilities
/// </summary>
InsertRestrictions,
/// <summary>
/// Deep Insert Support of the annotated resource (the whole service, an entity set, or a collection-valued resource
/// </summary>
DeepInsertSupport,
/// <summary>
/// Restrictions on update operations
/// </summary>
UpdateRestrictions,
/// <summary>
/// Deep Update Support of the annotated resource (the whole service, an entity set, or a collection-valued resource)
/// </summary>
DeepUpdateSupported,
/// <summary>
/// Restrictions on delete operations
/// </summary>
DeleteRestrictions,
/// <summary>
/// Describes restrictions on operations applied to collection-valued structural properties.
/// </summary>
CollectionPropertyRestrictions,
/// <summary>
/// Restrictions for function or action operation.
/// </summary>
OperationRestrictions,
/// <summary>
/// Restrictions for retrieving a collection of entities, retrieving a singleton instance, invoking a function
/// </summary>
ReadRestrictions,
/// <summary>
/// Custom headers that are supported/required for the annotated resource
/// </summary>
CustomHeaders,
/// <summary>
/// Custom query options that are supported/required for the annotated resource
/// </summary>
CustomQueryOptions
}
}

View file

@ -0,0 +1,94 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
namespace Microsoft.OpenApi.OData.Capabilities
{
/// <summary>
/// Org.OData.Capabilities.V1.CollectionPropertyRestrictions
/// </summary>
internal class CollectionPropertyRestrictions : CapabilitiesRestrictions
{
/// <summary>
/// The Term type kind.
/// </summary>
public override CapabilitesTermKind Kind => CapabilitesTermKind.CollectionPropertyRestrictions;
/// <summary>
/// Gets the Restricted Collection-valued property.
/// </summary>
public string CollectionProperty { get; private set; }
/// <summary>
/// Gets the List of functions and operators supported in filter expressions..
/// </summary>
public IList<string> FilterFunctions { get; private set; }
/// <summary>
/// Gets Restrictions on filter expressions.
/// </summary>
public FilterRestrictions FilterRestrictions { get; private set; }
/// <summary>
/// Gets Restrictions on search expressions.
/// </summary>
public SearchRestrictions SearchRestrictions { get; private set; }
/// <summary>
/// Gets Restrictions on orderby expressions.
/// </summary>
public SortRestrictions SortRestrictions { get; private set; }
/// <summary>
/// Gets Supports $top.
/// </summary>
public bool? TopSupported { get; private set; }
/// <summary>
/// Gets Supports $skip.
/// </summary>
public bool? SkipSupported { get; private set; }
/// <summary>
/// Gets Support for $select.
/// </summary>
public SelectSupportType SelectSupport { get; private set; }
/// <summary>
/// Gets the collection supports positional inserts.
/// </summary>
public bool? Insertable { get; private set; }
/// <summary>
/// Gets the Members of this ordered collection can be updated by ordinal.
/// </summary>
public bool? Updatable { get; private set; }
/// <summary>
/// Gets the Members of this ordered collection can be deleted by ordinal.
/// </summary>
public bool? Deletable { get; private set; }
protected override bool Initialize(IEdmVocabularyAnnotation annotation)
{
if (annotation == null ||
annotation.Value == null ||
annotation.Value.ExpressionKind != EdmExpressionKind.Record)
{
return false;
}
IEdmRecordExpression record = (IEdmRecordExpression)annotation.Value;
// Deletable
Deletable = record.GetBoolean("Deletable");
return true;
}
}
}

View file

@ -0,0 +1,31 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.OData.Edm.Vocabularies;
namespace Microsoft.OpenApi.OData.Capabilities
{
/// <summary>
/// Term: Org.OData.Capabilities.V1.CustomHeaders
/// </summary>
internal class CustomHeaders : CapabilitiesRestrictions
{
/// <summary>
/// The Term type kind.
/// </summary>
public override CapabilitesTermKind Kind => CapabilitesTermKind.CustomHeaders;
/// <summary>
/// Collection(Capabilities.CustomParameter)
/// </summary>
public IList<CustomParameter> Parameters { get; private set; }
protected override bool Initialize(IEdmVocabularyAnnotation annotation)
{
throw new System.NotImplementedException();
}
}
}

View file

@ -0,0 +1,31 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.OData.Edm.Vocabularies;
namespace Microsoft.OpenApi.OData.Capabilities
{
/// <summary>
/// Term: Org.OData.Capabilities.V1.CustomQueryOptions
/// </summary>
internal class CustomQueryOptions : CapabilitiesRestrictions
{
/// <summary>
/// The Term type kind.
/// </summary>
public override CapabilitesTermKind Kind => CapabilitesTermKind.CustomQueryOptions;
/// <summary>
/// Collection(Capabilities.CustomParameter)
/// </summary>
public IList<CustomParameter> Parameters { get; private set; }
protected override bool Initialize(IEdmVocabularyAnnotation annotation)
{
throw new System.NotImplementedException();
}
}
}

View file

@ -0,0 +1,46 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
namespace Microsoft.OpenApi.OData.Capabilities
{
/// <summary>
/// Org.OData.Capabilities.V1.DeepInsertSupport
/// </summary>
internal class DeepInsertSupported : SupportedRestrictions
{
/// <summary>
/// The Term type kind.
/// </summary>
public override CapabilitesTermKind Kind => CapabilitesTermKind.DeepInsertSupport;
/// <summary>
/// Gets Annotation target supports accepting and returning nested entities annotated with the `Core.ContentID` instance annotation.
/// </summary>
public bool? ContentIDSupported { get; private set; }
protected override bool Initialize(IEdmVocabularyAnnotation annotation)
{
if (annotation == null ||
annotation.Value == null ||
annotation.Value.ExpressionKind != EdmExpressionKind.Record)
{
return false;
}
IEdmRecordExpression record = (IEdmRecordExpression)annotation.Value;
// Supported
Supported = record.GetBoolean("Supported");
// NonInsertableNavigationProperties
ContentIDSupported = record.GetBoolean("ContentIDSupported");
return true;
}
}
}

View file

@ -0,0 +1,46 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
namespace Microsoft.OpenApi.OData.Capabilities
{
/// <summary>
/// Org.OData.Capabilities.V1.DeepUpdateSupported
/// </summary>
internal class DeepUpdateSupported : SupportedRestrictions
{
/// <summary>
/// The Term type kind.
/// </summary>
public override CapabilitesTermKind Kind => CapabilitesTermKind.DeepUpdateSupported;
/// <summary>
/// Gets Annotation target supports accepting and returning nested entities annotated with the `Core.ContentID` instance annotation.
/// </summary>
public bool? ContentIDSupported { get; private set; }
protected override bool Initialize(IEdmVocabularyAnnotation annotation)
{
if (annotation == null ||
annotation.Value == null ||
annotation.Value.ExpressionKind != EdmExpressionKind.Record)
{
return false;
}
IEdmRecordExpression record = (IEdmRecordExpression)annotation.Value;
// Supported
Supported = record.GetBoolean("Supported");
// NonInsertableNavigationProperties
ContentIDSupported = record.GetBoolean("ContentIDSupported");
return true;
}
}
}

View file

@ -30,6 +30,26 @@ namespace Microsoft.OpenApi.OData.Capabilities
/// </summary>
public IList<string> NonDeletableNavigationProperties { get; private set; }
/// <summary>
/// Gets the maximum number of navigation properties that can be traversed.
/// </summary>
public int? MaxLevels { get; private set; }
/// <summary>
/// Gets the required scopes to perform the insert.
/// </summary>
public PermissionType Permission { get; private set; }
/// <summary>
/// Gets the Support for query options with insert requests.
/// </summary>
public ModificationQueryOptionsType QueryOptions { get; private set; }
/// <summary>
/// Gets the Supported or required custom headers.
/// </summary>
public IList<CustomParameter> CustomHeaders { get; private set; }
/// <summary>
/// Test the target supports delete.
/// </summary>

View file

@ -30,6 +30,11 @@ namespace Microsoft.OpenApi.OData.Capabilities
/// </summary>
public IList<string> NonExpandableProperties { get; private set; }
/// <summary>
/// Gets the maximum number of levels that can be expanded in a expand expression.
/// </summary>
public int? MaxLevles { get; private set; }
/// <summary>
/// Test the target supports $expand.
/// </summary>

View file

@ -25,11 +25,41 @@ namespace Microsoft.OpenApi.OData.Capabilities
/// </summary>
public bool? Insertable { get; private set; }
/// <summary>
/// Gets the structural properties cannot be specified on insert.
/// </summary>
public IList<string> NonInsertableProperties { get; private set; }
/// <summary>
/// Gets the navigation properties which do not allow deep inserts.
/// </summary>
public IList<string> NonInsertableNavigationProperties { get; private set; }
/// <summary>
/// Gets the maximum number of navigation properties that can be traversed.
/// </summary>
public int? MaxLevels { get; private set; }
/// <summary>
/// Gets the required scopes to perform the insert.
/// </summary>
public PermissionType Permission { get; private set; }
/// <summary>
/// Gets the Support for query options with insert requests.
/// </summary>
public ModificationQueryOptionsType QueryOptions { get; private set; }
/// <summary>
/// Gets the Supported or required custom headers.
/// </summary>
public IList<CustomParameter> CustomHeaders { get; private set; }
/// <summary>
/// Gets the Supported or required custom query options.
/// </summary>
public IList<CustomParameter> CustomQueryOptions { get; private set; }
/// <summary>
/// Test the target supports insert.
/// </summary>

View file

@ -0,0 +1,52 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
namespace Microsoft.OpenApi.OData.Capabilities
{
/// <summary>
/// Org.OData.Capabilities.V1.OperationRestrictions
/// </summary>
internal class OperationRestrictions : CapabilitiesRestrictions
{
/// <summary>
/// The Term type name.
/// </summary>
public override CapabilitesTermKind Kind => CapabilitesTermKind.OperationRestrictions;
/// <summary>
/// Gets the List of required scopes to invoke an action or function.
/// </summary>
public PermissionType Permission { get; private set; }
/// <summary>
/// Gets the Supported or required custom headers.
/// </summary>
public IList<CustomParameter> CustomHeaders { get; private set; }
/// <summary>
/// Gets the Supported or required custom query options.
/// </summary>
public IList<CustomParameter> CustomQueryOptions { get; private set; }
protected override bool Initialize(IEdmVocabularyAnnotation annotation)
{
if (annotation == null ||
annotation.Value == null ||
annotation.Value.ExpressionKind != EdmExpressionKind.Record)
{
return false;
}
IEdmRecordExpression record = (IEdmRecordExpression)annotation.Value;
return true;
}
}
}

View file

@ -0,0 +1,58 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
namespace Microsoft.OpenApi.OData.Capabilities
{
/// <summary>
/// Complex type: Org.OData.Capabilities.V1.SelectSupportType
/// </summary>
internal class SelectSupportType
{
/// <summary>
/// Gets the Supports $select.
/// </summary>
public bool? Supported { get; private set; }
/// <summary>
/// Gets the $expand within $select is supported.
/// </summary>
public bool? Expandable { get; private set; }
/// <summary>
/// Gets the $filter within $select is supported.
/// </summary>
public bool? Filterable { get; private set; }
/// <summary>
/// Gets the $search within $select is supported.
/// </summary>
public bool? Searchable { get; private set; }
/// <summary>
/// Gets the $top within $select is supported.
/// </summary>
public bool? TopSupported { get; private set; }
/// <summary>
/// Gets the $skip within $select is supported.
/// </summary>
public bool? SkipSupported { get; private set; }
/// <summary>
/// Gets the $compute within $select is supported.
/// </summary>
public bool? ComputeSupported { get; private set; }
/// <summary>
/// Gets the $count within $select is supported.
/// </summary>
public bool? Countable { get; private set; }
/// <summary>
/// Gets the orderby within $select is supported.
/// </summary>
public bool? Sortable { get; private set; }
}
}

View file

@ -0,0 +1,96 @@
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using System.Collections.Generic;
using Microsoft.OData.Edm;
using Microsoft.OData.Edm.Vocabularies;
namespace Microsoft.OpenApi.OData.Capabilities
{
internal abstract class ReadRestrictionsBase
{
/// <summary>
/// Get the Entities can be retrieved.
/// </summary>
public bool? Readable { get; private set; }
/// <summary>
/// Gets the List of required scopes to invoke an action or function
/// </summary>
public PermissionType Permission { get; private set; }
/// <summary>
/// Gets the Supported or required custom headers.
/// </summary>
public IList<CustomParameter> CustomHeaders { get; private set; }
/// <summary>
/// Gets the Supported or required custom query options.
/// </summary>
public IList<CustomParameter> CustomQueryOptions { get; private set; }
}
/// <summary>
/// Restrictions for retrieving an entity by key
/// </summary>
internal class ReadByKeyRestrictionsType : ReadRestrictionsBase
{
}
/// <summary>
/// Restrictions for retrieving an entity by key
/// </summary>
internal class ReadRestrictionsType : ReadRestrictionsBase
{
/// <summary>
/// Gets the Restrictions for retrieving an entity by key.
/// Only valid when applied to a collection. If a property of `ReadByKeyRestrictions`
/// is not specified, the corresponding property value of `ReadRestrictions` applies.
/// </summary>
public ReadByKeyRestrictionsType ReadByKeyRestrictions { get; private set; }
}
/// <summary>
/// Org.OData.Capabilities.V1.ReadRestrictions
/// </summary>
internal class ReadRestrictions : CapabilitiesRestrictions
{
/// <summary>
/// The Term type name.
/// </summary>
public override CapabilitesTermKind Kind => CapabilitesTermKind.ReadRestrictions;
/// <summary>
/// Gets the List of required scopes to invoke an action or function.
/// </summary>
public PermissionType Permission { get; private set; }
/// <summary>
/// Gets the Supported or required custom headers.
/// </summary>
public IList<CustomParameter> CustomHeaders { get; private set; }
/// <summary>
/// Gets the Supported or required custom query options.
/// </summary>
public IList<CustomParameter> CustomQueryOptions { get; private set; }
protected override bool Initialize(IEdmVocabularyAnnotation annotation)
{
if (annotation == null ||
annotation.Value == null ||
annotation.Value.ExpressionKind != EdmExpressionKind.Record)
{
return false;
}
IEdmRecordExpression record = (IEdmRecordExpression)annotation.Value;
return true;
}
}
}

View file

@ -16,7 +16,7 @@ namespace Microsoft.OpenApi.OData.Capabilities
/// <summary>
/// Get the Supported boolean value.
/// </summary>
public bool? Supported { get; private set; }
public bool? Supported { get; protected set; }
/// <summary>
/// Test the target supports the corresponding restriction.