/// <summary> /// Create a map of string/<see cref="OpenApiSchema"/> map for a <see cref="IEdmStructuredType"/>'s all properties. /// </summary> /// <param name="context">The OData context.</param> /// <param name="structuredType">The Edm structured type.</param> /// <returns>The created map of <see cref="OpenApiSchema"/>.</returns> public static IDictionary <string, OpenApiSchema> CreateStructuredTypePropertiesSchema(this ODataContext context, IEdmStructuredType structuredType) { Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(structuredType, nameof(structuredType)); // The name is the property name, the value is a Schema Object describing the allowed values of the property. IDictionary <string, OpenApiSchema> properties = new Dictionary <string, OpenApiSchema>(); // structure properties foreach (var property in structuredType.DeclaredStructuralProperties()) { // OpenApiSchema propertySchema = property.Type.CreateSchema(); // propertySchema.Default = property.DefaultValueString != null ? new OpenApiString(property.DefaultValueString) : null; properties.Add(property.Name, context.CreatePropertySchema(property)); } // navigation properties foreach (var property in structuredType.DeclaredNavigationProperties()) { OpenApiSchema propertySchema = context.CreateEdmTypeSchema(property.Type); properties.Add(property.Name, propertySchema); } return(properties); }
/// <summary> /// Create a map of string/<see cref="OpenApiSchema"/> map for a <see cref="IEdmStructuredType"/>'s all properties. /// </summary> /// <param name="context">The OData context.</param> /// <param name="structuredType">The Edm structured type.</param> /// <returns>The created map of <see cref="OpenApiSchema"/>.</returns> public static IDictionary <string, OpenApiSchema> CreateStructuredTypePropertiesSchema(this ODataContext context, IEdmStructuredType structuredType) { Utils.CheckArgumentNull(context, nameof(context)); Utils.CheckArgumentNull(structuredType, nameof(structuredType)); // The name is the property name, the value is a Schema Object describing the allowed values of the property. IDictionary <string, OpenApiSchema> properties = new Dictionary <string, OpenApiSchema>(); // structure properties foreach (var property in structuredType.DeclaredStructuralProperties()) { OpenApiSchema propertySchema = context.CreatePropertySchema(property); propertySchema.Description = context.Model.GetDescriptionAnnotation(property); propertySchema.Extensions.AddCustomAtributesToExtensions(context, property); properties.Add(property.Name, propertySchema); } // navigation properties foreach (var property in structuredType.DeclaredNavigationProperties()) { OpenApiSchema propertySchema = context.CreateEdmTypeSchema(property.Type); propertySchema.Description = context.Model.GetDescriptionAnnotation(property); propertySchema.Extensions.AddCustomAtributesToExtensions(context, property); properties.Add(property.Name, propertySchema); } return(properties); }
private IDictionary <string, OpenApiSchema> VisitStructuredTypeProperties(IEdmStructuredType structuredType) { IDictionary <string, OpenApiSchema> properties = new Dictionary <string, OpenApiSchema>(); foreach (var property in structuredType.DeclaredStructuralProperties()) { OpenApiSchema propertySchema = VisitTypeReference(property.Type); properties.Add(property.Name, propertySchema); } foreach (var property in structuredType.DeclaredNavigationProperties()) { OpenApiSchema propertySchema = VisitTypeReference(property.Type); properties.Add(property.Name, propertySchema); } return(properties); }