add the tool project to update the docs folder automatically

This commit is contained in:
Sam Xu 2018-01-19 10:52:51 -08:00
parent 6b965f5af2
commit 5292794f4b
17 changed files with 4849 additions and 3842 deletions

View file

@ -11,6 +11,8 @@ 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
@ -33,6 +35,10 @@ 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

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -38,7 +38,7 @@
},
{
"name": "$orderby",
"in": "Query",
"in": "query",
"description": "Order items by property values",
"type": "array",
"items": {
@ -71,7 +71,7 @@
},
{
"name": "$select",
"in": "Query",
"in": "query",
"description": "Select properties to be returned",
"type": "array",
"items": {
@ -86,14 +86,17 @@
"AddressInfo",
"HomeAddress",
"FavoriteFeature",
"Features"
"Features",
"Friends",
"BestFriend",
"Trips"
],
"type": "string"
}
},
{
"name": "$expand",
"in": "Query",
"in": "query",
"description": "Expand related entities",
"type": "array",
"items": {
@ -111,7 +114,7 @@
"200": {
"description": "Retrieved entities",
"schema": {
"title": "Collection of People",
"title": "Collection of Person",
"type": "object",
"properties": {
"value": {
@ -174,14 +177,14 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
},
{
"name": "$select",
"in": "Query",
"in": "query",
"description": "Select properties to be returned",
"type": "array",
"items": {
@ -196,14 +199,17 @@
"AddressInfo",
"HomeAddress",
"FavoriteFeature",
"Features"
"Features",
"Friends",
"BestFriend",
"Trips"
],
"type": "string"
}
},
{
"name": "$expand",
"in": "Query",
"in": "query",
"description": "Expand related entities",
"type": "array",
"items": {
@ -240,7 +246,7 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
@ -271,14 +277,14 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
},
{
"name": "If-Match",
"in": "Header",
"in": "header",
"description": "ETag",
"type": "string"
}
@ -305,7 +311,7 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
@ -334,7 +340,7 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
@ -366,7 +372,7 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
@ -398,7 +404,7 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
@ -460,7 +466,7 @@
},
{
"name": "$orderby",
"in": "Query",
"in": "query",
"description": "Order items by property values",
"type": "array",
"items": {
@ -475,7 +481,7 @@
},
{
"name": "$select",
"in": "Query",
"in": "query",
"description": "Select properties to be returned",
"type": "array",
"items": {
@ -488,7 +494,7 @@
},
{
"name": "$expand",
"in": "Query",
"in": "query",
"description": "Expand related entities",
"type": "array",
"items": {
@ -503,7 +509,7 @@
"200": {
"description": "Retrieved entities",
"schema": {
"title": "Collection of Airlines",
"title": "Collection of Airline",
"type": "object",
"properties": {
"value": {
@ -566,14 +572,14 @@
"parameters": [
{
"name": "AirlineCode",
"in": "Path",
"in": "path",
"description": "key: AirlineCode",
"required": true,
"type": "string"
},
{
"name": "$select",
"in": "Query",
"in": "query",
"description": "Select properties to be returned",
"type": "array",
"items": {
@ -586,7 +592,7 @@
},
{
"name": "$expand",
"in": "Query",
"in": "query",
"description": "Expand related entities",
"type": "array",
"items": {
@ -620,7 +626,7 @@
"parameters": [
{
"name": "AirlineCode",
"in": "Path",
"in": "path",
"description": "key: AirlineCode",
"required": true,
"type": "string"
@ -651,14 +657,14 @@
"parameters": [
{
"name": "AirlineCode",
"in": "Path",
"in": "path",
"description": "key: AirlineCode",
"required": true,
"type": "string"
},
{
"name": "If-Match",
"in": "Header",
"in": "header",
"description": "ETag",
"type": "string"
}
@ -700,7 +706,7 @@
},
{
"name": "$orderby",
"in": "Query",
"in": "query",
"description": "Order items by property values",
"type": "array",
"items": {
@ -719,7 +725,7 @@
},
{
"name": "$select",
"in": "Query",
"in": "query",
"description": "Select properties to be returned",
"type": "array",
"items": {
@ -734,7 +740,7 @@
},
{
"name": "$expand",
"in": "Query",
"in": "query",
"description": "Expand related entities",
"type": "array",
"items": {
@ -749,7 +755,7 @@
"200": {
"description": "Retrieved entities",
"schema": {
"title": "Collection of Airports",
"title": "Collection of Airport",
"type": "object",
"properties": {
"value": {
@ -812,14 +818,14 @@
"parameters": [
{
"name": "IcaoCode",
"in": "Path",
"in": "path",
"description": "key: IcaoCode",
"required": true,
"type": "string"
},
{
"name": "$select",
"in": "Query",
"in": "query",
"description": "Select properties to be returned",
"type": "array",
"items": {
@ -834,7 +840,7 @@
},
{
"name": "$expand",
"in": "Query",
"in": "query",
"description": "Expand related entities",
"type": "array",
"items": {
@ -868,7 +874,7 @@
"parameters": [
{
"name": "IcaoCode",
"in": "Path",
"in": "path",
"description": "key: IcaoCode",
"required": true,
"type": "string"
@ -899,14 +905,14 @@
"parameters": [
{
"name": "IcaoCode",
"in": "Path",
"in": "path",
"description": "key: IcaoCode",
"required": true,
"type": "string"
},
{
"name": "If-Match",
"in": "Header",
"in": "header",
"description": "ETag",
"type": "string"
}
@ -948,7 +954,7 @@
},
{
"name": "$orderby",
"in": "Query",
"in": "query",
"description": "Order items by property values",
"type": "array",
"items": {
@ -981,7 +987,7 @@
},
{
"name": "$select",
"in": "Query",
"in": "query",
"description": "Select properties to be returned",
"type": "array",
"items": {
@ -996,14 +1002,17 @@
"AddressInfo",
"HomeAddress",
"FavoriteFeature",
"Features"
"Features",
"Friends",
"BestFriend",
"Trips"
],
"type": "string"
}
},
{
"name": "$expand",
"in": "Query",
"in": "query",
"description": "Expand related entities",
"type": "array",
"items": {
@ -1021,7 +1030,7 @@
"200": {
"description": "Retrieved entities",
"schema": {
"title": "Collection of NewComePeople",
"title": "Collection of Person",
"type": "object",
"properties": {
"value": {
@ -1084,14 +1093,14 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
},
{
"name": "$select",
"in": "Query",
"in": "query",
"description": "Select properties to be returned",
"type": "array",
"items": {
@ -1106,14 +1115,17 @@
"AddressInfo",
"HomeAddress",
"FavoriteFeature",
"Features"
"Features",
"Friends",
"BestFriend",
"Trips"
],
"type": "string"
}
},
{
"name": "$expand",
"in": "Query",
"in": "query",
"description": "Expand related entities",
"type": "array",
"items": {
@ -1150,7 +1162,7 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
@ -1181,14 +1193,14 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
},
{
"name": "If-Match",
"in": "Header",
"in": "header",
"description": "ETag",
"type": "string"
}
@ -1215,7 +1227,7 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
@ -1244,7 +1256,7 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
@ -1276,7 +1288,7 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
@ -1308,7 +1320,7 @@
"parameters": [
{
"name": "UserName",
"in": "Path",
"in": "path",
"description": "key: UserName",
"required": true,
"type": "string"
@ -1355,7 +1367,7 @@
"parameters": [
{
"name": "$select",
"in": "Query",
"in": "query",
"description": "Select properties to be returned",
"type": "array",
"items": {
@ -1370,14 +1382,17 @@
"AddressInfo",
"HomeAddress",
"FavoriteFeature",
"Features"
"Features",
"Friends",
"BestFriend",
"Trips"
],
"type": "string"
}
},
{
"name": "$expand",
"in": "Query",
"in": "query",
"description": "Expand related entities",
"type": "array",
"items": {
@ -1463,7 +1478,7 @@
"parameters": [
{
"name": "userName",
"in": "Path",
"in": "path",
"required": true,
"type": "string"
}
@ -1494,7 +1509,7 @@
"parameters": [
{
"name": "lastName",
"in": "Path",
"in": "path",
"required": true,
"type": "string"
}
@ -1585,13 +1600,13 @@
"parameters": [
{
"name": "lat",
"in": "Path",
"in": "path",
"required": true,
"format": "double"
},
{
"name": "lon",
"in": "Path",
"in": "path",
"required": true,
"format": "double"
}
@ -1640,7 +1655,8 @@
},
"Gender": { },
"Age": {
"format": "int64"
"format": "int64",
"type": "integer"
},
"Emails": {
"type": "array",
@ -1898,7 +1914,8 @@
"type": "object",
"properties": {
"Cost": {
"format": "int64"
"format": "int64",
"type": "integer"
},
"Peers": {
"type": "array",
@ -1920,7 +1937,8 @@
"type": "object",
"properties": {
"Budget": {
"format": "int64"
"format": "int64",
"type": "integer"
},
"BossOffice": { },
"DirectReports": {
@ -2202,33 +2220,33 @@
"parameters": {
"top": {
"name": "$top",
"in": "Query",
"in": "query",
"description": "Show only the first n items",
"type": "integer",
"minimum": 0
},
"skip": {
"name": "$skip",
"in": "Query",
"in": "query",
"description": "Skip the first n items",
"type": "integer",
"minimum": 0
},
"count": {
"name": "$count",
"in": "Query",
"in": "query",
"description": "Include count of items",
"type": "boolean"
},
"filter": {
"name": "$filter",
"in": "Query",
"in": "query",
"description": "Filter items by property values",
"type": "string"
},
"search": {
"name": "$search",
"in": "Query",
"in": "query",
"description": "Search items by search phrases",
"type": "string"
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,86 @@
//---------------------------------------------------------------------
// <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 Microsoft.OData.Edm;
using Microsoft.OData.Edm.Csdl;
using Microsoft.OpenApi;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.OData;
using Microsoft.OpenApi.Extensions;
using System;
using System.IO;
using System.Xml.Linq;
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.ServiceRoot = new Uri("https://graph.microsoft.com/beta");
}
else if (fileName.Contains("graph1.0"))
{
settings.ServiceRoot = new Uri("https://graph.microsoft.com/1.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));
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\net46\</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.3.1.10814, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<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>
</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,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" />
</packages>