From 77e094a043a6a059244f6fd07a69ce813fc87d50 Mon Sep 17 00:00:00 2001 From: Sam Xu Date: Thu, 14 Nov 2024 21:15:38 -0800 Subject: [PATCH] fixes #46: sync vocabularies folder using the updated OData.Edm; Support the Edm.Geometry; Enable the T4 on .NET 8 platform using command line --- .../Microsoft.OData.ModelBuilder.csproj | 17 +- .../Microsoft.OData.ModelBuilder.xml | 530 ++++++++++++++++-- .../V1/DeleteRestrictionsConfiguration.cs | 39 +- .../V1/ExpandRestrictionsConfiguration.cs | 2 +- .../V1/HttpResponseConfiguration.cs | 89 +++ .../V1/InsertRestrictionsConfiguration.cs | 35 +- ...diaLocationUpdateSupportedConfiguration.cs | 4 +- ...igationPropertyRestrictionConfiguration.cs | 9 +- .../V1/OperationRestrictionsConfiguration.cs | 33 ++ .../ReadByKeyRestrictionsTypeConfiguration.cs | 35 +- .../V1/ReadRestrictionsConfiguration.cs | 52 +- .../V1/UpdateRestrictionsConfiguration.cs | 37 +- .../V1/AcceptableMediaTypesConfiguration.cs | 6 +- .../Core/V1/AnyStructureConfiguration.cs | 45 ++ .../V1/AppliesViaContainerConfiguration.cs | 45 ++ .../Core/V1/AutoExpandConfiguration.cs | 4 +- .../V1/ContentDispositionConfiguration.cs | 85 +++ .../Core/V1/DictionaryConfiguration.cs | 58 ++ .../ExplicitOperationBindingsConfiguration.cs | 47 ++ .../Core/V1/GeometryFeatureConfiguration.cs | 116 ++++ .../Core/V1/LongDescriptionConfiguration.cs | 4 +- .../Core/V1/MediaTypeConfiguration.cs | 6 +- .../V1/OptimisticConcurrencyConfiguration.cs | 4 +- .../RequiresExplicitBindingConfiguration.cs | 41 ++ .../Core/V1/SymbolicNameConfiguration.cs | 41 ++ .../VocabularyTermConfigurationExtensions.cs | 166 +++++- .../VocabularyTermConfigurationExtensions.tt | 21 +- 27 files changed, 1462 insertions(+), 109 deletions(-) create mode 100644 src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/HttpResponseConfiguration.cs create mode 100644 src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AnyStructureConfiguration.cs create mode 100644 src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AppliesViaContainerConfiguration.cs create mode 100644 src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ContentDispositionConfiguration.cs create mode 100644 src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/DictionaryConfiguration.cs create mode 100644 src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ExplicitOperationBindingsConfiguration.cs create mode 100644 src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/GeometryFeatureConfiguration.cs create mode 100644 src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/RequiresExplicitBindingConfiguration.cs create mode 100644 src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/SymbolicNameConfiguration.cs diff --git a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.csproj b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.csproj index 27dcc3d..b927aa1 100644 --- a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.csproj +++ b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.csproj @@ -15,6 +15,11 @@ + + + + + @@ -34,11 +39,6 @@ True SRResources.resx - - True - True - VocabularyTermConfigurationExtensions.tt - @@ -48,13 +48,6 @@ - - - TextTemplatingFileGenerator - VocabularyTermConfigurationExtensions.cs - - - diff --git a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml index d7f17bb..b746e2e 100644 --- a/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml +++ b/src/Microsoft.OData.ModelBuilder/Microsoft.OData.ModelBuilder.xml @@ -6643,14 +6643,14 @@ - Members of collections can be updated via a PATCH request with a `/$filter(...)/$each` segment + Members of collections can be deleted via a DELETE request with a `/$filter(...)/$each` segment The value to set - Members of collections can be updated via a PATCH request with a type-cast segment and a `/$each` segment + Members of collections can be deleted via a DELETE request with a type-cast segment and a `/$each` segment The value to set @@ -6706,11 +6706,25 @@ - A lengthy description of the request + A long description of the request The value to set + + + Possible error responses returned by the request. + + The configuration to set + + + + + Possible error responses returned by the request. + + The value(s) to set + + @@ -6739,7 +6753,7 @@ - $expand is supported for stream properties and media resources + $expand is supported for stream properties and media streams The value to set @@ -6931,6 +6945,41 @@ The HTTP HEAD Method + + + Org.OData.Capabilities.V1.HttpResponse + + + + + Creates a new instance of + + + + + Dynamic properties. + + The name to set + The value to set + + + + + HTTP response status code, for example 400, 403, 501 + + The value to set + + + + + Human-readable description of the response + + The value to set + + + + + Supports key values according to OData URL conventions @@ -7072,11 +7121,25 @@ - A lengthy description of the request + A long description of the request The value to set + + + Possible error responses returned by the request. + + The configuration to set + + + + + Possible error responses returned by the request. + + The value(s) to set + + @@ -7128,7 +7191,7 @@ - Stream property supports update of its media edit URL and/or media read URL + Stream property or media stream supports update of its media edit URL and/or media read URL @@ -7136,7 +7199,7 @@ - Stream property supports update of its media edit URL and/or media read URL + Stream property or media stream supports update of its media edit URL and/or media read URL The value to set @@ -7207,7 +7270,10 @@ - Org.OData.Capabilities.V1.NavigationPropertyRestriction + Using a property of `NavigationPropertyRestriction` in a [`NavigationRestrictions`](#NavigationRestrictions) annotation + is discouraged in favor of using an annotation with the corresponding term from this vocabulary and a target path starting with a container and ending in the `NavigationProperty`, + unless the favored alternative is impossible because a dynamic expression requires an instance path whose evaluation + starts at the target of the `NavigationRestrictions` annotation. See [this example](../examples/Org.OData.Capabilities.V1.capabilities.md). @@ -7226,6 +7292,10 @@ Navigation properties can be navigated + The target path of a [`NavigationRestrictions`](#NavigationRestrictions) annotation followed by this + navigation property path addresses the resource to which the other properties of `NavigationPropertyRestriction` apply. + Instance paths that occur in dynamic expressions are evaluated starting at the boundary between both paths, + which must therefore be chosen accordingly. The value to set @@ -7542,6 +7612,20 @@ The value(s) to set + + + Possible error responses returned by the request. + + The configuration to set + + + + + Possible error responses returned by the request. + + The value(s) to set + + @@ -7681,11 +7765,25 @@ - A lengthy description of the request + A long description of the request The value to set + + + Possible error responses returned by the request. + + The configuration to set + + + + + Possible error responses returned by the request. + + The value(s) to set + + @@ -7763,11 +7861,32 @@ - A lengthy description of the request + A long description of the request The value to set + + + Possible error responses returned by the request. + + The configuration to set + + + + + Possible error responses returned by the request. + + The value(s) to set + + + + + Entities of a specific derived type can be read by specifying a type-cast segment + + The value to set + + Restrictions for retrieving an entity by key @@ -8163,7 +8282,7 @@ - These structural properties cannot be specified on update + These structural properties cannot be updated The value(s) to set @@ -8254,17 +8373,32 @@ - A lengthy description of the request + A long description of the request The value to set + + + Possible error responses returned by the request. + + The configuration to set + + + + + Possible error responses returned by the request. + + The value(s) to set + + - Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated stream property + Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated binary, stream, or string property or term + The annotation of a TypeDefinition propagates to the model elements having this type @@ -8272,7 +8406,8 @@ - Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated stream property + Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated binary, stream, or string property or term + The annotation of a TypeDefinition propagates to the model elements having this type The value(s) to set @@ -8360,9 +8495,53 @@ + + + Instances of a type are annotated with this tag if they have no common structure in a given response payload + The select-list of a context URL MUST be `(@Core.AnyStructure)` if it would otherwise be empty, + but this instance annotation SHOULD be omitted from the response value. + + + + + + + + Instances of a type are annotated with this tag if they have no common structure in a given response payload + The select-list of a context URL MUST be `(@Core.AnyStructure)` if it would otherwise be empty, + but this instance annotation SHOULD be omitted from the response value. + + The value to set + + + + + + + + The target path of an annotation with the tagged term MUST start with an entity container or the annotation MUST be embedded within an entity container, entity set or singleton + Services MAY additionally annotate a container-independent model element (entity type, property, navigation property) if allowed by the `AppliesTo` property of the term + and the annotation applies to all uses of that model element. + + + + + + + + The target path of an annotation with the tagged term MUST start with an entity container or the annotation MUST be embedded within an entity container, entity set or singleton + Services MAY additionally annotate a container-independent model element (entity type, property, navigation property) if allowed by the `AppliesTo` property of the term + and the annotation applies to all uses of that model element. + + The value to set + + + + + - The service will automatically expand this stream or navigation property even if not requested with $expand + The service will automatically expand this stream property, navigation property, or the media stream of this media entity type even if not requested with $expand @@ -8370,7 +8549,7 @@ - The service will automatically expand this stream or navigation property even if not requested with $expand + The service will automatically expand this stream property, navigation property, or the media stream of this media entity type even if not requested with $expand The value to set @@ -8432,6 +8611,39 @@ + + + The content disposition of the media stream of the annotated entity type marked with HasStream="true" or the annotated binary, stream, or string property or term + + + + + + + + Dynamic properties. + + The name to set + The value to set + + + + + The disposition type of the binary or stream value, see [RFC 6266, Disposition Type](https://datatracker.ietf.org/doc/html/rfc6266#section-4.2) + + The value to set + + + + + The proposed filename for downloading the binary or stream value, see [RFC 6266, Disposition Parameter: 'Filename'](https://datatracker.ietf.org/doc/html/rfc6266#section-4.3) + + The value to set + + + + + A unique identifier for nested entities within a request. @@ -8611,6 +8823,30 @@ + + + A dictionary of name-value pairs. Names must be valid property names, values may be restricted to a list of types via an annotation with term `Validation.OpenPropertyTypeConstraint`. + Property|Type + :-------|:--- + Any simple identifier | Any type listed in `Validation.OpenPropertyTypeConstraint`, or any type if there is no constraint + + + + + Creates a new instance of + + + + + Dynamic properties. + + The name to set + The value to set + + + + + Example for an instance of the annotated model element @@ -8637,6 +8873,71 @@ + + + The qualified names of explicitly bound operations that are supported on the target model element. These operations are in addition to any operations not annotated with RequiresExplicitBinding that are bound to the type of the target model element. + + + + + + + + The qualified names of explicitly bound operations that are supported on the target model element. These operations are in addition to any operations not annotated with RequiresExplicitBinding that are bound to the type of the target model element. + + The value(s) to set + + + + + + + + A [Feature Object](https://datatracker.ietf.org/doc/html/rfc7946#section-3.2) represents a spatially bounded thing + + + + + + + + Dynamic properties. + + The name to set + The value to set + + + + + Location of the Feature + + The value to set + + + + + Properties of the Feature + + The configuration to set + + + + + Properties of the Feature + + The value to set + + + + + Commonly used identifer for a Feature + + The value to set + + + + + A value for this non-key property can be provided by the client on insert and remains unchanged on update @@ -8771,7 +9072,7 @@ - A lengthy description of a model element + A long description of a model element @@ -8779,7 +9080,7 @@ - A lengthy description of a model element + A long description of a model element The value to set @@ -8807,7 +9108,8 @@ - The media type of a binary resource + The media type of the media stream of the annotated entity type marked with HasStream="true" or the annotated binary, stream, or string property or term + The annotation of a TypeDefinition propagates to the model elements having this type @@ -8815,7 +9117,8 @@ - The media type of a binary resource + The media type of the media stream of the annotated entity type marked with HasStream="true" or the annotated binary, stream, or string property or term + The annotation of a TypeDefinition propagates to the model elements having this type The value to set @@ -8951,7 +9254,7 @@ - Data modification requires the use of ETags. A non-empty collection contains the set of properties that are used to compute the ETag. An empty collection means that the service won't tell how it computes the ETag. + Data modification requires the use of ETags. A non-empty collection contains the set of properties that are used to compute the ETag. An empty collection means that the service won't tell how it computes the ETag @@ -8959,7 +9262,7 @@ - Data modification requires the use of ETags. A non-empty collection contains the set of properties that are used to compute the ETag. An empty collection means that the service won't tell how it computes the ETag. + Data modification requires the use of ETags. A non-empty collection contains the set of properties that are used to compute the ETag. An empty collection means that the service won't tell how it computes the ETag The value(s) to set @@ -9149,6 +9452,24 @@ + + + This bound action or function is only available on model elements annotated with the ExplicitOperationBindings term. + + + + + + + + This bound action or function is only available on model elements annotated with the ExplicitOperationBindings term. + + The value to set + + + + + Terms annotated with this term can only be applied to elements that have a type that is identical to or derived from the given type name @@ -9330,6 +9651,24 @@ + + + A symbolic name for a model element + + + + + + + + A symbolic name for a model element + + The value to set + + + + + The annotated value is problematic @@ -9571,14 +9910,6 @@ The that can be built using . - - - configuration - - The type of the structured type. - The that can be built using . - - configuration @@ -9595,14 +9926,6 @@ The that can be built using . - - - configuration - - The type of the structured type. - The that can be built using . - - configuration @@ -9619,14 +9942,6 @@ The that can be built using . - - - configuration - - The type of the structured type. - The that can be built using . - - configuration @@ -9665,6 +9980,14 @@ The that can be built using . + + + configuration + + The type of the structured type. + The that can be built using . + + configuration @@ -9991,6 +10314,14 @@ The that can be built using . + + + configuration + + The type of the structured type. + The that can be built using . + + configuration @@ -9998,6 +10329,21 @@ The that can be built using . + + + configuration + + The that can be built using . + + + + + configuration + + The type of the structured type. + The that can be built using . + + configuration @@ -10021,6 +10367,14 @@ The that can be built using . + + + configuration + + The type of the structured type. + The that can be built using . + + configuration @@ -10114,6 +10468,90 @@ The that can be built using . + + + configuration + + The that can be built using . + + + + + configuration + + The entity type of the navigation source. + The that can be built using . + + + + + configuration + + The that can be built using . + + + + + configuration + + The type of the structured type. + The that can be built using . + + + + + configuration + + The entity type of the navigation source. + The that can be built using . + + + + + configuration + + The that can be built using . + + + + + configuration + + The type of the structured type. + The that can be built using . + + + + + configuration + + The entity type of the navigation source. + The that can be built using . + + + + + configuration + + The that can be built using . + + + + + configuration + + The type of the structured type. + The that can be built using . + + + + + configuration + + The type of the structured type. + The that can be built using . + + Add vocabulary annotations to a model target. diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/DeleteRestrictionsConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/DeleteRestrictionsConfiguration.cs index 8f24dfa..1f78d3d 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/DeleteRestrictionsConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/DeleteRestrictionsConfiguration.cs @@ -27,6 +27,7 @@ public partial class DeleteRestrictionsConfiguration : VocabularyTermConfigurati private readonly HashSet _customQueryOptions = new HashSet(); private string _description; private string _longDescription; + private readonly HashSet _errorResponses = new HashSet(); /// public override string TermName => "Org.OData.Capabilities.V1.DeleteRestrictions"; @@ -77,7 +78,7 @@ public DeleteRestrictionsConfiguration HasMaxLevels(int maxLevels) } /// - /// Members of collections can be updated via a PATCH request with a `/$filter(...)/$each` segment + /// Members of collections can be deleted via a DELETE request with a `/$filter(...)/$each` segment /// /// The value to set /// @@ -88,7 +89,7 @@ public DeleteRestrictionsConfiguration IsFilterSegmentSupported(bool filterSegme } /// - /// Members of collections can be updated via a PATCH request with a type-cast segment and a `/$each` segment + /// Members of collections can be deleted via a DELETE request with a type-cast segment and a `/$each` segment /// /// The value to set /// @@ -179,7 +180,7 @@ public DeleteRestrictionsConfiguration HasDescription(string description) } /// - /// A lengthy description of the request + /// A long description of the request /// /// The value to set /// @@ -189,6 +190,29 @@ public DeleteRestrictionsConfiguration HasLongDescription(string longDescription return this; } + /// + /// Possible error responses returned by the request. + /// + /// The configuration to set + /// + public DeleteRestrictionsConfiguration HasErrorResponses(Func errorResponsesConfiguration) + { + var instance = new HttpResponseConfiguration(); + instance = errorResponsesConfiguration?.Invoke(instance); + return HasErrorResponses(instance); + } + + /// + /// Possible error responses returned by the request. + /// + /// The value(s) to set + /// + public DeleteRestrictionsConfiguration HasErrorResponses(params HttpResponseConfiguration[] errorResponses) + { + _errorResponses.UnionWith(errorResponses); + return this; + } + /// public override IEdmExpression ToEdmExpression() { @@ -260,6 +284,15 @@ public override IEdmExpression ToEdmExpression() properties.Add(new EdmPropertyConstructor("LongDescription", new EdmStringConstant(_longDescription))); } + if (_errorResponses.Any()) + { + var collection = _errorResponses.Select(item => item.ToEdmExpression()).Where(item => item != null); + if (collection.Any()) + { + properties.Add(new EdmPropertyConstructor("ErrorResponses", new EdmCollectionExpression(collection))); + } + } + properties.AddRange(_dynamicProperties.ToEdmProperties()); if (!properties.Any()) diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ExpandRestrictionsConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ExpandRestrictionsConfiguration.cs index 2030d80..a88407d 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ExpandRestrictionsConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ExpandRestrictionsConfiguration.cs @@ -50,7 +50,7 @@ public ExpandRestrictionsConfiguration IsExpandable(bool expandable) } /// - /// $expand is supported for stream properties and media resources + /// $expand is supported for stream properties and media streams /// /// The value to set /// diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/HttpResponseConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/HttpResponseConfiguration.cs new file mode 100644 index 0000000..54a1880 --- /dev/null +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/HttpResponseConfiguration.cs @@ -0,0 +1,89 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// This is an auto generated file. Please run the template to modify it. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OData.Edm; +using Microsoft.OData.Edm.Vocabularies; + +namespace Microsoft.OData.ModelBuilder.Capabilities.V1 +{ + /// + /// Org.OData.Capabilities.V1.HttpResponse + /// + public partial class HttpResponseConfiguration : IRecord + { + private readonly Dictionary _dynamicProperties = new Dictionary(); + private string _statusCode; + private string _description; + + /// + /// Creates a new instance of + /// + public HttpResponseConfiguration() + { + } + + /// + /// Dynamic properties. + /// + /// The name to set + /// The value to set + /// + public HttpResponseConfiguration HasDynamicProperty(string name, object value) + { + _dynamicProperties[name] = value; + return this; + } + + /// + /// HTTP response status code, for example 400, 403, 501 + /// + /// The value to set + /// + public HttpResponseConfiguration HasStatusCode(string statusCode) + { + _statusCode = statusCode; + return this; + } + + /// + /// Human-readable description of the response + /// + /// The value to set + /// + public HttpResponseConfiguration HasDescription(string description) + { + _description = description; + return this; + } + + /// + public IEdmExpression ToEdmExpression() + { + var properties = new List(); + + if (!string.IsNullOrEmpty(_statusCode)) + { + properties.Add(new EdmPropertyConstructor("StatusCode", new EdmStringConstant(_statusCode))); + } + + if (!string.IsNullOrEmpty(_description)) + { + properties.Add(new EdmPropertyConstructor("Description", new EdmStringConstant(_description))); + } + + properties.AddRange(_dynamicProperties.ToEdmProperties()); + + if (!properties.Any()) + { + return null; + } + + return new EdmRecordExpression(properties); + } + } +} diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/InsertRestrictionsConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/InsertRestrictionsConfiguration.cs index 5652460..02187eb 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/InsertRestrictionsConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/InsertRestrictionsConfiguration.cs @@ -29,6 +29,7 @@ public partial class InsertRestrictionsConfiguration : VocabularyTermConfigurati private readonly HashSet _customQueryOptions = new HashSet(); private string _description; private string _longDescription; + private readonly HashSet _errorResponses = new HashSet(); /// public override string TermName => "Org.OData.Capabilities.V1.InsertRestrictions"; @@ -215,7 +216,7 @@ public InsertRestrictionsConfiguration HasDescription(string description) } /// - /// A lengthy description of the request + /// A long description of the request /// /// The value to set /// @@ -225,6 +226,29 @@ public InsertRestrictionsConfiguration HasLongDescription(string longDescription return this; } + /// + /// Possible error responses returned by the request. + /// + /// The configuration to set + /// + public InsertRestrictionsConfiguration HasErrorResponses(Func errorResponsesConfiguration) + { + var instance = new HttpResponseConfiguration(); + instance = errorResponsesConfiguration?.Invoke(instance); + return HasErrorResponses(instance); + } + + /// + /// Possible error responses returned by the request. + /// + /// The value(s) to set + /// + public InsertRestrictionsConfiguration HasErrorResponses(params HttpResponseConfiguration[] errorResponses) + { + _errorResponses.UnionWith(errorResponses); + return this; + } + /// public override IEdmExpression ToEdmExpression() { @@ -314,6 +338,15 @@ public override IEdmExpression ToEdmExpression() properties.Add(new EdmPropertyConstructor("LongDescription", new EdmStringConstant(_longDescription))); } + if (_errorResponses.Any()) + { + var collection = _errorResponses.Select(item => item.ToEdmExpression()).Where(item => item != null); + if (collection.Any()) + { + properties.Add(new EdmPropertyConstructor("ErrorResponses", new EdmCollectionExpression(collection))); + } + } + properties.AddRange(_dynamicProperties.ToEdmProperties()); if (!properties.Any()) diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/MediaLocationUpdateSupportedConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/MediaLocationUpdateSupportedConfiguration.cs index 5b780a5..fa1794e 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/MediaLocationUpdateSupportedConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/MediaLocationUpdateSupportedConfiguration.cs @@ -12,7 +12,7 @@ namespace Microsoft.OData.ModelBuilder.Capabilities.V1 { /// - /// Stream property supports update of its media edit URL and/or media read URL + /// Stream property or media stream supports update of its media edit URL and/or media read URL /// public partial class MediaLocationUpdateSupportedConfiguration : VocabularyTermConfiguration { @@ -22,7 +22,7 @@ public partial class MediaLocationUpdateSupportedConfiguration : VocabularyTermC public override string TermName => "Org.OData.Capabilities.V1.MediaLocationUpdateSupported"; /// - /// Stream property supports update of its media edit URL and/or media read URL + /// Stream property or media stream supports update of its media edit URL and/or media read URL /// /// The value to set /// diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/NavigationPropertyRestrictionConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/NavigationPropertyRestrictionConfiguration.cs index 1d92e34..3bec8ae 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/NavigationPropertyRestrictionConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/NavigationPropertyRestrictionConfiguration.cs @@ -12,7 +12,10 @@ namespace Microsoft.OData.ModelBuilder.Capabilities.V1 { /// - /// Org.OData.Capabilities.V1.NavigationPropertyRestriction + /// Using a property of `NavigationPropertyRestriction` in a [`NavigationRestrictions`](#NavigationRestrictions) annotation + /// is discouraged in favor of using an annotation with the corresponding term from this vocabulary and a target path starting with a container and ending in the `NavigationProperty`, + /// unless the favored alternative is impossible because a dynamic expression requires an instance path whose evaluation + /// starts at the target of the `NavigationRestrictions` annotation. See [this example](../examples/Org.OData.Capabilities.V1.capabilities.md). /// public partial class NavigationPropertyRestrictionConfiguration : IRecord { @@ -56,6 +59,10 @@ public NavigationPropertyRestrictionConfiguration HasDynamicProperty(string name /// /// Navigation properties can be navigated + /// The target path of a [`NavigationRestrictions`](#NavigationRestrictions) annotation followed by this + /// navigation property path addresses the resource to which the other properties of `NavigationPropertyRestriction` apply. + /// Instance paths that occur in dynamic expressions are evaluated starting at the boundary between both paths, + /// which must therefore be chosen accordingly. /// /// The value to set /// diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/OperationRestrictionsConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/OperationRestrictionsConfiguration.cs index 1b0bd07..d24fe4c 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/OperationRestrictionsConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/OperationRestrictionsConfiguration.cs @@ -21,6 +21,7 @@ public partial class OperationRestrictionsConfiguration : VocabularyTermConfigur private readonly HashSet _permissions = new HashSet(); private readonly HashSet _customHeaders = new HashSet(); private readonly HashSet _customQueryOptions = new HashSet(); + private readonly HashSet _errorResponses = new HashSet(); /// public override string TermName => "Org.OData.Capabilities.V1.OperationRestrictions"; @@ -117,6 +118,29 @@ public OperationRestrictionsConfiguration HasCustomQueryOptions(params CustomPar return this; } + /// + /// Possible error responses returned by the request. + /// + /// The configuration to set + /// + public OperationRestrictionsConfiguration HasErrorResponses(Func errorResponsesConfiguration) + { + var instance = new HttpResponseConfiguration(); + instance = errorResponsesConfiguration?.Invoke(instance); + return HasErrorResponses(instance); + } + + /// + /// Possible error responses returned by the request. + /// + /// The value(s) to set + /// + public OperationRestrictionsConfiguration HasErrorResponses(params HttpResponseConfiguration[] errorResponses) + { + _errorResponses.UnionWith(errorResponses); + return this; + } + /// public override IEdmExpression ToEdmExpression() { @@ -154,6 +178,15 @@ public override IEdmExpression ToEdmExpression() } } + if (_errorResponses.Any()) + { + var collection = _errorResponses.Select(item => item.ToEdmExpression()).Where(item => item != null); + if (collection.Any()) + { + properties.Add(new EdmPropertyConstructor("ErrorResponses", new EdmCollectionExpression(collection))); + } + } + properties.AddRange(_dynamicProperties.ToEdmProperties()); if (!properties.Any()) diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ReadByKeyRestrictionsTypeConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ReadByKeyRestrictionsTypeConfiguration.cs index 8f39992..4ca3ee1 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ReadByKeyRestrictionsTypeConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ReadByKeyRestrictionsTypeConfiguration.cs @@ -23,6 +23,7 @@ public partial class ReadByKeyRestrictionsTypeConfiguration : IRecord private readonly HashSet _customQueryOptions = new HashSet(); private string _description; private string _longDescription; + private readonly HashSet _errorResponses = new HashSet(); /// /// Creates a new instance of @@ -135,7 +136,7 @@ public ReadByKeyRestrictionsTypeConfiguration HasDescription(string description) } /// - /// A lengthy description of the request + /// A long description of the request /// /// The value to set /// @@ -145,6 +146,29 @@ public ReadByKeyRestrictionsTypeConfiguration HasLongDescription(string longDesc return this; } + /// + /// Possible error responses returned by the request. + /// + /// The configuration to set + /// + public ReadByKeyRestrictionsTypeConfiguration HasErrorResponses(Func errorResponsesConfiguration) + { + var instance = new HttpResponseConfiguration(); + instance = errorResponsesConfiguration?.Invoke(instance); + return HasErrorResponses(instance); + } + + /// + /// Possible error responses returned by the request. + /// + /// The value(s) to set + /// + public ReadByKeyRestrictionsTypeConfiguration HasErrorResponses(params HttpResponseConfiguration[] errorResponses) + { + _errorResponses.UnionWith(errorResponses); + return this; + } + /// public IEdmExpression ToEdmExpression() { @@ -192,6 +216,15 @@ public IEdmExpression ToEdmExpression() properties.Add(new EdmPropertyConstructor("LongDescription", new EdmStringConstant(_longDescription))); } + if (_errorResponses.Any()) + { + var collection = _errorResponses.Select(item => item.ToEdmExpression()).Where(item => item != null); + if (collection.Any()) + { + properties.Add(new EdmPropertyConstructor("ErrorResponses", new EdmCollectionExpression(collection))); + } + } + properties.AddRange(_dynamicProperties.ToEdmProperties()); if (!properties.Any()) diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ReadRestrictionsConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ReadRestrictionsConfiguration.cs index cfa83bf..29edf8b 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ReadRestrictionsConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/ReadRestrictionsConfiguration.cs @@ -23,6 +23,8 @@ public partial class ReadRestrictionsConfiguration : VocabularyTermConfiguration private readonly HashSet _customQueryOptions = new HashSet(); private string _description; private string _longDescription; + private readonly HashSet _errorResponses = new HashSet(); + private bool? _typecastSegmentSupported; private ReadByKeyRestrictionsTypeConfiguration _readByKeyRestrictions; /// @@ -132,7 +134,7 @@ public ReadRestrictionsConfiguration HasDescription(string description) } /// - /// A lengthy description of the request + /// A long description of the request /// /// The value to set /// @@ -142,6 +144,40 @@ public ReadRestrictionsConfiguration HasLongDescription(string longDescription) return this; } + /// + /// Possible error responses returned by the request. + /// + /// The configuration to set + /// + public ReadRestrictionsConfiguration HasErrorResponses(Func errorResponsesConfiguration) + { + var instance = new HttpResponseConfiguration(); + instance = errorResponsesConfiguration?.Invoke(instance); + return HasErrorResponses(instance); + } + + /// + /// Possible error responses returned by the request. + /// + /// The value(s) to set + /// + public ReadRestrictionsConfiguration HasErrorResponses(params HttpResponseConfiguration[] errorResponses) + { + _errorResponses.UnionWith(errorResponses); + return this; + } + + /// + /// Entities of a specific derived type can be read by specifying a type-cast segment + /// + /// The value to set + /// + public ReadRestrictionsConfiguration IsTypecastSegmentSupported(bool typecastSegmentSupported) + { + _typecastSegmentSupported = typecastSegmentSupported; + return this; + } + /// /// 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. @@ -214,6 +250,20 @@ public override IEdmExpression ToEdmExpression() properties.Add(new EdmPropertyConstructor("LongDescription", new EdmStringConstant(_longDescription))); } + if (_errorResponses.Any()) + { + var collection = _errorResponses.Select(item => item.ToEdmExpression()).Where(item => item != null); + if (collection.Any()) + { + properties.Add(new EdmPropertyConstructor("ErrorResponses", new EdmCollectionExpression(collection))); + } + } + + if (_typecastSegmentSupported.HasValue) + { + properties.Add(new EdmPropertyConstructor("TypecastSegmentSupported", new EdmBooleanConstant(_typecastSegmentSupported.Value))); + } + if (_readByKeyRestrictions != null) { properties.Add(new EdmPropertyConstructor("ReadByKeyRestrictions", _readByKeyRestrictions.ToEdmExpression())); diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/UpdateRestrictionsConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/UpdateRestrictionsConfiguration.cs index 404f7be..4a90283 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/UpdateRestrictionsConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Capabilities/V1/UpdateRestrictionsConfiguration.cs @@ -33,6 +33,7 @@ public partial class UpdateRestrictionsConfiguration : VocabularyTermConfigurati private readonly HashSet _customQueryOptions = new HashSet(); private string _description; private string _longDescription; + private readonly HashSet _errorResponses = new HashSet(); /// public override string TermName => "Org.OData.Capabilities.V1.UpdateRestrictions"; @@ -116,7 +117,7 @@ public UpdateRestrictionsConfiguration IsTypecastSegmentSupported(bool typecastS } /// - /// These structural properties cannot be specified on update + /// These structural properties cannot be updated /// /// The value(s) to set /// @@ -263,7 +264,7 @@ public UpdateRestrictionsConfiguration HasDescription(string description) } /// - /// A lengthy description of the request + /// A long description of the request /// /// The value to set /// @@ -273,6 +274,29 @@ public UpdateRestrictionsConfiguration HasLongDescription(string longDescription return this; } + /// + /// Possible error responses returned by the request. + /// + /// The configuration to set + /// + public UpdateRestrictionsConfiguration HasErrorResponses(Func errorResponsesConfiguration) + { + var instance = new HttpResponseConfiguration(); + instance = errorResponsesConfiguration?.Invoke(instance); + return HasErrorResponses(instance); + } + + /// + /// Possible error responses returned by the request. + /// + /// The value(s) to set + /// + public UpdateRestrictionsConfiguration HasErrorResponses(params HttpResponseConfiguration[] errorResponses) + { + _errorResponses.UnionWith(errorResponses); + return this; + } + /// public override IEdmExpression ToEdmExpression() { @@ -384,6 +408,15 @@ public override IEdmExpression ToEdmExpression() properties.Add(new EdmPropertyConstructor("LongDescription", new EdmStringConstant(_longDescription))); } + if (_errorResponses.Any()) + { + var collection = _errorResponses.Select(item => item.ToEdmExpression()).Where(item => item != null); + if (collection.Any()) + { + properties.Add(new EdmPropertyConstructor("ErrorResponses", new EdmCollectionExpression(collection))); + } + } + properties.AddRange(_dynamicProperties.ToEdmProperties()); if (!properties.Any()) diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AcceptableMediaTypesConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AcceptableMediaTypesConfiguration.cs index 0267064..285a4ea 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AcceptableMediaTypesConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AcceptableMediaTypesConfiguration.cs @@ -12,7 +12,8 @@ namespace Microsoft.OData.ModelBuilder.Core.V1 { /// - /// Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated stream property + /// Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated binary, stream, or string property or term + /// The annotation of a TypeDefinition propagates to the model elements having this type /// public partial class AcceptableMediaTypesConfiguration : VocabularyTermConfiguration { @@ -22,7 +23,8 @@ public partial class AcceptableMediaTypesConfiguration : VocabularyTermConfigura public override string TermName => "Org.OData.Core.V1.AcceptableMediaTypes"; /// - /// Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated stream property + /// Lists the MIME types acceptable for the annotated entity type marked with HasStream="true" or the annotated binary, stream, or string property or term + /// The annotation of a TypeDefinition propagates to the model elements having this type /// /// The value(s) to set /// diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AnyStructureConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AnyStructureConfiguration.cs new file mode 100644 index 0000000..187a473 --- /dev/null +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AnyStructureConfiguration.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// This is an auto generated file. Please run the template to modify it. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OData.Edm; +using Microsoft.OData.Edm.Vocabularies; + +namespace Microsoft.OData.ModelBuilder.Core.V1 +{ + /// + /// Instances of a type are annotated with this tag if they have no common structure in a given response payload + /// The select-list of a context URL MUST be `(@Core.AnyStructure)` if it would otherwise be empty, + /// but this instance annotation SHOULD be omitted from the response value. + /// + public partial class AnyStructureConfiguration : VocabularyTermConfiguration + { + private bool? _anyStructure; + + /// + public override string TermName => "Org.OData.Core.V1.AnyStructure"; + + /// + /// Instances of a type are annotated with this tag if they have no common structure in a given response payload + /// The select-list of a context URL MUST be `(@Core.AnyStructure)` if it would otherwise be empty, + /// but this instance annotation SHOULD be omitted from the response value. + /// + /// The value to set + /// + public AnyStructureConfiguration IsAnyStructure(bool anyStructure) + { + _anyStructure = anyStructure; + return this; + } + + /// + public override IEdmExpression ToEdmExpression() + { + return _anyStructure.HasValue ? new EdmBooleanConstant(_anyStructure.Value) : null; + } + } +} diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AppliesViaContainerConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AppliesViaContainerConfiguration.cs new file mode 100644 index 0000000..5072695 --- /dev/null +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AppliesViaContainerConfiguration.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// This is an auto generated file. Please run the template to modify it. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OData.Edm; +using Microsoft.OData.Edm.Vocabularies; + +namespace Microsoft.OData.ModelBuilder.Core.V1 +{ + /// + /// The target path of an annotation with the tagged term MUST start with an entity container or the annotation MUST be embedded within an entity container, entity set or singleton + /// Services MAY additionally annotate a container-independent model element (entity type, property, navigation property) if allowed by the `AppliesTo` property of the term + /// and the annotation applies to all uses of that model element. + /// + public partial class AppliesViaContainerConfiguration : VocabularyTermConfiguration + { + private bool? _appliesViaContainer; + + /// + public override string TermName => "Org.OData.Core.V1.AppliesViaContainer"; + + /// + /// The target path of an annotation with the tagged term MUST start with an entity container or the annotation MUST be embedded within an entity container, entity set or singleton + /// Services MAY additionally annotate a container-independent model element (entity type, property, navigation property) if allowed by the `AppliesTo` property of the term + /// and the annotation applies to all uses of that model element. + /// + /// The value to set + /// + public AppliesViaContainerConfiguration IsAppliesViaContainer(bool appliesViaContainer) + { + _appliesViaContainer = appliesViaContainer; + return this; + } + + /// + public override IEdmExpression ToEdmExpression() + { + return _appliesViaContainer.HasValue ? new EdmBooleanConstant(_appliesViaContainer.Value) : null; + } + } +} diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AutoExpandConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AutoExpandConfiguration.cs index 1c67a14..a9c172c 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AutoExpandConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/AutoExpandConfiguration.cs @@ -12,7 +12,7 @@ namespace Microsoft.OData.ModelBuilder.Core.V1 { /// - /// The service will automatically expand this stream or navigation property even if not requested with $expand + /// The service will automatically expand this stream property, navigation property, or the media stream of this media entity type even if not requested with $expand /// public partial class AutoExpandConfiguration : VocabularyTermConfiguration { @@ -22,7 +22,7 @@ public partial class AutoExpandConfiguration : VocabularyTermConfiguration public override string TermName => "Org.OData.Core.V1.AutoExpand"; /// - /// The service will automatically expand this stream or navigation property even if not requested with $expand + /// The service will automatically expand this stream property, navigation property, or the media stream of this media entity type even if not requested with $expand /// /// The value to set /// diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ContentDispositionConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ContentDispositionConfiguration.cs new file mode 100644 index 0000000..22193ea --- /dev/null +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ContentDispositionConfiguration.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// This is an auto generated file. Please run the template to modify it. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OData.Edm; +using Microsoft.OData.Edm.Vocabularies; + +namespace Microsoft.OData.ModelBuilder.Core.V1 +{ + /// + /// The content disposition of the media stream of the annotated entity type marked with HasStream="true" or the annotated binary, stream, or string property or term + /// + public partial class ContentDispositionConfiguration : VocabularyTermConfiguration + { + private readonly Dictionary _dynamicProperties = new Dictionary(); + private string _type; + private string _filename; + + /// + public override string TermName => "Org.OData.Core.V1.ContentDisposition"; + + /// + /// Dynamic properties. + /// + /// The name to set + /// The value to set + /// + public ContentDispositionConfiguration HasDynamicProperty(string name, object value) + { + _dynamicProperties[name] = value; + return this; + } + + /// + /// The disposition type of the binary or stream value, see [RFC 6266, Disposition Type](https://datatracker.ietf.org/doc/html/rfc6266#section-4.2) + /// + /// The value to set + /// + public ContentDispositionConfiguration HasType(string type) + { + _type = type; + return this; + } + + /// + /// The proposed filename for downloading the binary or stream value, see [RFC 6266, Disposition Parameter: 'Filename'](https://datatracker.ietf.org/doc/html/rfc6266#section-4.3) + /// + /// The value to set + /// + public ContentDispositionConfiguration HasFilename(string filename) + { + _filename = filename; + return this; + } + + /// + public override IEdmExpression ToEdmExpression() + { + var properties = new List(); + + if (!string.IsNullOrEmpty(_type)) + { + properties.Add(new EdmPropertyConstructor("Type", new EdmStringConstant(_type))); + } + + if (!string.IsNullOrEmpty(_filename)) + { + properties.Add(new EdmPropertyConstructor("Filename", new EdmStringConstant(_filename))); + } + + properties.AddRange(_dynamicProperties.ToEdmProperties()); + + if (!properties.Any()) + { + return null; + } + + return new EdmRecordExpression(properties); + } + } +} diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/DictionaryConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/DictionaryConfiguration.cs new file mode 100644 index 0000000..9e41eb7 --- /dev/null +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/DictionaryConfiguration.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// This is an auto generated file. Please run the template to modify it. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OData.Edm; +using Microsoft.OData.Edm.Vocabularies; + +namespace Microsoft.OData.ModelBuilder.Core.V1 +{ + /// + /// A dictionary of name-value pairs. Names must be valid property names, values may be restricted to a list of types via an annotation with term `Validation.OpenPropertyTypeConstraint`. + /// Property|Type + /// :-------|:--- + /// Any simple identifier | Any type listed in `Validation.OpenPropertyTypeConstraint`, or any type if there is no constraint + /// + public partial class DictionaryConfiguration : IRecord + { + private readonly Dictionary _dynamicProperties = new Dictionary(); + + /// + /// Creates a new instance of + /// + public DictionaryConfiguration() + { + } + + /// + /// Dynamic properties. + /// + /// The name to set + /// The value to set + /// + public DictionaryConfiguration HasDynamicProperty(string name, object value) + { + _dynamicProperties[name] = value; + return this; + } + + /// + public IEdmExpression ToEdmExpression() + { + var properties = new List(); + + properties.AddRange(_dynamicProperties.ToEdmProperties()); + + if (!properties.Any()) + { + return null; + } + + return new EdmRecordExpression(properties); + } + } +} diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ExplicitOperationBindingsConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ExplicitOperationBindingsConfiguration.cs new file mode 100644 index 0000000..d3e6d7a --- /dev/null +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/ExplicitOperationBindingsConfiguration.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// This is an auto generated file. Please run the template to modify it. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OData.Edm; +using Microsoft.OData.Edm.Vocabularies; + +namespace Microsoft.OData.ModelBuilder.Core.V1 +{ + /// + /// The qualified names of explicitly bound operations that are supported on the target model element. These operations are in addition to any operations not annotated with RequiresExplicitBinding that are bound to the type of the target model element. + /// + public partial class ExplicitOperationBindingsConfiguration : VocabularyTermConfiguration + { + private readonly HashSet _explicitOperationBindings = new HashSet(); + + /// + public override string TermName => "Org.OData.Core.V1.ExplicitOperationBindings"; + + /// + /// The qualified names of explicitly bound operations that are supported on the target model element. These operations are in addition to any operations not annotated with RequiresExplicitBinding that are bound to the type of the target model element. + /// + /// The value(s) to set + /// + public ExplicitOperationBindingsConfiguration HasExplicitOperationBindings(params string[] explicitOperationBindings) + { + _explicitOperationBindings.UnionWith(explicitOperationBindings); + return this; + } + + /// + public override IEdmExpression ToEdmExpression() + { + if (!_explicitOperationBindings.Any()) + { + return null; + } + + var records = _explicitOperationBindings.Select(item => item.ToEdmExpression()); + return new EdmCollectionExpression(records); + } + } +} diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/GeometryFeatureConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/GeometryFeatureConfiguration.cs new file mode 100644 index 0000000..146c330 --- /dev/null +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/GeometryFeatureConfiguration.cs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// This is an auto generated file. Please run the template to modify it. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OData.Edm; +using Microsoft.OData.Edm.Vocabularies; + +namespace Microsoft.OData.ModelBuilder.Core.V1 +{ + /// + /// A [Feature Object](https://datatracker.ietf.org/doc/html/rfc7946#section-3.2) represents a spatially bounded thing + /// + public partial class GeometryFeatureConfiguration : VocabularyTermConfiguration + { + private readonly Dictionary _dynamicProperties = new Dictionary(); + private Microsoft.Spatial.Geometry _geometry; + private DictionaryConfiguration _properties; + private string _id; + + /// + public override string TermName => "Org.OData.Core.V1.GeometryFeature"; + + /// + /// Dynamic properties. + /// + /// The name to set + /// The value to set + /// + public GeometryFeatureConfiguration HasDynamicProperty(string name, object value) + { + _dynamicProperties[name] = value; + return this; + } + + /// + /// Location of the Feature + /// + /// The value to set + /// + public GeometryFeatureConfiguration Hasgeometry(Microsoft.Spatial.Geometry geometry) + { + _geometry = geometry; + return this; + } + + /// + /// Properties of the Feature + /// + /// The configuration to set + /// + public GeometryFeatureConfiguration Hasproperties(Func propertiesConfiguration) + { + var instance = _properties ?? new DictionaryConfiguration(); + instance = propertiesConfiguration?.Invoke(instance); + return Hasproperties(instance); + } + + /// + /// Properties of the Feature + /// + /// The value to set + /// + public GeometryFeatureConfiguration Hasproperties(DictionaryConfiguration properties) + { + _properties = properties; + return this; + } + + /// + /// Commonly used identifer for a Feature + /// + /// The value to set + /// + public GeometryFeatureConfiguration Hasid(string id) + { + _id = id; + return this; + } + + /// + public override IEdmExpression ToEdmExpression() + { + var properties = new List(); + + if (_geometry != null) + { + var formatter = Microsoft.Spatial.WellKnownTextSqlFormatter.Create(true); + string geometryValue = Microsoft.Spatial.FormatterExtensions.Write(formatter, _geometry); + properties.Add(new EdmPropertyConstructor("geometry", new EdmStringConstant(geometryValue))); + } + + if (_properties != null) + { + properties.Add(new EdmPropertyConstructor("properties", _properties.ToEdmExpression())); + } + + if (!string.IsNullOrEmpty(_id)) + { + properties.Add(new EdmPropertyConstructor("id", new EdmStringConstant(_id))); + } + + properties.AddRange(_dynamicProperties.ToEdmProperties()); + + if (!properties.Any()) + { + return null; + } + + return new EdmRecordExpression(properties); + } + } +} diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/LongDescriptionConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/LongDescriptionConfiguration.cs index 8509526..67d91a6 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/LongDescriptionConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/LongDescriptionConfiguration.cs @@ -12,7 +12,7 @@ namespace Microsoft.OData.ModelBuilder.Core.V1 { /// - /// A lengthy description of a model element + /// A long description of a model element /// public partial class LongDescriptionConfiguration : VocabularyTermConfiguration { @@ -22,7 +22,7 @@ public partial class LongDescriptionConfiguration : VocabularyTermConfiguration public override string TermName => "Org.OData.Core.V1.LongDescription"; /// - /// A lengthy description of a model element + /// A long description of a model element /// /// The value to set /// diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/MediaTypeConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/MediaTypeConfiguration.cs index 567e49f..b80fa13 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/MediaTypeConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/MediaTypeConfiguration.cs @@ -12,7 +12,8 @@ namespace Microsoft.OData.ModelBuilder.Core.V1 { /// - /// The media type of a binary resource + /// The media type of the media stream of the annotated entity type marked with HasStream="true" or the annotated binary, stream, or string property or term + /// The annotation of a TypeDefinition propagates to the model elements having this type /// public partial class MediaTypeConfiguration : VocabularyTermConfiguration { @@ -22,7 +23,8 @@ public partial class MediaTypeConfiguration : VocabularyTermConfiguration public override string TermName => "Org.OData.Core.V1.MediaType"; /// - /// The media type of a binary resource + /// The media type of the media stream of the annotated entity type marked with HasStream="true" or the annotated binary, stream, or string property or term + /// The annotation of a TypeDefinition propagates to the model elements having this type /// /// The value to set /// diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/OptimisticConcurrencyConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/OptimisticConcurrencyConfiguration.cs index aed24ea..257df30 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/OptimisticConcurrencyConfiguration.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/OptimisticConcurrencyConfiguration.cs @@ -12,7 +12,7 @@ namespace Microsoft.OData.ModelBuilder.Core.V1 { /// - /// Data modification requires the use of ETags. A non-empty collection contains the set of properties that are used to compute the ETag. An empty collection means that the service won't tell how it computes the ETag. + /// Data modification requires the use of ETags. A non-empty collection contains the set of properties that are used to compute the ETag. An empty collection means that the service won't tell how it computes the ETag /// public partial class OptimisticConcurrencyConfiguration : VocabularyTermConfiguration { @@ -22,7 +22,7 @@ public partial class OptimisticConcurrencyConfiguration : VocabularyTermConfigur public override string TermName => "Org.OData.Core.V1.OptimisticConcurrency"; /// - /// Data modification requires the use of ETags. A non-empty collection contains the set of properties that are used to compute the ETag. An empty collection means that the service won't tell how it computes the ETag. + /// Data modification requires the use of ETags. A non-empty collection contains the set of properties that are used to compute the ETag. An empty collection means that the service won't tell how it computes the ETag /// /// The value(s) to set /// diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/RequiresExplicitBindingConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/RequiresExplicitBindingConfiguration.cs new file mode 100644 index 0000000..1ae759a --- /dev/null +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/RequiresExplicitBindingConfiguration.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// This is an auto generated file. Please run the template to modify it. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OData.Edm; +using Microsoft.OData.Edm.Vocabularies; + +namespace Microsoft.OData.ModelBuilder.Core.V1 +{ + /// + /// This bound action or function is only available on model elements annotated with the ExplicitOperationBindings term. + /// + public partial class RequiresExplicitBindingConfiguration : VocabularyTermConfiguration + { + private bool? _requiresExplicitBinding; + + /// + public override string TermName => "Org.OData.Core.V1.RequiresExplicitBinding"; + + /// + /// This bound action or function is only available on model elements annotated with the ExplicitOperationBindings term. + /// + /// The value to set + /// + public RequiresExplicitBindingConfiguration IsRequiresExplicitBinding(bool requiresExplicitBinding) + { + _requiresExplicitBinding = requiresExplicitBinding; + return this; + } + + /// + public override IEdmExpression ToEdmExpression() + { + return _requiresExplicitBinding.HasValue ? new EdmBooleanConstant(_requiresExplicitBinding.Value) : null; + } + } +} diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/SymbolicNameConfiguration.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/SymbolicNameConfiguration.cs new file mode 100644 index 0000000..973ed3a --- /dev/null +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/Core/V1/SymbolicNameConfiguration.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// This is an auto generated file. Please run the template to modify it. +// + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OData.Edm; +using Microsoft.OData.Edm.Vocabularies; + +namespace Microsoft.OData.ModelBuilder.Core.V1 +{ + /// + /// A symbolic name for a model element + /// + public partial class SymbolicNameConfiguration : VocabularyTermConfiguration + { + private string _symbolicName; + + /// + public override string TermName => "Org.OData.Core.V1.SymbolicName"; + + /// + /// A symbolic name for a model element + /// + /// The value to set + /// + public SymbolicNameConfiguration HasSymbolicName(string symbolicName) + { + _symbolicName = symbolicName; + return this; + } + + /// + public override IEdmExpression ToEdmExpression() + { + return new EdmStringConstant(_symbolicName); + } + } +} diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/VocabularyTermConfigurationExtensions.cs b/src/Microsoft.OData.ModelBuilder/Vocabularies/VocabularyTermConfigurationExtensions.cs index 9a5208b..d3ed452 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/VocabularyTermConfigurationExtensions.cs +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/VocabularyTermConfigurationExtensions.cs @@ -164,15 +164,6 @@ public static SearchRestrictionsConfiguration HasSearchRestrictions(thi public static InsertRestrictionsConfiguration HasInsertRestrictions(this EntitySetConfiguration navigationSource) where TEntity : class => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); - /// - /// configuration - /// - /// The type of the structured type. - /// The that can be built using . - /// - public static InsertRestrictionsConfiguration HasInsertRestrictions(this EntityTypeConfiguration structuredType) where T : class - => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); - /// /// configuration /// @@ -191,15 +182,6 @@ public static DeepInsertSupportConfiguration HasDeepInsertSupport(this public static UpdateRestrictionsConfiguration HasUpdateRestrictions(this NavigationSourceConfiguration navigationSource) where TEntity : class => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); - /// - /// configuration - /// - /// The type of the structured type. - /// The that can be built using . - /// - public static UpdateRestrictionsConfiguration HasUpdateRestrictions(this EntityTypeConfiguration structuredType) where T : class - => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); - /// /// configuration /// @@ -218,15 +200,6 @@ public static DeepUpdateSupportConfiguration HasDeepUpdateSupport(this public static DeleteRestrictionsConfiguration HasDeleteRestrictions(this NavigationSourceConfiguration navigationSource) where TEntity : class => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); - /// - /// configuration - /// - /// The type of the structured type. - /// The that can be built using . - /// - public static DeleteRestrictionsConfiguration HasDeleteRestrictions(this EntityTypeConfiguration structuredType) where T : class - => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); - /// /// configuration /// @@ -278,6 +251,15 @@ public static ReadRestrictionsConfiguration HasReadRestrictions(this Na public static MediaLocationUpdateSupportedConfiguration HasMediaLocationUpdateSupported(this VocabularyConfigurationsBase vocabularyConfigurationsBase) => vocabularyConfigurationsBase?.VocabularyTermConfigurations.GetOrCreateConfiguration(); + /// + /// configuration + /// + /// The type of the structured type. + /// The that can be built using . + /// + public static MediaLocationUpdateSupportedConfiguration HasMediaLocationUpdateSupported(this EntityTypeConfiguration structuredType) where T : class + => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + /// /// configuration /// @@ -718,6 +700,15 @@ public static AcceptableMediaTypesConfiguration HasAcceptableMediaTypes(this public static MediaTypeConfiguration HasMediaType(this VocabularyConfigurationsBase vocabularyConfigurationsBase) => vocabularyConfigurationsBase?.VocabularyTermConfigurations.GetOrCreateConfiguration(); + /// + /// configuration + /// + /// The type of the structured type. + /// The that can be built using . + /// + public static MediaTypeConfiguration HasMediaType(this EntityTypeConfiguration structuredType) where T : class + => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + /// /// configuration /// @@ -726,6 +717,23 @@ public static MediaTypeConfiguration HasMediaType(this VocabularyConfigurationsB public static IsMediaTypeConfiguration HasIsMediaType(this VocabularyConfigurationsBase vocabularyConfigurationsBase) => vocabularyConfigurationsBase?.VocabularyTermConfigurations.GetOrCreateConfiguration(); + /// + /// configuration + /// + /// The that can be built using . + /// + public static ContentDispositionConfiguration HasContentDisposition(this VocabularyConfigurationsBase vocabularyConfigurationsBase) + => vocabularyConfigurationsBase?.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The type of the structured type. + /// The that can be built using . + /// + public static ContentDispositionConfiguration HasContentDisposition(this EntityTypeConfiguration structuredType) where T : class + => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + /// /// configuration /// @@ -752,6 +760,15 @@ public static AdditionalPropertiesConfiguration HasAdditionalProperties(this public static AutoExpandConfiguration HasAutoExpand(this VocabularyConfigurationsBase vocabularyConfigurationsBase) => vocabularyConfigurationsBase?.VocabularyTermConfigurations.GetOrCreateConfiguration(); + /// + /// configuration + /// + /// The type of the structured type. + /// The that can be built using . + /// + public static AutoExpandConfiguration HasAutoExpand(this EntityTypeConfiguration structuredType) where T : class + => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + /// /// configuration /// @@ -881,6 +898,101 @@ public static AlternateKeysConfiguration HasAlternateKeys(this EntityTypeConf public static OperationAvailableConfiguration HasOperationAvailable(this VocabularyConfigurationsBase vocabularyConfigurationsBase) => vocabularyConfigurationsBase?.VocabularyTermConfigurations.GetOrCreateConfiguration(); + /// + /// configuration + /// + /// The that can be built using . + /// + public static RequiresExplicitBindingConfiguration HasRequiresExplicitBinding(this VocabularyConfigurationsBase vocabularyConfigurationsBase) + => vocabularyConfigurationsBase?.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The entity type of the navigation source. + /// The that can be built using . + /// + public static ExplicitOperationBindingsConfiguration HasExplicitOperationBindings(this NavigationSourceConfiguration navigationSource) where TEntity : class + => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The that can be built using . + /// + public static ExplicitOperationBindingsConfiguration HasExplicitOperationBindings(this VocabularyConfigurationsBase vocabularyConfigurationsBase) + => vocabularyConfigurationsBase?.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The type of the structured type. + /// The that can be built using . + /// + public static ExplicitOperationBindingsConfiguration HasExplicitOperationBindings(this StructuralTypeConfiguration structuredType) where T : class + => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The entity type of the navigation source. + /// The that can be built using . + /// + public static SymbolicNameConfiguration HasSymbolicName(this NavigationSourceConfiguration navigationSource) where TEntity : class + => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The that can be built using . + /// + public static SymbolicNameConfiguration HasSymbolicName(this VocabularyConfigurationsBase vocabularyConfigurationsBase) + => vocabularyConfigurationsBase?.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The type of the structured type. + /// The that can be built using . + /// + public static SymbolicNameConfiguration HasSymbolicName(this StructuralTypeConfiguration structuredType) where T : class + => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The entity type of the navigation source. + /// The that can be built using . + /// + public static GeometryFeatureConfiguration HasGeometryFeature(this NavigationSourceConfiguration navigationSource) where TEntity : class + => navigationSource?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The that can be built using . + /// + public static GeometryFeatureConfiguration HasGeometryFeature(this VocabularyConfigurationsBase vocabularyConfigurationsBase) + => vocabularyConfigurationsBase?.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The type of the structured type. + /// The that can be built using . + /// + public static GeometryFeatureConfiguration HasGeometryFeature(this StructuralTypeConfiguration structuredType) where T : class + => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + + /// + /// configuration + /// + /// The type of the structured type. + /// The that can be built using . + /// + public static AnyStructureConfiguration HasAnyStructure(this StructuralTypeConfiguration structuredType) where T : class + => structuredType?.Configuration.VocabularyTermConfigurations.GetOrCreateConfiguration(); + /// /// Add vocabulary annotations to a model target. /// diff --git a/src/Microsoft.OData.ModelBuilder/Vocabularies/VocabularyTermConfigurationExtensions.tt b/src/Microsoft.OData.ModelBuilder/Vocabularies/VocabularyTermConfigurationExtensions.tt index 8cc8d8c..0e99225 100644 --- a/src/Microsoft.OData.ModelBuilder/Vocabularies/VocabularyTermConfigurationExtensions.tt +++ b/src/Microsoft.OData.ModelBuilder/Vocabularies/VocabularyTermConfigurationExtensions.tt @@ -1,7 +1,8 @@ <#@ template debug="false" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ assembly name="System.Runtime" #> -<#@ assembly name="$(NuGetPackageRoot)microsoft.odata.edm\7.9.0\lib\net45\Microsoft.OData.Edm.dll" #> +<#@ assembly name="System.Linq" #> +<#@ assembly name="System.Collections" #> <#@ import namespace="System.IO" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> @@ -296,7 +297,8 @@ class Manager : GeneratedTextTransformation public Manager(GeneratedTextTransformation transformation, IEdmModel model) { - _templateDirectory = Path.GetDirectoryName(transformation.Host.TemplateFile); + var fullFilePath = transformation.Host.ResolvePath("VocabularyTermConfigurationExtensions.tt"); + _templateDirectory = Path.GetDirectoryName(fullFilePath); _model = model; } @@ -886,6 +888,18 @@ using Microsoft.OData.Edm.Vocabularies; properties.Add(new EdmPropertyConstructor("<#= name #>", new EdmBooleanConstant(_<#= camelName #>.Value))); } +<#+ + } + else if (fullTypeName == "Edm.Geometry") + { +#> + if (_<#= camelName #> != null) + { + var formatter = Microsoft.Spatial.WellKnownTextSqlFormatter.Create(true); + string geometryValue = Microsoft.Spatial.FormatterExtensions.Write(formatter, _<#= camelName #>); + properties.Add(new EdmPropertyConstructor("<#= name #>", new EdmStringConstant(geometryValue))); + } + <#+ } else @@ -945,6 +959,9 @@ using Microsoft.OData.Edm.Vocabularies; case "Edm.PropertyPath": clrType = "EdmPropertyPathExpression"; break; + case "Edm.Geometry": + clrType = "Microsoft.Spatial.Geometry"; + break; default: clrType = name.Substring(name.LastIndexOf('.') + 1); break;