/// <summary>
        /// Create a <see cref="OpenApiSchema"/> for a <see cref="IEdmTypeReference"/>.
        /// </summary>
        /// <param name="context">The OData context.</param>
        /// <param name="edmTypeReference">The Edm type reference.</param>
        /// <returns>The created <see cref="OpenApiSchema"/>.</returns>
        public static OpenApiSchema CreateEdmTypeSchema(this ODataContext context, IEdmTypeReference edmTypeReference)
        {
            Utils.CheckArgumentNull(context, nameof(context));
            Utils.CheckArgumentNull(edmTypeReference, nameof(edmTypeReference));

            switch (edmTypeReference.TypeKind())
            {
            case EdmTypeKind.Collection:
                // Collection-valued structural and navigation are represented as Schema Objects of type array.
                // The value of the items keyword is a Schema Object specifying the type of the items.
                return(new OpenApiSchema
                {
                    Type = "array",
                    Items = context.CreateEdmTypeSchema(edmTypeReference.AsCollection().ElementType())
                });

            // Complex, enum, entity, entity reference are represented as JSON References to the Schema Object of the complex,
            // enum, entity and entity reference type, either as local references for types directly defined in the CSDL document,
            // or as external references for types defined in referenced CSDL documents.
            case EdmTypeKind.Complex:
            case EdmTypeKind.Entity:
                return(context.CreateStructuredTypeSchema(edmTypeReference.AsStructured()));

            case EdmTypeKind.Enum:
                return(context.CreateEnumTypeSchema(edmTypeReference.AsEnum()));

            // Primitive properties of type Edm.PrimitiveType, Edm.Stream, and any of the Edm.Geo* types are
            // represented as Schema Objects that are JSON References to definitions in the Definitions Object
            case EdmTypeKind.Primitive:
                IEdmPrimitiveTypeReference primitiveTypeReference = (IEdmPrimitiveTypeReference)edmTypeReference;
                return(context.CreateSchema(primitiveTypeReference));

            case EdmTypeKind.TypeDefinition:
                return(context.CreateSchema(((IEdmTypeDefinitionReference)edmTypeReference).TypeDefinition().UnderlyingType));

            case EdmTypeKind.EntityReference:
                return(context.CreateTypeDefinitionSchema(edmTypeReference.AsTypeDefinition()));

            case EdmTypeKind.None:
            default:
                throw Error.NotSupported(String.Format(SRResource.NotSupportedEdmTypeKind, edmTypeReference.TypeKind()));
            }
        }