update to latest OpenApi dll and add the key as segment into context

This commit is contained in:
Sam Xu 2018-01-29 15:46:19 -08:00
parent 25851ec64e
commit dd72df735e
10 changed files with 36 additions and 9 deletions

View file

@ -12,6 +12,24 @@ namespace Microsoft.OpenApi.OData.Capabilities
{
internal static class CapabilitiesHelper
{
/// <summary>
/// Gets boolean value for term Org.OData.Core.V1.KeyAsSegmentSupported
/// </summary>
/// <param name="model">The model referenced to.</param>
/// <returns>Boolean for term Org.OData.Core.V1.KeyAsSegmentSupported</returns>
public static bool GetKeyAsSegmentSupported(this IEdmModel model)
{
Utils.CheckArgumentNull(model, nameof(model));
if (model.EntityContainer == null)
{
return false;
}
KeyAsSegmentSupported keyAsSegment = new KeyAsSegmentSupported(model, model.EntityContainer);
return keyAsSegment.Supported ?? false;
}
/// <summary>
/// Gets description for term Org.OData.Core.V1.Description from a target annotatable
/// </summary>

View file

@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.OData.Capabilities;
namespace Microsoft.OpenApi.OData.Generator
{
@ -15,6 +16,7 @@ namespace Microsoft.OpenApi.OData.Generator
internal class ODataContext
{
private IDictionary<IEdmTypeReference, IEdmOperation> _boundOperations;
private bool _keyAsSegmentSupported = false;
/// <summary>
/// Initializes a new instance of <see cref="ODataContext"/> class.
@ -38,6 +40,8 @@ namespace Microsoft.OpenApi.OData.Generator
EdmModelVisitor visitor = new EdmModelVisitor();
visitor.Visit(model);
IsSpatialTypeUsed = visitor.IsSpatialTypeUsed;
_keyAsSegmentSupported = settings.KeyAsSegment ?? model.GetKeyAsSegmentSupported();
}
/// <summary>
@ -56,6 +60,11 @@ namespace Microsoft.OpenApi.OData.Generator
}
}
/// <summary>
/// Gets the boolean value indicating to support key as segment.
/// </summary>
public bool KeyAsSegment => _keyAsSegmentSupported;
/// <summary>
/// Gets the value indicating the Edm spatial type used.
/// </summary>

View file

@ -39,7 +39,7 @@ namespace Microsoft.OpenApi.OData.Generator
IList<IEdmStructuralProperty> keys = entitySet.EntityType().Key().ToList();
if (keys.Count() == 1)
{
if (context.Settings.KeyAsSegment)
if (context.KeyAsSegment)
{
sb.Append("/{").Append(keys.First().Name).Append("}");
}

View file

@ -21,7 +21,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.OData.Edm" Version="7.3.1" />
<PackageReference Include="Microsoft.OpenApi" Version="1.0.0-beta010" />
<PackageReference Include="Microsoft.OpenApi" Version="1.0.0-beta012" />
</ItemGroup>
<ItemGroup>

View file

@ -25,7 +25,7 @@ namespace Microsoft.OpenApi.OData
/// <summary>
/// Gets/set a value indicating whether to output key as segment path.
/// </summary>
public bool KeyAsSegment { get; set; }
public bool? KeyAsSegment { get; set; }
/// <summary>
/// Gets/set a value indicating whether to output un-qualified operation call.

View file

@ -36,7 +36,7 @@
<HintPath>..\..\packages\Microsoft.OData.Edm.7.3.1\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.OpenApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3f5743946376f042, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.OpenApi.1.0.0-beta010\lib\net46\Microsoft.OpenApi.dll</HintPath>
<HintPath>..\..\packages\Microsoft.OpenApi.1.0.0-beta012\lib\net46\Microsoft.OpenApi.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.OData.Edm" version="7.3.1" targetFramework="net461" />
<package id="Microsoft.OpenApi" version="1.0.0-beta010" targetFramework="net461" />
<package id="Microsoft.OpenApi" version="1.0.0-beta012" targetFramework="net461" />
</packages>

View file

@ -35,8 +35,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="Microsoft.OpenApi" Version="1.0.0-beta010" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="Microsoft.OpenApi" Version="1.0.0-beta012" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>

View file

@ -36,7 +36,7 @@
<HintPath>..\..\packages\Microsoft.OData.Edm.7.3.1\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.OpenApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3f5743946376f042, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.OpenApi.1.0.0-beta010\lib\net46\Microsoft.OpenApi.dll</HintPath>
<HintPath>..\..\packages\Microsoft.OpenApi.1.0.0-beta012\lib\net46\Microsoft.OpenApi.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.OData.Edm" version="7.3.1" targetFramework="net461" />
<package id="Microsoft.OpenApi" version="1.0.0-beta010" targetFramework="net461" />
<package id="Microsoft.OpenApi" version="1.0.0-beta012" targetFramework="net461" />
</packages>