Skip to content

Commit ffb9bd0

Browse files
Merge pull request #1279 from microsoft/vnext
Master refresh
2 parents 27215dd + f7968be commit ffb9bd0

File tree

52 files changed

+1791
-481
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1791
-481
lines changed

.github/workflows/docker.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Check out the repo
1818
uses: actions/checkout@v3
1919
- name: Login to GitHub package feed
20-
uses: docker/login-action@v2.1.0
20+
uses: docker/login-action@v2.2.0
2121
with:
2222
username: ${{ secrets.ACR_USERNAME }}
2323
password: ${{ secrets.ACR_PASSWORD }}
@@ -30,13 +30,13 @@ jobs:
3030
id: getversion
3131
- name: Push to GitHub Packages - Nightly
3232
if: ${{ github.ref == 'refs/heads/vnext' }}
33-
uses: docker/build-push-action@v4.0.0
33+
uses: docker/build-push-action@v4.1.0
3434
with:
3535
push: true
3636
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
3737
- name: Push to GitHub Packages - Release
3838
if: ${{ github.ref == 'refs/heads/master' }}
39-
uses: docker/build-push-action@v4.0.0
39+
uses: docker/build-push-action@v4.1.0
4040
with:
4141
push: true
4242
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}

.vscode/launch.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,36 @@
55
// Use IntelliSense to find out which attributes exist for C# debugging
66
// Use hover for the description of the existing attributes
77
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
8-
"name": ".NET Core Launch (console)",
8+
"name": "Launch Hidi",
99
"type": "coreclr",
1010
"request": "launch",
1111
"preLaunchTask": "build",
1212
// If you have changed target frameworks, make sure to update the program path.
1313
"program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net7.0/Microsoft.OpenApi.Hidi.dll",
14-
"args": [],
14+
"args": ["plugin",
15+
"-m","C:\\Users\\darrmi\\src\\github\\microsoft\\openapi.net\\test\\Microsoft.OpenApi.Hidi.Tests\\UtilityFiles\\exampleapimanifest.json",
16+
"--of","./output"],
1517
"cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi",
1618
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
1719
"console": "internalConsole",
1820
"stopAtEntry": false
1921
},
22+
{
23+
// Use IntelliSense to find out which attributes exist for C# debugging
24+
// Use hover for the description of the existing attributes
25+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
26+
"name": "Launch Workbench",
27+
"type": "coreclr",
28+
"request": "launch",
29+
"preLaunchTask": "build",
30+
// If you have changed target frameworks, make sure to update the program path.
31+
"program": "${workspaceFolder}/src/Microsoft.OpenApi.WorkBench/bin/Debug/net7.0-windows/Microsoft.OpenApi.Workbench.exe",
32+
"args": [],
33+
"cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Workbench",
34+
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
35+
"console": "internalConsole",
36+
"stopAtEntry": false
37+
},
2038
{
2139
"name": ".NET Core Attach",
2240
"type": "coreclr",

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
|--|--|
77
|Models and Writers|[![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.svg)](https://www.nuget.org/packages/Microsoft.OpenApi/) |
88
|Readers | [![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.Readers.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.Readers/) |
9+
|Hidi|[![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.Hidi.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi/)
910

1011

1112
The **OpenAPI.NET** SDK contains a useful object model for OpenAPI documents in .NET along with common serializers to extract raw OpenAPI JSON and YAML documents from the model.
@@ -90,6 +91,28 @@ var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, Open
9091

9192
```
9293

94+
# Validating/Testing OpenAPI descriptions
95+
In order to test the validity of an OpenApi document, we avail the following tools:
96+
- [Microsoft.OpenApi.Hidi](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi)
97+
98+
A commandline tool for validating and transforming OpenAPI descriptions. [Installation guidelines and documentation](https://github.com/microsoft/OpenAPI.NET/blob/vnext/src/Microsoft.OpenApi.Hidi/readme.md)
99+
100+
- Microsoft.OpenApi.Workbench
101+
102+
A workbench tool consisting of a GUI where you can test and convert OpenAPI descriptions in both JSON and YAML from v2-->v3 and vice versa.
103+
104+
#### Installation guidelines:
105+
1. Clone the repo locally by running this command:
106+
`git clone https://github.com/microsoft/OpenAPI.NET.git`
107+
2. Open the solution file `(.sln)` in the root of the project with Visual Studio
108+
3. Navigate to the `src/Microsoft.OpenApi.Workbench` directory and set it as the startup project
109+
4. Run the project and you'll see a GUI pop up resembling the one below:
110+
111+
112+
<img src="https://user-images.githubusercontent.com/36787645/235884441-f45d2ef7-c27b-4e1a-a890-d6f7fbef87c3.png" width="700" height="500">
113+
114+
5. Copy and paste your OpenAPI descriptions in the **Input Content** window or paste the path to the descriptions file in the **Input File** textbox and click on `Convert` to render the results.
115+
93116
# Build Status
94117

95118
|**master**|
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
using System.Collections.Generic;
5+
using System.CommandLine;
6+
7+
namespace Microsoft.OpenApi.Hidi.Extensions
8+
{
9+
internal static class CommandExtensions
10+
{
11+
public static void AddOptions(this Command command, IReadOnlyList<Option> options)
12+
{
13+
foreach (var option in options)
14+
{
15+
command.AddOption(option);
16+
}
17+
}
18+
}
19+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.OpenApi.Any;
2+
using Microsoft.OpenApi.Interfaces;
3+
using System.Collections.Generic;
4+
5+
namespace Microsoft.OpenApi.Hidi.Extensions
6+
{
7+
internal static class OpenApiExtensibleExtensions
8+
{
9+
/// <summary>
10+
/// Gets an extension value from the extensions dictionary.
11+
/// </summary>
12+
/// <param name="extensions">A dictionary of <see cref="IOpenApiExtension"/>.</param>
13+
/// <param name="extensionKey">The key corresponding to the <see cref="IOpenApiExtension"/>.</param>
14+
/// <returns>A <see cref="string"/> value matching the provided extensionKey. Return null when extensionKey is not found. </returns>
15+
public static string GetExtension(this IDictionary<string, IOpenApiExtension> extensions, string extensionKey)
16+
{
17+
if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiString castValue)
18+
{
19+
return castValue.Value;
20+
}
21+
return default;
22+
}
23+
}
24+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace Microsoft.OpenApi.Hidi.Extensions
6+
{
7+
/// <summary>
8+
/// Extension class for <see cref="string"/>.
9+
/// </summary>
10+
internal static class StringExtensions
11+
{
12+
/// <summary>
13+
/// Checks if the specified searchValue is equal to the target string based on the specified <see cref="StringComparison"/>.
14+
/// </summary>
15+
/// <param name="target">The target string to commpare to.</param>
16+
/// <param name="searchValue">The search string to seek.</param>
17+
/// <param name="comparison">The <see cref="StringComparison"/> to use. This defaults to <see cref="StringComparison.OrdinalIgnoreCase"/>.</param>
18+
/// <returns>true if the searchValue parameter occurs within this string; otherwise, false.</returns>
19+
public static bool IsEquals(this string target, string searchValue, StringComparison comparison = StringComparison.OrdinalIgnoreCase)
20+
{
21+
if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(searchValue))
22+
{
23+
return false;
24+
}
25+
return target.Equals(searchValue, comparison);
26+
}
27+
28+
/// <summary>
29+
/// Splits the target string in substrings based on the specified char separator.
30+
/// </summary>
31+
/// <param name="target">The target string to split by char. </param>
32+
/// <param name="separator">The char separator.</param>
33+
/// <returns>An <see cref="IList{String}"/> containing substrings.</returns>
34+
public static IList<string> SplitByChar(this string target, char separator)
35+
{
36+
if (string.IsNullOrWhiteSpace(target))
37+
{
38+
return new List<string>();
39+
}
40+
return target.Split(new char[] { separator }, StringSplitOptions.RemoveEmptyEntries).ToList();
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)