Move the update docs to tool subfolder

This commit is contained in:
Sam Xu 2018-09-24 14:31:53 -07:00
parent 9e3306e76d
commit 295b9d4685
6 changed files with 233 additions and 6 deletions

View file

@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OoasUtil", "src\OoasUtil\Oo
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OoasGui", "src\OoasGui\OoasGui.csproj", "{79B190E8-EDB0-4C03-8FD8-EB48E4807CFB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateDocs", "test\UpdateDocs\UpdateDocs.csproj", "{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -35,10 +33,6 @@ Global
{79B190E8-EDB0-4C03-8FD8-EB48E4807CFB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79B190E8-EDB0-4C03-8FD8-EB48E4807CFB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79B190E8-EDB0-4C03-8FD8-EB48E4807CFB}.Release|Any CPU.Build.0 = Release|Any CPU
{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -0,0 +1,97 @@
//---------------------------------------------------------------------
// <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;
using Microsoft.OpenApi.OData.Edm;
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"))
{
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;
}
}
}
}

View file

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
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("UpdateDocs")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UpdateDocs")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6d5453c2-e35f-4cc6-b774-4c676f5f33d1")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View file

@ -0,0 +1,64 @@
<?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')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}</ProjectGuid>
<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>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.OData.Edm, Version=7.5.0.20627, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.OData.Edm.7.5.0\lib\portable-net45+win8+wpa81\Microsoft.OData.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.OpenApi, Version=1.1.0.0, Culture=neutral, PublicKeyToken=3f5743946376f042, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.OpenApi.1.1.0\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" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</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>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View file

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2042
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateDocs", "UpdateDocs.csproj", "{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}"
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
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6D5453C2-E35F-4CC6-B774-4C676F5F33D1}.Release|Any CPU.Build.0 = Release|Any CPU
{B7A15A06-0B61-4557-9BD4-0E4F32DE119D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {620DD027-5C7A-4BF7-9F76-44FAC453F5D7}
EndGlobalSection
EndGlobal

View file

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