Add the root path with links

This commit is contained in:
Darrel Miller 2020-04-28 10:01:46 -04:00
parent a9278f0e29
commit 42d20b3f0d
2 changed files with 31 additions and 1 deletions

View file

@ -3,7 +3,9 @@
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// ------------------------------------------------------------
using System;
using System.Collections.Generic;
using Microsoft.OData.Edm;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.OData.Common;
using Microsoft.OpenApi.OData.Edm;
@ -44,7 +46,35 @@ namespace Microsoft.OpenApi.OData.Generator
pathItems.Add(path.GetPathItemName(settings), handler.CreatePathItem(context, path));
}
var rootPath = new OpenApiPathItem()
{
Operations = new Dictionary<OperationType, OpenApiOperation> {
{ OperationType.Get, new OpenApiOperation {
Responses = new OpenApiResponses()
{
{ "200",new OpenApiResponse() {
Description = "OK",
Links = CreateRootLinks(context.EntityContainer)
}
}
}
}
}
}
};
pathItems.Add("/", rootPath);
return pathItems;
}
private static IDictionary<string, OpenApiLink> CreateRootLinks(IEdmEntityContainer entityContainer)
{
var links = new Dictionary<string, OpenApiLink>();
foreach(var element in entityContainer.Elements)
{
links.Add(element.Name, new OpenApiLink());
}
return links;
}
}
}

View file

@ -13,7 +13,7 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>