resolve the comments
This commit is contained in:
parent
75738b8d30
commit
4ee734ffd3
|
@ -18,18 +18,18 @@ namespace Microsoft.OpenApi.OData
|
|||
/// Convert <see cref="IEdmModel"/> to <see cref="OpenApiDocument"/>.
|
||||
/// </summary>
|
||||
/// <param name="model">The Edm model.</param>
|
||||
/// <returns>The converted Open API document object.</returns>
|
||||
/// <returns>The converted Open API document object, <see cref="OpenApiDocument"/>.</returns>
|
||||
public static OpenApiDocument ConvertToOpenApi(this IEdmModel model)
|
||||
{
|
||||
return model.ConvertToOpenApi(new OpenApiConvertSettings());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert <see cref="IEdmModel"/> to <see cref="OpenApiDocument"/> using a configure action.
|
||||
/// Convert <see cref="IEdmModel"/> to <see cref="OpenApiDocument"/> using a convert settings.
|
||||
/// </summary>
|
||||
/// <param name="model">The Edm model.</param>
|
||||
/// <param name="configure">The configure action.</param>
|
||||
/// <returns>The converted Open API document object.</returns>
|
||||
/// <param name="settings">The convert settings.</param>
|
||||
/// <returns>The converted Open API document object, <see cref="OpenApiDocument"/>.</returns>
|
||||
public static OpenApiDocument ConvertToOpenApi(this IEdmModel model, OpenApiConvertSettings settings)
|
||||
{
|
||||
if (model == null)
|
||||
|
|
33
src/Microsoft.OpenApi.OData.Reader/Generator/Constants.cs
Normal file
33
src/Microsoft.OpenApi.OData.Reader/Generator/Constants.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
// ------------------------------------------------------------
|
||||
// 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.Generator
|
||||
{
|
||||
/// <summary>
|
||||
/// Constant strings
|
||||
/// </summary>
|
||||
internal static class Constants
|
||||
{
|
||||
/// <summary>
|
||||
/// application/json
|
||||
/// </summary>
|
||||
public static string ApplicationJsonMediaType = "application/json";
|
||||
|
||||
/// <summary>
|
||||
/// Status code: 200
|
||||
/// </summary>
|
||||
public static string StatusCode200 = "200";
|
||||
|
||||
/// <summary>
|
||||
/// Status code: 204
|
||||
/// </summary>
|
||||
public static string StatusCode204 = "204";
|
||||
|
||||
/// <summary>
|
||||
/// Status code: 204
|
||||
/// </summary>
|
||||
public static string StatusCodeDefault = "default";
|
||||
}
|
||||
}
|
|
@ -98,14 +98,14 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
operation.Responses = new OpenApiResponses
|
||||
{
|
||||
{
|
||||
"200",
|
||||
Constants.StatusCode200,
|
||||
new OpenApiResponse
|
||||
{
|
||||
Description = "Retrieved entities",
|
||||
Content = new Dictionary<string, OpenApiMediaType>
|
||||
{
|
||||
{
|
||||
"application/json",
|
||||
Constants.ApplicationJsonMediaType,
|
||||
new OpenApiMediaType
|
||||
{
|
||||
Schema = new OpenApiSchema
|
||||
|
@ -138,7 +138,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
}
|
||||
};
|
||||
|
||||
operation.Responses.Add("default", "default".GetResponse());
|
||||
operation.Responses.Add(Constants.StatusCodeDefault, Constants.StatusCodeDefault.GetResponse());
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
Content = new Dictionary<string, OpenApiMediaType>
|
||||
{
|
||||
{
|
||||
"application/json", new OpenApiMediaType
|
||||
Constants.ApplicationJsonMediaType, new OpenApiMediaType
|
||||
{
|
||||
Schema = new OpenApiSchema
|
||||
{
|
||||
|
@ -211,7 +211,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
Content = new Dictionary<string, OpenApiMediaType>
|
||||
{
|
||||
{
|
||||
"application/json",
|
||||
Constants.ApplicationJsonMediaType,
|
||||
new OpenApiMediaType
|
||||
{
|
||||
Schema = new OpenApiSchema
|
||||
|
@ -228,7 +228,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
}
|
||||
}
|
||||
};
|
||||
operation.Responses.Add("default", "default".GetResponse());
|
||||
operation.Responses.Add(Constants.StatusCodeDefault, Constants.StatusCodeDefault.GetResponse());
|
||||
|
||||
if (context.Settings.OperationId)
|
||||
{
|
||||
|
@ -287,14 +287,14 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
operation.Responses = new OpenApiResponses
|
||||
{
|
||||
{
|
||||
"200",
|
||||
Constants.StatusCode200,
|
||||
new OpenApiResponse
|
||||
{
|
||||
Description = "Retrieved entity",
|
||||
Content = new Dictionary<string, OpenApiMediaType>
|
||||
{
|
||||
{
|
||||
"application/json",
|
||||
Constants.ApplicationJsonMediaType,
|
||||
new OpenApiMediaType
|
||||
{
|
||||
Schema = new OpenApiSchema
|
||||
|
@ -311,7 +311,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
}
|
||||
}
|
||||
};
|
||||
operation.Responses.Add("default", "default".GetResponse());
|
||||
operation.Responses.Add(Constants.StatusCodeDefault, Constants.StatusCodeDefault.GetResponse());
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
Content = new Dictionary<string, OpenApiMediaType>
|
||||
{
|
||||
{
|
||||
"application/json", new OpenApiMediaType
|
||||
Constants.ApplicationJsonMediaType, new OpenApiMediaType
|
||||
{
|
||||
Schema = new OpenApiSchema
|
||||
{
|
||||
|
@ -385,8 +385,8 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
|
||||
operation.Responses = new OpenApiResponses
|
||||
{
|
||||
{ "204", "204".GetResponse() },
|
||||
{ "default", "default".GetResponse() }
|
||||
{ Constants.StatusCode204, Constants.StatusCode204.GetResponse() },
|
||||
{ Constants.StatusCodeDefault, Constants.StatusCodeDefault.GetResponse() }
|
||||
};
|
||||
|
||||
return operation;
|
||||
|
@ -446,8 +446,8 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
|
||||
operation.Responses = new OpenApiResponses
|
||||
{
|
||||
{ "204", "204".GetResponse() },
|
||||
{ "default", "default".GetResponse() }
|
||||
{ Constants.StatusCode204, Constants.StatusCode204.GetResponse() },
|
||||
{ Constants.StatusCodeDefault, Constants.StatusCodeDefault.GetResponse() }
|
||||
};
|
||||
return operation;
|
||||
}
|
||||
|
@ -501,14 +501,14 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
operation.Responses = new OpenApiResponses
|
||||
{
|
||||
{
|
||||
"200",
|
||||
Constants.StatusCode200,
|
||||
new OpenApiResponse
|
||||
{
|
||||
Description = "Retrieved entity",
|
||||
Content = new Dictionary<string, OpenApiMediaType>
|
||||
{
|
||||
{
|
||||
"application/json",
|
||||
Constants.ApplicationJsonMediaType,
|
||||
new OpenApiMediaType
|
||||
{
|
||||
Schema = new OpenApiSchema
|
||||
|
@ -525,7 +525,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
}
|
||||
},
|
||||
};
|
||||
operation.Responses.Add("default", "default".GetResponse());
|
||||
operation.Responses.Add(Constants.StatusCodeDefault, Constants.StatusCodeDefault.GetResponse());
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
@ -576,7 +576,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
Content = new Dictionary<string, OpenApiMediaType>
|
||||
{
|
||||
{
|
||||
"application/json", new OpenApiMediaType
|
||||
Constants.ApplicationJsonMediaType, new OpenApiMediaType
|
||||
{
|
||||
Schema = new OpenApiSchema
|
||||
{
|
||||
|
@ -593,8 +593,8 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
|
||||
operation.Responses = new OpenApiResponses
|
||||
{
|
||||
{ "204", "204".GetResponse() },
|
||||
{ "default", "default".GetResponse() }
|
||||
{ Constants.StatusCode204, Constants.StatusCode204.GetResponse() },
|
||||
{ Constants.StatusCodeDefault, Constants.StatusCodeDefault.GetResponse() }
|
||||
};
|
||||
|
||||
return operation;
|
||||
|
@ -674,8 +674,6 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
operation.Parameters.Add(parameter);
|
||||
}
|
||||
}
|
||||
|
||||
operation.Responses = context.CreateResponses(function);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -685,8 +683,6 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
// TODO: For bound actions on entities that use optimistic concurrency control,
|
||||
// i.e. require ETags for modification operations, the parameters array contains
|
||||
// a Parameter Object for the If-Match header.
|
||||
|
||||
operation.Responses = context.CreateResponses(action);
|
||||
}
|
||||
|
||||
// TODO: Depending on the result type of the bound action or function the parameters
|
||||
|
@ -696,11 +692,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
// describing the structure of the success response by referencing an appropriate schema
|
||||
// in the global schemas. In addition, it contains a default name/value pair for
|
||||
// the OData error response referencing the global responses.
|
||||
//operation.Responses = new OpenApiResponses
|
||||
//{
|
||||
// { "204", "204".GetResponse() },
|
||||
// { "default", "default".GetResponse() }
|
||||
//};
|
||||
operation.Responses = context.CreateResponses(edmOperation);
|
||||
|
||||
return operation;
|
||||
}
|
||||
|
|
|
@ -218,10 +218,10 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
OpenApiPathItem pathItem = context.CreatePathItem(navigationSource, operation);
|
||||
string pathName = context.CreatePathItemName(operation);
|
||||
|
||||
string temp;
|
||||
string entityPathName;
|
||||
if (entitySet != null)
|
||||
{
|
||||
temp = context.CreateEntityPathName(entitySet);
|
||||
entityPathName = context.CreateEntityPathName(entitySet);
|
||||
|
||||
OpenApiOperation openApiOperation = pathItem.Operations.First().Value;
|
||||
Debug.Assert(openApiOperation != null);
|
||||
|
@ -229,10 +229,10 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
}
|
||||
else
|
||||
{
|
||||
temp = "/" + navigationSource.Name;
|
||||
entityPathName = "/" + navigationSource.Name;
|
||||
}
|
||||
|
||||
operationPathItems.Add(temp + pathName, pathItem);
|
||||
operationPathItems.Add(entityPathName + pathName, pathItem);
|
||||
}
|
||||
|
||||
return operationPathItems;
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
Content = new Dictionary<string, OpenApiMediaType>()
|
||||
};
|
||||
|
||||
requestBody.Content.Add("application/json", new OpenApiMediaType
|
||||
requestBody.Content.Add(Constants.ApplicationJsonMediaType, new OpenApiMediaType
|
||||
{
|
||||
Schema = parametersSchema
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
private static IDictionary<string, OpenApiResponse> _responses =
|
||||
new Dictionary<string, OpenApiResponse>
|
||||
{
|
||||
{ "default",
|
||||
{ Constants.StatusCodeDefault,
|
||||
new OpenApiResponse
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
|
@ -28,7 +28,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
}
|
||||
},
|
||||
|
||||
{ "204", new OpenApiResponse { Description = "Success"} },
|
||||
{ Constants.StatusCode204, new OpenApiResponse { Description = "Success"} },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
@ -111,7 +111,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
|
||||
if (operation.IsAction())
|
||||
{
|
||||
responses.Add("204", "204".GetResponse());
|
||||
responses.Add(Constants.StatusCode204, Constants.StatusCode204.GetResponse());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
Content = new Dictionary<string, OpenApiMediaType>
|
||||
{
|
||||
{
|
||||
"application/json",
|
||||
Constants.ApplicationJsonMediaType,
|
||||
new OpenApiMediaType
|
||||
{
|
||||
Schema = context.CreateEdmTypeSchema(operation.ReturnType)
|
||||
|
@ -129,11 +129,11 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
}
|
||||
}
|
||||
};
|
||||
responses.Add("200", response);
|
||||
responses.Add(Constants.StatusCode200, response);
|
||||
}
|
||||
|
||||
// both action & function has the default response.
|
||||
responses.Add("default", "default".GetResponse());
|
||||
responses.Add(Constants.StatusCodeDefault, Constants.StatusCodeDefault.GetResponse());
|
||||
|
||||
return responses;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
Content = new Dictionary<string, OpenApiMediaType>
|
||||
{
|
||||
{
|
||||
"application/json",
|
||||
Constants.ApplicationJsonMediaType,
|
||||
new OpenApiMediaType
|
||||
{
|
||||
Schema = new OpenApiSchema
|
||||
|
|
|
@ -166,7 +166,12 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
return schema;
|
||||
}
|
||||
|
||||
// 4.6.1.1 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)
|
||||
{
|
||||
// The name is the property name, the value is a Schema Object describing the allowed values of the property.
|
||||
|
|
|
@ -35,28 +35,30 @@ namespace Microsoft.OpenApi.OData.Generator
|
|||
throw Error.ArgumentNull(nameof(entitySet));
|
||||
}
|
||||
|
||||
string keyString;
|
||||
StringBuilder sb = new StringBuilder("/" + entitySet.Name);
|
||||
IList<IEdmStructuralProperty> keys = entitySet.EntityType().Key().ToList();
|
||||
if (keys.Count() == 1)
|
||||
{
|
||||
keyString = "{" + keys.First().Name + "}";
|
||||
|
||||
if (context.Settings.KeyAsSegment)
|
||||
{
|
||||
return "/" + entitySet.Name + "/" + keyString;
|
||||
sb.Append("/{").Append(keys.First().Name).Append("}");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.Append("('{").Append(keys.First().Name).Append("}')");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IList<string> temps = new List<string>();
|
||||
IList<string> keyStrings = new List<string>();
|
||||
foreach (var keyProperty in entitySet.EntityType().Key())
|
||||
{
|
||||
temps.Add(keyProperty.Name + "={" + keyProperty.Name + "}");
|
||||
keyStrings.Add(keyProperty.Name + "={" + keyProperty.Name + "}");
|
||||
}
|
||||
keyString = String.Join(",", temps);
|
||||
sb.Append("('").Append(String.Join(",", keyStrings)).Append("')");
|
||||
}
|
||||
|
||||
return "/" + entitySet.Name + "('" + keyString + "')";
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -5,12 +5,12 @@ using System.Runtime.InteropServices;
|
|||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("OoasGui")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyTitle("OData to Open API GUI tool.")]
|
||||
[assembly: AssemblyDescription("A GUI tool used to convert OData CSDL to Open API document.")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("OoasGui")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2017")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
|
|
|
@ -1,122 +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 System.IO;
|
||||
using Microsoft.OpenApi.Interfaces;
|
||||
using Microsoft.OpenApi.Extensions;
|
||||
using Microsoft.OpenApi.Writers;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Tests
|
||||
{
|
||||
internal static class OpenApiWriterTestHelper
|
||||
{
|
||||
internal static string WriteToJson(this IOpenApiElement element,
|
||||
Action<IOpenApiWriter, IOpenApiElement> before = null,
|
||||
Action<IOpenApiWriter, IOpenApiElement> after = null)
|
||||
{
|
||||
Action<IOpenApiWriter> action = writer =>
|
||||
{
|
||||
before?.Invoke(writer, element);
|
||||
// element?(writer);
|
||||
after?.Invoke(writer, element);
|
||||
writer?.Flush();
|
||||
};
|
||||
|
||||
return Write(OpenApiFormat.Json, action);
|
||||
}
|
||||
|
||||
internal static string WriteToYaml(this IOpenApiElement element,
|
||||
Action<IOpenApiWriter, IOpenApiElement> before = null,
|
||||
Action<IOpenApiWriter, IOpenApiElement> after = null)
|
||||
{
|
||||
Action<IOpenApiWriter> action = writer =>
|
||||
{
|
||||
before?.Invoke(writer, element);
|
||||
//element?.Write(writer);
|
||||
after?.Invoke(writer, element);
|
||||
writer?.Flush();
|
||||
};
|
||||
|
||||
return Write(OpenApiFormat.Yaml, action);
|
||||
}
|
||||
|
||||
internal static string Write(this IOpenApiElement element,
|
||||
OpenApiFormat target,
|
||||
Action<IOpenApiWriter, IOpenApiElement> before = null,
|
||||
Action<IOpenApiWriter, IOpenApiElement> after = null)
|
||||
{
|
||||
Action<IOpenApiWriter> action = writer =>
|
||||
{
|
||||
before?.Invoke(writer, element);
|
||||
// element?.Write(writer);
|
||||
after?.Invoke(writer, element);
|
||||
writer?.Flush();
|
||||
};
|
||||
|
||||
return Write(target, action);
|
||||
}
|
||||
|
||||
internal static string Write(this Action<IOpenApiWriter> action, OpenApiFormat target)
|
||||
{
|
||||
MemoryStream stream = new MemoryStream();
|
||||
IOpenApiWriter writer;
|
||||
if (target == OpenApiFormat.Yaml)
|
||||
{
|
||||
writer = new OpenApiYamlWriter(new StreamWriter(stream));
|
||||
}
|
||||
else
|
||||
{
|
||||
writer = new OpenApiJsonWriter(new StreamWriter(stream));
|
||||
}
|
||||
|
||||
action(writer);
|
||||
writer.Flush();
|
||||
stream.Position = 0;
|
||||
return new StreamReader(stream).ReadToEnd();
|
||||
}
|
||||
|
||||
internal static string Write(OpenApiFormat target, Action<IOpenApiWriter> action)
|
||||
{
|
||||
MemoryStream stream = new MemoryStream();
|
||||
IOpenApiWriter writer;
|
||||
if (target == OpenApiFormat.Yaml)
|
||||
{
|
||||
writer = new OpenApiYamlWriter(new StreamWriter(stream));
|
||||
}
|
||||
else
|
||||
{
|
||||
writer = new OpenApiJsonWriter(new StreamWriter(stream));
|
||||
}
|
||||
|
||||
action(writer);
|
||||
writer.Flush();
|
||||
stream.Position = 0;
|
||||
return new StreamReader(stream).ReadToEnd();
|
||||
}
|
||||
|
||||
internal static string SerializeAsJson<T>(this T element)
|
||||
where T : IOpenApiSerializable
|
||||
{
|
||||
return element.Serialize(OpenApiFormat.Json);
|
||||
}
|
||||
|
||||
internal static string SerializeAsYaml<T>(this T element)
|
||||
where T : IOpenApiSerializable
|
||||
{
|
||||
return element.Serialize(OpenApiFormat.Yaml);
|
||||
}
|
||||
|
||||
internal static string Serialize<T>(this T element, OpenApiFormat format)
|
||||
where T : IOpenApiSerializable
|
||||
{
|
||||
MemoryStream stream = new MemoryStream();
|
||||
element.Serialize(stream, OpenApiSpecVersion.OpenApi3_0_0, format);
|
||||
stream.Position = 0;
|
||||
return new StreamReader(stream).ReadToEnd();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// ------------------------------------------------------------
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
|
||||
// ------------------------------------------------------------
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.OpenApi.OData.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension methods for the string in test.
|
||||
/// </summary>
|
||||
public static class StringExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Change the input string's line breaks
|
||||
/// </summary>
|
||||
/// <param name="rawString">The raw input string</param>
|
||||
/// <param name="newLine">The new line break.</param>
|
||||
/// <returns>The changed string.</returns>
|
||||
public static string ChangeLineBreaks(this string rawString, string newLine = "\n")
|
||||
{
|
||||
Assert.NotNull(rawString);
|
||||
rawString = rawString.Trim('\n', '\r');
|
||||
rawString = rawString.Replace("\r\n", newLine);
|
||||
return rawString;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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.Tests
|
||||
{
|
||||
public static class StringHelper
|
||||
{
|
||||
public static string Replace(this string rawString, string newLine = "\n")
|
||||
{
|
||||
rawString = rawString.Trim('\n', '\r');
|
||||
rawString = rawString.Replace("\r\n", newLine);
|
||||
return rawString;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,11 +15,22 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
public class EdmModelOpenApiExtensionsTest
|
||||
{
|
||||
private ITestOutputHelper _output;
|
||||
|
||||
public EdmModelOpenApiExtensionsTest(ITestOutputHelper output)
|
||||
{
|
||||
_output = output;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ConvertToOpenApiThrowsArgumentNullModel()
|
||||
{
|
||||
// Arrange
|
||||
IEdmModel model = null;
|
||||
|
||||
// Act & Assert
|
||||
Assert.Throws<ArgumentNullException>("model", () => model.ConvertToOpenApi());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmptyEdmModelToOpenApiJsonWorks()
|
||||
{
|
||||
|
@ -31,7 +42,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
_output.WriteLine(json);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Resources.GetString("Empty.OpenApi.json").Replace(), json);
|
||||
Assert.Equal(Resources.GetString("Empty.OpenApi.json").ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -45,7 +56,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
_output.WriteLine(yaml);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Resources.GetString("Empty.OpenApi.yaml").Replace(), yaml);
|
||||
Assert.Equal(Resources.GetString("Empty.OpenApi.yaml").ChangeLineBreaks(), yaml);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -59,7 +70,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
_output.WriteLine(json);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Resources.GetString("Basic.OpenApi.json").Replace(), json);
|
||||
Assert.Equal(Resources.GetString("Basic.OpenApi.json").ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -73,7 +84,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
_output.WriteLine(yaml);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Resources.GetString("Basic.OpenApi.yaml").Replace(), yaml);
|
||||
Assert.Equal(Resources.GetString("Basic.OpenApi.yaml").ChangeLineBreaks(), yaml);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -91,7 +102,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
_output.WriteLine(json);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Resources.GetString("TripService.OpenApi.json").Replace(), json);
|
||||
Assert.Equal(Resources.GetString("TripService.OpenApi.json").ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -111,13 +122,15 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
_output.WriteLine(yaml);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(Resources.GetString("TripService.OpenApi.yaml").Replace(), yaml);
|
||||
Assert.Equal(Resources.GetString("TripService.OpenApi.yaml").ChangeLineBreaks(), yaml);
|
||||
}
|
||||
|
||||
private static string WriteEdmModelAsOpenApi(IEdmModel model, OpenApiFormat target,
|
||||
OpenApiConvertSettings settings = null)
|
||||
{
|
||||
var document = model.ConvertToOpenApi(settings);
|
||||
Assert.NotNull(document); // guard
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
document.Serialize(stream, OpenApiSpecVersion.OpenApi3_0_0, target);
|
||||
stream.Flush();
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
],
|
||||
""nullable"": true
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -92,7 +92,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
""items"": {
|
||||
""$ref"": ""#/components/schemas/Microsoft.OData.Service.Sample.TrippinInMemory.Models.AirportLocation""
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -115,7 +115,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
""items"": {
|
||||
""type"": ""string""
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -142,7 +142,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
""format"": ""int32"",
|
||||
""nullable"": true
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
@ -267,13 +267,13 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.Equal(@"{
|
||||
""type"": ""string"",
|
||||
""nullable"": true
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.Equal(@"{
|
||||
""type"": ""string""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
""type"": ""integer"",
|
||||
""format"": ""int32"",
|
||||
""nullable"": true
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -310,7 +310,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
""minimum"": -2147483648,
|
||||
""type"": ""integer"",
|
||||
""format"": ""int32""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ description: Skip the first n items
|
|||
schema:
|
||||
minimum: 0
|
||||
type: integer
|
||||
".Replace(), yaml);
|
||||
".ChangeLineBreaks(), yaml);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ namespace Microsoft.OpenApi.OData.Generator.Tests
|
|||
}
|
||||
},
|
||||
""required"": true
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace Microsoft.OpenApi.OData.Generator.Tests
|
|||
}
|
||||
}
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -97,7 +97,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
},
|
||||
""description"": ""Complex type 'Address' description.""
|
||||
}"
|
||||
.Replace(), json);
|
||||
.ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -175,7 +175,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
}
|
||||
]
|
||||
}"
|
||||
.Replace(), json);
|
||||
.ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -225,7 +225,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
},
|
||||
""description"": ""Entity type 'Zoo' description.""
|
||||
}"
|
||||
.Replace(), json);
|
||||
.ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -293,7 +293,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
}
|
||||
]
|
||||
}"
|
||||
.Replace(), json);
|
||||
.ChangeLineBreaks(), json);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -353,7 +353,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
],
|
||||
""type"": ""string"",
|
||||
""description"": ""Enum type 'Color' description.""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -381,7 +381,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
}
|
||||
],
|
||||
""default"": ""yellow""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -408,7 +408,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
],
|
||||
""default"": ""yellow"",
|
||||
""nullable"": true
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -428,11 +428,11 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema);
|
||||
Assert.Equal("boolean", schema.Type);
|
||||
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
Assert.Equal(@"{
|
||||
""type"": ""boolean"",
|
||||
""default"": false
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -453,13 +453,13 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema);
|
||||
Assert.Equal("string", schema.Type);
|
||||
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
Assert.Equal(@"{
|
||||
""maxLength"": 44,
|
||||
""type"": ""string"",
|
||||
""format"": ""base64url"",
|
||||
""default"": ""T0RhdGE""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -478,14 +478,14 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema);
|
||||
Assert.Equal("integer", schema.Type);
|
||||
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
Assert.Equal(@"{
|
||||
""maximum"": 2147483647,
|
||||
""minimum"": -2147483648,
|
||||
""type"": ""integer"",
|
||||
""format"": ""int32"",
|
||||
""default"": -128
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -504,7 +504,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema);
|
||||
Assert.Null(schema.Type);
|
||||
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
Assert.Equal(@"{
|
||||
""oneOf"": [
|
||||
|
@ -524,7 +524,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
],
|
||||
""format"": ""double"",
|
||||
""default"": ""3.1415926535897931""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OpenApi.Extensions;
|
||||
using Microsoft.OpenApi.OData.Generator;
|
||||
using Xunit;
|
||||
|
||||
|
@ -87,12 +88,12 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
""$ref"": ""#/components/schemas/Edm.Geometry""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -103,12 +104,12 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
""$ref"": ""#/components/schemas/Edm.GeometryPoint""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -119,12 +120,12 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
""$ref"": ""#/components/schemas/Edm.GeometryLineString""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -135,12 +136,12 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
""$ref"": ""#/components/schemas/Edm.GeometryPolygon""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -151,12 +152,12 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
""$ref"": ""#/components/schemas/Edm.GeometryMultiPoint""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -167,12 +168,12 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
""$ref"": ""#/components/schemas/Edm.GeometryMultiLineString""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -183,12 +184,12 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
""$ref"": ""#/components/schemas/Edm.GeometryMultiPolygon""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -199,12 +200,12 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
""$ref"": ""#/components/schemas/Edm.GeometryCollection""
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -215,7 +216,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
|
@ -243,7 +244,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
""$ref"": ""#/components/schemas/Edm.GeometryCollection""
|
||||
}
|
||||
]
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -254,7 +255,7 @@ namespace Microsoft.OpenApi.OData.Tests
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string yaml = schema.SerializeAsYaml();
|
||||
string yaml = schema.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(
|
||||
|
@ -269,7 +270,7 @@ properties:
|
|||
type: string
|
||||
default: Point
|
||||
coordinates:
|
||||
$ref: '#/components/schemas/GeoJSON.position'".Replace(), yaml);
|
||||
$ref: '#/components/schemas/GeoJSON.position'".ChangeLineBreaks(), yaml);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -280,7 +281,7 @@ properties:
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
|
@ -303,7 +304,7 @@ properties:
|
|||
}
|
||||
}
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -314,7 +315,7 @@ properties:
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
|
@ -340,7 +341,7 @@ properties:
|
|||
}
|
||||
}
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -351,7 +352,7 @@ properties:
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
|
@ -373,7 +374,7 @@ properties:
|
|||
}
|
||||
}
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -384,7 +385,7 @@ properties:
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string yaml = schema.SerializeAsYaml();
|
||||
string yaml = schema.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"required:
|
||||
|
@ -401,7 +402,7 @@ properties:
|
|||
items:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/GeoJSON.position'".Replace(), yaml);
|
||||
$ref: '#/components/schemas/GeoJSON.position'".ChangeLineBreaks(), yaml);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -412,7 +413,7 @@ properties:
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
|
@ -441,7 +442,7 @@ properties:
|
|||
}
|
||||
}
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -452,7 +453,7 @@ properties:
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
|
@ -474,7 +475,7 @@ properties:
|
|||
}
|
||||
}
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -485,7 +486,7 @@ properties:
|
|||
Assert.NotNull(schema); // guard
|
||||
|
||||
// Act
|
||||
string json = schema.SerializeAsJson();
|
||||
string json = schema.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0_0);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(@"{
|
||||
|
@ -494,7 +495,7 @@ properties:
|
|||
""items"": {
|
||||
""type"": ""number""
|
||||
}
|
||||
}".Replace(), json);
|
||||
}".ChangeLineBreaks(), json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,6 @@
|
|||
<TargetFramework>net46</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="ODataOpenApiConvertTest.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Resources\Basic.OpenApi.json" />
|
||||
<None Remove="Resources\Basic.OpenApi.yaml" />
|
||||
|
@ -34,8 +30,8 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.0.0-beta007" />
|
||||
<PackageReference Include="xunit" Version="2.3.0-beta5-build3769" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta5-build3769" />
|
||||
<PackageReference Include="xunit" Version="2.3.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Loading…
Reference in a new issue