commit
13427946de
|
@ -29,6 +29,11 @@ variables:
|
|||
|
||||
steps:
|
||||
|
||||
- task: UseDotNet@2
|
||||
displayName: 'Use .NET 6'
|
||||
inputs:
|
||||
version: 6.x
|
||||
|
||||
- task: PoliCheck@1
|
||||
displayName: 'Run PoliCheck "OpenApi.OData-master\src"'
|
||||
inputs:
|
||||
|
|
|
@ -27,6 +27,11 @@ variables:
|
|||
|
||||
steps:
|
||||
|
||||
- task: UseDotNet@2
|
||||
displayName: 'Use .NET 6'
|
||||
inputs:
|
||||
version: 6.x
|
||||
|
||||
- task: PoliCheck@1
|
||||
displayName: 'Run PoliCheck ".\src"'
|
||||
inputs:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Microsoft.OpenApi.OData.Reader</AssemblyName>
|
||||
|
@ -19,12 +19,12 @@
|
|||
<Import Project="..\Build.props" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.2">
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="3.3.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.OData.Edm" Version="7.6.1" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.2.2" />
|
||||
<PackageReference Include="Microsoft.OData.Edm" Version="7.9.4" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.2.3" />
|
||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
|
||||
</startup>
|
||||
</configuration>
|
|
@ -16,9 +16,9 @@ using System.Text;
|
|||
using Microsoft.OpenApi.Extensions;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData;
|
||||
using System.Net;
|
||||
using System.Xml;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace OoasGui
|
||||
{
|
||||
|
@ -120,6 +120,8 @@ namespace OoasGui
|
|||
}
|
||||
}
|
||||
|
||||
private static HttpClient client = new();
|
||||
|
||||
private async void loadBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
string url = urlTextBox.Text;
|
||||
|
@ -136,15 +138,10 @@ namespace OoasGui
|
|||
requestUri = new Uri(url + "/$metadata");
|
||||
}
|
||||
|
||||
WebRequest request = WebRequest.Create(requestUri);
|
||||
HttpResponseMessage response = await client.GetAsync(requestUri);
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
string csdl = await response.Content.ReadAsStringAsync();
|
||||
|
||||
Stream receivedStream = response.GetResponseStream();
|
||||
|
||||
StreamReader reader = new StreamReader(receivedStream, Encoding.UTF8);
|
||||
|
||||
string csdl = reader.ReadToEnd();
|
||||
LoadEdm(url, csdl);
|
||||
csdlRichTextBox.Text = FormatXml(csdl);
|
||||
Settings.ServiceRoot = requestUri;
|
||||
|
|
|
@ -1,98 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{79B190E8-EDB0-4C03-8FD8-EB48E4807CFB}</ProjectGuid>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>OoasGui</RootNamespace>
|
||||
<AssemblyName>OoasGui</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.OData.Edm, Version=7.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.OData.Edm.7.6.1\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.OpenApi, Version=1.2.2.0, Culture=neutral, PublicKeyToken=3f5743946376f042, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.OpenApi.1.2.2\lib\net46\Microsoft.OpenApi.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="MainForm.resx">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="..\..\.editorconfig">
|
||||
<Link>.editorconfig</Link>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<ProjectReference Include="..\Microsoft.OpenApi.OData.Reader\Microsoft.OpenApi.OData.Reader.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Microsoft.OpenApi.OData.Reader\Microsoft.OpenApi.OData.Reader.csproj">
|
||||
<Project>{ff3acd93-19e0-486c-9c0f-fa1c2e7fc8c2}</Project>
|
||||
<Name>Microsoft.OpenApi.OData.Reader</Name>
|
||||
</ProjectReference>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="Microsoft.OData.Edm" Version="7.9.4" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.2.3" />
|
||||
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.OData.Edm" version="7.9.4" targetFramework="net461" />
|
||||
<package id="Microsoft.OpenApi" version="1.2.3" targetFramework="net472" />
|
||||
</packages>
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OData.Edm.Csdl;
|
||||
using Microsoft.OpenApi;
|
||||
using Microsoft.OpenApi.OData;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OoasUtil
|
||||
{
|
||||
|
@ -44,20 +43,17 @@ namespace OoasUtil
|
|||
/// </summary>
|
||||
protected override IEdmModel GetEdmModel()
|
||||
{
|
||||
Uri requestUri = new Uri(Input.OriginalString + "/$metadata");
|
||||
Uri requestUri = new (Input.OriginalString + "/$metadata");
|
||||
|
||||
WebRequest request = WebRequest.Create(requestUri);
|
||||
|
||||
WebResponse response = request.GetResponse();
|
||||
|
||||
Stream receivedStream = response.GetResponseStream();
|
||||
|
||||
StreamReader reader = new StreamReader(receivedStream, Encoding.UTF8);
|
||||
|
||||
string csdl = reader.ReadToEnd();
|
||||
string csdl = GetModelDocumentAsync(requestUri).GetAwaiter().GetResult();
|
||||
|
||||
return CsdlReader.Parse(XElement.Parse(csdl).CreateReader());
|
||||
}
|
||||
private async Task<string> GetModelDocumentAsync(Uri requestUri) {
|
||||
HttpResponseMessage response = await client.GetAsync(requestUri);
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
private static readonly HttpClient client = new ();
|
||||
|
||||
protected override void ModifySettings()
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Microsoft.OpenApi.OData.Reader.Tests</AssemblyName>
|
||||
<RootNamespace>Microsoft.OpenApi.OData.Reader.Tests</RootNamespace>
|
||||
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
|
||||
<TargetFrameworks>net472;net6.0</TargetFrameworks>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>..\..\tool\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
|
||||
<DelaySign>true</DelaySign>
|
||||
|
@ -61,10 +61,10 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.2.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.2.3" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace UpdateDocs
|
|||
output = oas20 + "/" + fileName + ".json";
|
||||
File.WriteAllText(output, document.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0));
|
||||
|
||||
Console.WriteLine("Output [ " + fileName + " ] Succeessful!");
|
||||
Console.WriteLine("Output [ " + fileName + " ] Successful!");
|
||||
}
|
||||
|
||||
Console.WriteLine("\n==> All Done!");
|
||||
|
|
|
@ -1,64 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}</ProjectGuid>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>UpdateDocs</RootNamespace>
|
||||
<AssemblyName>UpdateDocs</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\net461\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.OData.Edm, Version=7.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.OData.Edm.7.6.1\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.OpenApi, Version=1.2.2.0, Culture=neutral, PublicKeyToken=3f5743946376f042, processorArchitecture=MSIL">
|
||||
<HintPath>packages\Microsoft.OpenApi.1.2.2\lib\net46\Microsoft.OpenApi.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<ProjectReference Include="..\..\src\Microsoft.OpenApi.OData.Reader\Microsoft.OpenApi.OData.Reader.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.OpenApi.OData.Reader\Microsoft.OpenApi.OData.Reader.csproj">
|
||||
<Project>{ff3acd93-19e0-486c-9c0f-fa1c2e7fc8c2}</Project>
|
||||
<Name>Microsoft.OpenApi.OData.Reader</Name>
|
||||
</ProjectReference>
|
||||
<PackageReference Include="Microsoft.OData.Edm" Version="7.9.4" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.2.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -7,8 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateDocs", "UpdateDocs.cs
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.OData.Reader", "..\..\src\Microsoft.OpenApi.OData.Reader\Microsoft.OpenApi.OData.Reader.csproj", "{B7A15A06-0B61-4557-9BD4-0E4F32DE119D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateDocsCore", "..\UpdateDocsCore\UpdateDocsCore.csproj", "{810B988E-24A2-4B6F-8FD3-B5B9FB25A44B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -23,10 +21,6 @@ Global
|
|||
{B7A15A06-0B61-4557-9BD4-0E4F32DE119D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B7A15A06-0B61-4557-9BD4-0E4F32DE119D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B7A15A06-0B61-4557-9BD4-0E4F32DE119D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{810B988E-24A2-4B6F-8FD3-B5B9FB25A44B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{810B988E-24A2-4B6F-8FD3-B5B9FB25A44B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{810B988E-24A2-4B6F-8FD3-B5B9FB25A44B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{810B988E-24A2-4B6F-8FD3-B5B9FB25A44B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.OData.Edm" version="7.6.1" targetFramework="net461" />
|
||||
<package id="Microsoft.OpenApi" version="1.2.2" targetFramework="net461" />
|
||||
</packages>
|
|
@ -1,98 +0,0 @@
|
|||
//---------------------------------------------------------------------
|
||||
// <copyright file="Program.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.IO;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.OData.Edm;
|
||||
using Microsoft.OData.Edm.Csdl;
|
||||
using Microsoft.OpenApi;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.OpenApi.OData;
|
||||
using Microsoft.OpenApi.Extensions;
|
||||
|
||||
namespace UpdateDocs
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static int Main(string[] args)
|
||||
{
|
||||
// we assume the path are existed for simplicity.
|
||||
string path = Directory.GetCurrentDirectory();
|
||||
string csdl = path + "/../../../../../docs/csdl";
|
||||
string oas20 = path + "/../../../../../docs/oas_2_0";
|
||||
string oas30 = path + "/../../../../../docs/oas3_0_0";
|
||||
|
||||
foreach (var filePath in Directory.GetFiles(csdl, "*.xml"))
|
||||
{
|
||||
Console.WriteLine(filePath);
|
||||
|
||||
IEdmModel model = LoadEdmModel(filePath);
|
||||
if (model == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
FileInfo fileInfo = new FileInfo(filePath);
|
||||
string fileName = fileInfo.Name.Substring(0, fileInfo.Name.Length - 4);
|
||||
|
||||
OpenApiConvertSettings settings = new OpenApiConvertSettings();
|
||||
if (fileName.Contains("graph.beta"))
|
||||
{
|
||||
settings.PrefixEntityTypeNameBeforeKey = true;
|
||||
settings.ServiceRoot = new Uri("https://graph.microsoft.com/beta");
|
||||
}
|
||||
else if (fileName.Contains("graph1.0"))
|
||||
{
|
||||
settings.PrefixEntityTypeNameBeforeKey = true;
|
||||
settings.ServiceRoot = new Uri("https://graph.microsoft.com/v1.0");
|
||||
}
|
||||
|
||||
OpenApiDocument document = model.ConvertToOpenApi(settings);
|
||||
|
||||
string output;/* = oas20 + "/" + fileName + ".yaml";
|
||||
File.WriteAllText(output, document.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0));
|
||||
|
||||
output = oas20 + "/" + fileName + ".json";
|
||||
File.WriteAllText(output, document.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0));
|
||||
|
||||
output = oas30 + "/" + fileName + ".yaml";
|
||||
File.WriteAllText(output, document.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0));
|
||||
|
||||
output = oas30 + "/" + fileName + ".json";
|
||||
File.WriteAllText(output, document.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0));
|
||||
*/
|
||||
settings.EnableKeyAsSegment = true;
|
||||
settings.EnableUnqualifiedCall = true;
|
||||
output = oas30 + "/" + fileName + ".json";
|
||||
document = model.ConvertToOpenApi(settings);
|
||||
File.WriteAllText(output, document.SerializeAsJson(OpenApiSpecVersion.OpenApi3_0));
|
||||
|
||||
output = oas20 + "/" + fileName + ".json";
|
||||
File.WriteAllText(output, document.SerializeAsJson(OpenApiSpecVersion.OpenApi2_0));
|
||||
|
||||
Console.WriteLine("Output [ " + fileName + " ] Succeessful!");
|
||||
}
|
||||
|
||||
Console.WriteLine("\n==> All Done!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static IEdmModel LoadEdmModel(string file)
|
||||
{
|
||||
try
|
||||
{
|
||||
string csdl = File.ReadAllText(file);
|
||||
return CsdlReader.Parse(XElement.Parse(csdl).CreateReader());
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("Cannot load EDM from file: " + file);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Microsoft.OpenApi.OData.Reader\Microsoft.OpenApi.OData.Reader.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in a new issue