remove all the subfolders
This commit is contained in:
parent
15fd35b59a
commit
58202e29a4
|
@ -1,18 +0,0 @@
|
|||
//---------------------------------------------------------------------
|
||||
// <copyright file="IOpenApiElement.cs" company="Microsoft">
|
||||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Open API document element.
|
||||
/// </summary>
|
||||
internal interface IOpenApiDocumentGenerator
|
||||
{
|
||||
OpenApiDocument Generate();
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
//---------------------------------------------------------------------
|
||||
// <copyright file="IOpenApiExtensible.cs" company="Microsoft">
|
||||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Extensible Open API element.
|
||||
/// </summary>
|
||||
internal interface IOpenApiExtensible //: IOpenApiElement
|
||||
{
|
||||
/// <summary>
|
||||
/// Specification extensions.
|
||||
/// </summary>
|
||||
// IList<OpenApiExtension> Extensions { get; }
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
//---------------------------------------------------------------------
|
||||
// <copyright file="IOpenApiReferencable.cs" company="Microsoft">
|
||||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Open API element is referencable.
|
||||
/// </summary>
|
||||
internal interface IOpenApiReferencable //: IOpenApiElement
|
||||
{
|
||||
/// <summary>
|
||||
/// Reference object.
|
||||
/// </summary>
|
||||
// OpenApiReference Reference { get; }
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
//---------------------------------------------------------------------
|
||||
// <copyright file="IOpenApiWritable.cs" company="Microsoft">
|
||||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an Open API element is writable.
|
||||
/// </summary>
|
||||
internal interface IOpenApiWritable //: IOpenApiElement
|
||||
{
|
||||
/// <summary>
|
||||
/// Write Open API element.
|
||||
/// </summary>
|
||||
/// <param name="writer">The writer.</param>
|
||||
// void Write(IOpenApiWriter writer);
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
//---------------------------------------------------------------------
|
||||
// <copyright file="EnumerationExtensions.cs" company="Microsoft">
|
||||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Enumeration type extension methods.
|
||||
/// </summary>
|
||||
public static class EnumerationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets an attribute on an enum field value.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the attribute to retrieve.</typeparam>
|
||||
/// <param name="enumVal">The enum value.</param>
|
||||
/// <returns>The attribute of type <typeparam name="T"> or null.</returns>
|
||||
public static T GetAttributeOfType<T>(this Enum enumVal) where T : Attribute
|
||||
{
|
||||
Type type = enumVal.GetType();
|
||||
MemberInfo memInfo = type.GetMember(enumVal.ToString()).First();
|
||||
IEnumerable<T> attributes = memInfo.GetCustomAttributes<T>(false);
|
||||
return attributes.FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the enum display name.
|
||||
/// </summary>
|
||||
/// <param name="enumValue">The enum value.</param>
|
||||
/// <returns>
|
||||
/// Use <see cref="MetadataAttribute"/> if exists.
|
||||
/// Otherwise, use the standard string representation.
|
||||
/// </returns>
|
||||
public static string GetMetadataName(this Enum enumValue)
|
||||
{
|
||||
var attribute = enumValue.GetAttributeOfType<MetadataAttribute>();
|
||||
return attribute == null ? enumValue.ToString() : attribute.Name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
// ------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
|
||||
// ------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Open Api Data type metadata attribute.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
|
||||
internal class MetadataAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MetadataAttribute"/> class.
|
||||
/// </summary>
|
||||
/// <param name="name">The display name.</param>
|
||||
public MetadataAttribute(string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
throw Error.ArgumentNullOrEmpty(nameof(name));
|
||||
}
|
||||
|
||||
Name = name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The display Name.
|
||||
/// </summary>
|
||||
public string Name { get; }
|
||||
}
|
||||
}
|
|
@ -4,13 +4,13 @@
|
|||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System.Linq;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OData.Edm.Vocabularies;
|
||||
using Microsoft.OData.Edm.Vocabularies.V1;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Commons;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
|
@ -59,37 +59,5 @@ namespace Microsoft.OpenApi.OData
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetOpenApiTypeName(this IEdmTypeReference edmType)
|
||||
{
|
||||
Debug.Assert(edmType != null);
|
||||
|
||||
return edmType.Definition.GetOpenApiTypeName();
|
||||
}
|
||||
|
||||
public static string GetOpenApiTypeName(this IEdmType edmType)
|
||||
{
|
||||
Debug.Assert(edmType != null);
|
||||
|
||||
switch (edmType.TypeKind)
|
||||
{
|
||||
case EdmTypeKind.Collection:
|
||||
return AnyType.Array.GetDisplayName();
|
||||
|
||||
case EdmTypeKind.Complex:
|
||||
case EdmTypeKind.Entity:
|
||||
case EdmTypeKind.EntityReference:
|
||||
return AnyType.Object.GetDisplayName();
|
||||
|
||||
case EdmTypeKind.Enum:
|
||||
return "string";
|
||||
|
||||
case EdmTypeKind.Primitive:
|
||||
return ((IEdmPrimitiveType)(edmType)).GetOpenApiDataType().GetCommonName();
|
||||
|
||||
default:
|
||||
return AnyType.Null.GetDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,16 @@
|
|||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmModelOpenApiExtensions.cs" company="Microsoft">
|
||||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
// ------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
|
||||
// ------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
using Microsoft.OpenApi.OData.Generators;
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to convert <see cref="IEdmModel"/>
|
||||
/// to Open API document, <see cref="OpenApiDocument"/>.
|
||||
/// Extension methods to convert <see cref="IEdmModel"/> to <see cref="OpenApiDocument"/>.
|
||||
/// </summary>
|
||||
public static class EdmModelOpenApiMappingExtensions
|
||||
{
|
||||
|
@ -37,9 +33,7 @@ namespace Microsoft.OpenApi.OData
|
|||
}
|
||||
|
||||
OpenApiDocument document = model.CreateDocument();
|
||||
|
||||
configure(document);
|
||||
|
||||
return document;
|
||||
}
|
||||
|
|
@ -1,98 +0,0 @@
|
|||
//---------------------------------------------------------------------
|
||||
// <copyright file="EdmPrimitiveExtensions.cs" company="Microsoft">
|
||||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.OData.Edm;
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Edm primitive type extension methods.
|
||||
/// </summary>
|
||||
internal static class EdmPrimitiveExtensions
|
||||
{
|
||||
private static readonly Dictionary<EdmPrimitiveTypeKind, OpenApiDataTypeKind> _builtInTypesMapping =
|
||||
new Dictionary<EdmPrimitiveTypeKind, OpenApiDataTypeKind>
|
||||
{
|
||||
{ EdmPrimitiveTypeKind.None, OpenApiDataTypeKind.None },
|
||||
{ EdmPrimitiveTypeKind.Binary, OpenApiDataTypeKind.Binary },
|
||||
{ EdmPrimitiveTypeKind.Boolean, OpenApiDataTypeKind.Boolean },
|
||||
{ EdmPrimitiveTypeKind.Byte, OpenApiDataTypeKind.Byte },
|
||||
{ EdmPrimitiveTypeKind.DateTimeOffset, OpenApiDataTypeKind.DateTime }, // TODO:
|
||||
{ EdmPrimitiveTypeKind.Decimal, OpenApiDataTypeKind.Double },
|
||||
{ EdmPrimitiveTypeKind.Double, OpenApiDataTypeKind.Double },
|
||||
{ EdmPrimitiveTypeKind.Guid, OpenApiDataTypeKind.String }, // TODO:
|
||||
{ EdmPrimitiveTypeKind.Int16, OpenApiDataTypeKind.Integer },
|
||||
{ EdmPrimitiveTypeKind.Int32, OpenApiDataTypeKind.Integer },
|
||||
{ EdmPrimitiveTypeKind.Int64, OpenApiDataTypeKind.Long },
|
||||
{ EdmPrimitiveTypeKind.SByte, OpenApiDataTypeKind.Integer },
|
||||
{ EdmPrimitiveTypeKind.Single, OpenApiDataTypeKind.Float },
|
||||
{ EdmPrimitiveTypeKind.String, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.Stream, OpenApiDataTypeKind.String }, // TODO:
|
||||
{ EdmPrimitiveTypeKind.Duration, OpenApiDataTypeKind.DateTime },
|
||||
{ EdmPrimitiveTypeKind.Date, OpenApiDataTypeKind.DateTime },
|
||||
{ EdmPrimitiveTypeKind.TimeOfDay, OpenApiDataTypeKind.DateTime },
|
||||
|
||||
{ EdmPrimitiveTypeKind.Geography, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeographyPoint, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeographyLineString, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeographyPolygon, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeographyCollection, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeographyMultiPolygon, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeographyMultiLineString, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeographyMultiPoint, OpenApiDataTypeKind.String },
|
||||
|
||||
{ EdmPrimitiveTypeKind.Geometry, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeometryPoint, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeometryLineString, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeometryPolygon, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeometryCollection, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeometryMultiPolygon, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeometryMultiLineString, OpenApiDataTypeKind.String },
|
||||
{ EdmPrimitiveTypeKind.GeometryMultiPoint, OpenApiDataTypeKind.String },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Get Open Api Data type kind.
|
||||
/// </summary>
|
||||
/// <param name="primitiveType">The primitive type.</param>
|
||||
/// <returns>The Open Api Data type kind.</returns>
|
||||
public static OpenApiDataTypeKind GetOpenApiDataType(this IEdmPrimitiveTypeReference primitiveType)
|
||||
{
|
||||
if (primitiveType == null)
|
||||
{
|
||||
return OpenApiDataTypeKind.None;
|
||||
}
|
||||
|
||||
return GetOpenApiDataType(primitiveType.PrimitiveKind());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Open Api Data type kind.
|
||||
/// </summary>
|
||||
/// <param name="primitiveType">The primitive type.</param>
|
||||
/// <returns>The Open Api Data type kind.</returns>
|
||||
public static OpenApiDataTypeKind GetOpenApiDataType(this IEdmPrimitiveType typeReference)
|
||||
{
|
||||
if (typeReference == null)
|
||||
{
|
||||
return OpenApiDataTypeKind.None;
|
||||
}
|
||||
|
||||
return GetOpenApiDataType(typeReference.PrimitiveKind);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Open Api Data type kind.
|
||||
/// </summary>
|
||||
/// <param name="primitiveType">The primitive type kind.</param>
|
||||
/// <returns>The Open Api Data type kind.</returns>
|
||||
private static OpenApiDataTypeKind GetOpenApiDataType(this EdmPrimitiveTypeKind primitiveKind)
|
||||
{
|
||||
return _builtInTypesMapping[primitiveKind];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,11 +4,11 @@
|
|||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using Microsoft.OpenApi.OData.Properties;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Microsoft.OpenApi.OData.Properties;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Commons
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class for creating and unwrapping <see cref="Exception"/> instances.
|
|
@ -19,8 +19,16 @@
|
|||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Schema\**" />
|
||||
<EmbeddedResource Remove="Schema\**" />
|
||||
<None Remove="Schema\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="EdmElementOpenApiElementExtensions.cs" />
|
||||
<Compile Remove="EdmPrimitiveExtensions.cs" />
|
||||
<Compile Remove="OpenApiWriterSettings.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiComponents"/> by <see cref="IEdmModel"/>.
|
|
@ -1,165 +0,0 @@
|
|||
//---------------------------------------------------------------------
|
||||
// <copyright file="OpenApiDataTypeMetadataAttribute.cs" company="Microsoft">
|
||||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the Open Api Data type metadata attribute.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
|
||||
internal class OpenApiDataTypeMetadataAttribute : Attribute
|
||||
{
|
||||
/// <summary>
|
||||
/// Common Name.
|
||||
/// </summary>
|
||||
public string CommonName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Type name.
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Format name
|
||||
/// </summary>
|
||||
public string Format { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Comments.
|
||||
/// </summary>
|
||||
public string Comments { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Primitive Data Types in the Open Api Specification.
|
||||
/// </summary>
|
||||
internal enum OpenApiDataTypeKind
|
||||
{
|
||||
/// <summary>
|
||||
/// None.
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata]
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// Integer
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "integer", Type = "integer", Format = "int32", Comments = "signed 32 bits")]
|
||||
Integer,
|
||||
|
||||
/// <summary>
|
||||
/// Long
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "long", Type = "integer", Format = "int642", Comments = "signed 64 bits")]
|
||||
Long,
|
||||
|
||||
/// <summary>
|
||||
/// Float
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "float", Type = "number", Format = "float")]
|
||||
Float,
|
||||
|
||||
/// <summary>
|
||||
/// Double
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "double", Type = "number", Format = "double")]
|
||||
Double,
|
||||
|
||||
/// <summary>
|
||||
/// String
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "string", Type = "string")]
|
||||
String,
|
||||
|
||||
/// <summary>
|
||||
/// Byte
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "byte", Type = "string", Format = "byte", Comments = "base64 encoded characters")]
|
||||
Byte,
|
||||
|
||||
/// <summary>
|
||||
/// Binary
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "binary", Type = "string", Format = "binary", Comments = "any sequence of octets")]
|
||||
Binary,
|
||||
|
||||
/// <summary>
|
||||
/// Boolean
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "boolean", Type = "boolean")]
|
||||
Boolean,
|
||||
|
||||
/// <summary>
|
||||
/// Date
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "date", Type = "string", Format = "date", Comments = "As defined by full-date - RFC3339")]
|
||||
Date,
|
||||
|
||||
/// <summary>
|
||||
/// DateTime
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "dateTime", Type = "string", Format = "date-time", Comments = "As defined by date-time - RFC3339")]
|
||||
DateTime,
|
||||
|
||||
/// <summary>
|
||||
/// Password
|
||||
/// </summary>
|
||||
[OpenApiDataTypeMetadata(CommonName = "password", Type = "string", Format = "password", Comments = "A hint to UIs to obscure input")]
|
||||
Password
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for Open Api Data Type kind.
|
||||
/// </summary>
|
||||
internal static class OpenApiDataTypeKindExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the Common Name.
|
||||
/// </summary>
|
||||
/// <param name="kind">The Open Api data type kind.</param>
|
||||
/// <returns>The Common Name.</returns>
|
||||
public static string GetCommonName(this OpenApiDataTypeKind kind)
|
||||
{
|
||||
OpenApiDataTypeMetadataAttribute attribute = kind.GetAttributeOfType<OpenApiDataTypeMetadataAttribute>();
|
||||
return attribute?.CommonName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Type.
|
||||
/// </summary>
|
||||
/// <param name="kind">The Open Api data type kind.</param>
|
||||
/// <returns>The Type.</returns>
|
||||
public static string GetTypeName(this OpenApiDataTypeKind kind)
|
||||
{
|
||||
OpenApiDataTypeMetadataAttribute attribute = kind.GetAttributeOfType<OpenApiDataTypeMetadataAttribute>();
|
||||
return attribute?.Type;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Format.
|
||||
/// </summary>
|
||||
/// <param name="kind">The Open Api data type kind.</param>
|
||||
/// <returns>The Format.</returns>
|
||||
public static string GetFormat(this OpenApiDataTypeKind kind)
|
||||
{
|
||||
OpenApiDataTypeMetadataAttribute attribute = kind.GetAttributeOfType<OpenApiDataTypeMetadataAttribute>();
|
||||
return attribute?.Format;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the Comments.
|
||||
/// </summary>
|
||||
/// <param name="kind">The Open Api data type kind.</param>
|
||||
/// <returns>The Comments.</returns>
|
||||
public static string GetComments(this OpenApiDataTypeKind kind)
|
||||
{
|
||||
OpenApiDataTypeMetadataAttribute attribute = kind.GetAttributeOfType<OpenApiDataTypeMetadataAttribute>();
|
||||
return attribute?.Comments;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,9 +6,8 @@
|
|||
using System;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiDocument"/> by <see cref="IEdmModel"/>.
|
||||
|
@ -16,7 +15,7 @@ namespace Microsoft.OpenApi.OData.Generators
|
|||
internal static class OpenApiDocumentGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Create a <see cref="OpenApiDocument"/>.
|
||||
/// Create a <see cref="OpenApiDocument"/>, it's a single Open API Object
|
||||
/// </summary>
|
||||
/// <param name="model">The Edm model.</param>
|
||||
/// <returns>The <see cref="OpenApiDocument"/> object.</returns>
|
||||
|
@ -44,11 +43,11 @@ namespace Microsoft.OpenApi.OData.Generators
|
|||
|
||||
Servers = model.CreateServers(),
|
||||
|
||||
Tags = model.CreateTags(),
|
||||
|
||||
Paths = model.CreatePaths(),
|
||||
|
||||
Components = model.CreateComponents(),
|
||||
|
||||
Tags = model.CreateTags()
|
||||
};
|
||||
}
|
||||
}
|
|
@ -6,9 +6,8 @@
|
|||
using System.Linq;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiInfo"/> by <see cref="IEdmModel"/>.
|
|
@ -8,9 +8,8 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiOperation"/> by Edm elements.
|
|
@ -7,9 +7,8 @@ using System.Collections.Generic;
|
|||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiParameter"/>.
|
|
@ -9,9 +9,8 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiPathItem"/> by Edm elements.
|
|
@ -7,9 +7,8 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiPaths"/> by <see cref="IEdmModel"/>.
|
|
@ -6,9 +6,8 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiResponse"/> by <see cref="IEdmModel"/>.
|
|
@ -8,9 +8,8 @@ using System.Collections.Generic;
|
|||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiSchema"/> by <see cref="IEdmModel"/>.
|
|
@ -6,9 +6,8 @@
|
|||
using System.Collections.Generic;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiServer"/> by <see cref="IEdmModel"/>.
|
|
@ -7,9 +7,8 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods to create <see cref="OpenApiTag"/> by <see cref="IEdmModel"/>.
|
|
@ -1,20 +0,0 @@
|
|||
//---------------------------------------------------------------------
|
||||
// <copyright file="OpenApiWriterSettings.cs" company="Microsoft">
|
||||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
||||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration settings for OData to Open API writers.
|
||||
/// </summary>
|
||||
public sealed class OpenApiWriterSettings
|
||||
{
|
||||
public Uri BaseUri { get; set; } = new Uri("http://localhost");
|
||||
|
||||
public Version Version { get; set; } = new Version(1, 0, 1);
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
// ------------------------------------------------------------
|
||||
// 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.Schema
|
||||
{
|
||||
internal enum SchemaFormat
|
||||
{
|
||||
Duration,
|
||||
Double,
|
||||
UUID,
|
||||
Int8,
|
||||
Int16,
|
||||
Int64,
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
// ------------------------------------------------------------
|
||||
// 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.Schema
|
||||
{
|
||||
internal enum SchemaType
|
||||
{
|
||||
/// <summary>
|
||||
/// Object type.
|
||||
/// </summary>
|
||||
[Metadata("object")]
|
||||
Object,
|
||||
|
||||
/// <summary>
|
||||
/// Array type.
|
||||
/// </summary>
|
||||
[Metadata("array")]
|
||||
Array,
|
||||
|
||||
/// <summary>
|
||||
/// Integer type.
|
||||
/// </summary>
|
||||
[Metadata("integer")]
|
||||
Integer,
|
||||
|
||||
/// <summary>
|
||||
/// Boolean type.
|
||||
/// </summary>
|
||||
[Metadata("boolean")]
|
||||
Boolean,
|
||||
|
||||
/// <summary>
|
||||
/// Number type.
|
||||
/// </summary>
|
||||
[Metadata("number")]
|
||||
Number,
|
||||
|
||||
/// <summary>
|
||||
/// String type.
|
||||
/// </summary>
|
||||
[Metadata("string")]
|
||||
String
|
||||
}
|
||||
}
|
|
@ -8,9 +8,8 @@ using System.Collections.Generic;
|
|||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Generators
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
/// <summary>
|
||||
/// See https://github.com/oasis-tcs/odata-openapi/blob/master/examples/odata-definitions.json
|
|
@ -1,14 +0,0 @@
|
|||
|
||||
namespace Microsoft.OpenApi.OData
|
||||
{
|
||||
internal static class OpenApiElementValidator
|
||||
{
|
||||
public static void ValidateReference(this IOpenApiReferencable reference)
|
||||
{
|
||||
//if (reference != null && reference.Reference != null)
|
||||
//{
|
||||
// throw new OpenApiException(String.Format(SRResource.OpenApiObjectMarkAsReference, reference.GetType().Name));
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,19 +4,18 @@
|
|||
// </copyright>
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using Microsoft.OpenApi;
|
||||
using Microsoft.OpenApi.OData;
|
||||
using Microsoft.OpenApi.Writers;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.OpenApi.Interfaces;
|
||||
using Microsoft.OpenApi.Writers;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Tests
|
||||
{
|
||||
internal static class OpenApiWriterTestHelper
|
||||
{
|
||||
internal static string WriteToJson(this IOpenApiWritable element,
|
||||
Action<IOpenApiWriter, IOpenApiWritable> before = null,
|
||||
Action<IOpenApiWriter, IOpenApiWritable> after = null)
|
||||
internal static string WriteToJson(this IOpenApiElement element,
|
||||
Action<IOpenApiWriter, IOpenApiElement> before = null,
|
||||
Action<IOpenApiWriter, IOpenApiElement> after = null)
|
||||
{
|
||||
Action<IOpenApiWriter> action = writer =>
|
||||
{
|
||||
|
@ -29,9 +28,9 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
return Write(OpenApiFormat.Json, action);
|
||||
}
|
||||
|
||||
internal static string WriteToYaml(this IOpenApiWritable element,
|
||||
Action<IOpenApiWriter, IOpenApiWritable> before = null,
|
||||
Action<IOpenApiWriter, IOpenApiWritable> after = null)
|
||||
internal static string WriteToYaml(this IOpenApiElement element,
|
||||
Action<IOpenApiWriter, IOpenApiElement> before = null,
|
||||
Action<IOpenApiWriter, IOpenApiElement> after = null)
|
||||
{
|
||||
Action<IOpenApiWriter> action = writer =>
|
||||
{
|
||||
|
@ -44,10 +43,10 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
return Write(OpenApiFormat.Yaml, action);
|
||||
}
|
||||
|
||||
internal static string Write(this IOpenApiWritable element,
|
||||
internal static string Write(this IOpenApiElement element,
|
||||
OpenApiFormat target,
|
||||
Action<IOpenApiWriter, IOpenApiWritable> before = null,
|
||||
Action<IOpenApiWriter, IOpenApiWritable> after = null)
|
||||
Action<IOpenApiWriter, IOpenApiElement> before = null,
|
||||
Action<IOpenApiWriter, IOpenApiElement> after = null)
|
||||
{
|
||||
Action<IOpenApiWriter> action = writer =>
|
||||
{
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.OpenApi.OData.Commons;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Tests
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue