Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master refresh #1279

Merged
merged 74 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
316c365
Bump Verify.Xunit from 19.13.1 to 19.14.1
dependabot[bot] May 2, 2023
8b7d1c8
Update README.md with guidelines on using workbench tool
MaggieKimani1 May 3, 2023
f80d52e
Update README.md
MaggieKimani1 May 3, 2023
9985902
Add OpenAPI formatter for PS
peombwa May 8, 2023
faf29de
Clean up Readme file
MaggieKimani1 May 9, 2023
75bb4ef
Merge pull request #1241 from microsoft/mk/update-documentation
MaggieKimani1 May 9, 2023
f4dee06
Use strongly typed config and options
peombwa May 10, 2023
10806b7
ISSUE-1131: Added diagnostic reporting recursive concatenation of dia…
elize-vdr May 11, 2023
4eff4c4
Move languageFormat to settings file
peombwa May 12, 2023
8bda200
Merge branch 'po/PowerShellSlicing' into po/PowerShellSlicingExtra
peombwa May 12, 2023
4fc2a75
Merge pull request #1237 from microsoft/dependabot/nuget/Verify.Xunit…
baywet May 13, 2023
86262b6
Added basic version of filter by manifest
darrelmiller May 15, 2023
83a15b5
ISSUE-1131: Added review improvements
elize-vdr May 15, 2023
50649b3
ISSUE #1228: Resolve path where it is an external reference
elize-vdr May 15, 2023
6a46338
ISSUE #1228: Add unit test for path external reference to ConvertToOp…
elize-vdr May 15, 2023
8d49857
Bump Microsoft.OData.Edm from 7.15.0 to 7.16.0
dependabot[bot] May 16, 2023
a2ff2d9
Bump Microsoft.NET.Test.Sdk from 17.5.0 to 17.6.0
dependabot[bot] May 16, 2023
3845be8
Merge pull request #1248 from microsoft/dependabot/nuget/Microsoft.NE…
baywet May 16, 2023
f1c89d8
Merge pull request #1247 from microsoft/dependabot/nuget/Microsoft.OD…
baywet May 16, 2023
88a0220
ISSUE-1131: Added 2nd review improvements
elize-vdr May 17, 2023
c329b37
ISSUE #1228: Changes for review comments
elize-vdr May 17, 2023
ca241c0
Updated with latest Apimanifest changes
darrelmiller May 21, 2023
26cac43
Bump coverlet.msbuild from 3.2.0 to 6.0.0
dependabot[bot] May 22, 2023
1ee0c61
Bump coverlet.collector from 3.2.0 to 6.0.0
dependabot[bot] May 22, 2023
0d88401
Merge pull request #1252 from microsoft/dependabot/nuget/coverlet.msb…
andrueastman May 23, 2023
58ccd91
Merge pull request #1253 from microsoft/dependabot/nuget/coverlet.col…
andrueastman May 23, 2023
85b3c0f
Started adding the plugin creation command
darrelmiller May 24, 2023
dc16fed
Merge remote-tracking branch 'origin/vnext' into po/PowerShellSlicing…
darrelmiller May 24, 2023
d1c6fca
Merge branch 'po/PowerShellSlicingExtra' into filterbymanifest
darrelmiller May 24, 2023
fd4c768
Merge branch 'filterbymanifest' into chatgpt
darrelmiller May 24, 2023
0f6a6ca
Added preview plugin command
darrelmiller May 30, 2023
bd3a51e
Changed project reference to package reference for manifest
darrelmiller May 31, 2023
d8fdc5a
Bump Microsoft.NET.Test.Sdk from 17.6.0 to 17.6.1
dependabot[bot] Jun 1, 2023
64499f6
Merge pull request #1259 from microsoft/dependabot/nuget/Microsoft.NE…
baywet Jun 1, 2023
7aefc0a
Fixed issues identified by sonarCube
darrelmiller Jun 2, 2023
fe2b6b9
Fixed more sonarcube issues
darrelmiller Jun 2, 2023
76dcb45
Code quality fixes.
darrelmiller Jun 2, 2023
7c71ad3
Returned OpenAPIService to be non-static due to logging issues
darrelmiller Jun 5, 2023
3cc169f
Bump Microsoft.NET.Test.Sdk from 17.6.1 to 17.6.2
dependabot[bot] Jun 6, 2023
891f257
Bump Verify.Xunit from 19.14.1 to 20.3.2
dependabot[bot] Jun 6, 2023
d2c7cbf
Merge pull request #1263 from microsoft/dependabot/nuget/Microsoft.NE…
baywet Jun 6, 2023
0178e88
Merge pull request #1264 from microsoft/dependabot/nuget/Verify.Xunit…
baywet Jun 6, 2023
0e13150
Merge remote-tracking branch 'origin/vnext' into feature/plugin
darrelmiller Jun 8, 2023
eb539de
Addressed code smell issues
darrelmiller Jun 8, 2023
5d6db61
Fixed more smells
darrelmiller Jun 9, 2023
7247f74
More smells
darrelmiller Jun 9, 2023
e833d1b
ISSUE-1228: Change char array to static readonly for path separator c…
BuzzyLizzy Jun 9, 2023
bab8a96
Shortened assignment of output folder
darrelmiller Jun 12, 2023
e5e6430
Bump docker/login-action from 2.1.0 to 2.2.0
dependabot[bot] Jun 12, 2023
56a7c96
Bump docker/build-push-action from 4.0.0 to 4.1.0
dependabot[bot] Jun 12, 2023
503cf84
Merge pull request #1266 from microsoft/dependabot/github_actions/doc…
andrueastman Jun 13, 2023
b1c42fe
Merge pull request #1267 from microsoft/dependabot/github_actions/doc…
andrueastman Jun 13, 2023
050dd51
Merge pull request #1246 from elize-vdr/ISSUE-#1228-Path-as-reference…
baywet Jun 13, 2023
c080552
Merge pull request #1245 from elize-vdr/ISSUE-1131
baywet Jun 13, 2023
bdfe5a1
Bump Microsoft.Extensions.Logging.Abstractions from 7.0.0 to 7.0.1
dependabot[bot] Jun 13, 2023
24de0ca
Bump Microsoft.Windows.Compatibility from 7.0.1 to 7.0.3
dependabot[bot] Jun 13, 2023
b906de1
Merge pull request #1269 from microsoft/dependabot/nuget/Microsoft.Wi…
baywet Jun 13, 2023
24ed6e3
Merge pull request #1268 from microsoft/dependabot/nuget/Microsoft.Ex…
baywet Jun 13, 2023
737d180
Clone extensions in the schema copy constructor
MaggieKimani1 Jun 14, 2023
7d0df91
Update public api
MaggieKimani1 Jun 14, 2023
e3c1f36
Use static lambda.
peombwa Jun 14, 2023
6cdb8f9
Apply suggestions from code review
peombwa Jun 14, 2023
a2ee29d
Separate concerns in OpenApiFilterService class.
peombwa Jun 14, 2023
3e4bf01
Add PowerShellFormatter tests.
peombwa Jun 14, 2023
ede77de
Update public api.
peombwa Jun 15, 2023
15b4c75
Add plugin command test.
peombwa Jun 15, 2023
ca33d2b
Merge pull request #1270 from microsoft/mk/fix-schema-copy-ctr
MaggieKimani1 Jun 15, 2023
02e3708
Bump up lib versions
MaggieKimani1 Jun 15, 2023
8f272aa
Bump up conversion lib
MaggieKimani1 Jun 15, 2023
038a356
Apply is operation suggestion.
peombwa Jun 15, 2023
181c6c3
Perform case-insensitive operationId and keyType match.
peombwa Jun 15, 2023
9d82233
Merge pull request #1258 from microsoft/feature/plugin
peombwa Jun 15, 2023
4a24112
Merge branch 'vnext' into mk/upgrade-libs
andrueastman Jun 16, 2023
f7968be
Merge pull request #1276 from microsoft/mk/upgrade-libs
MaggieKimani1 Jun 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v3
- name: Login to GitHub package feed
uses: docker/login-action@v2.1.0
uses: docker/login-action@v2.2.0
with:
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
Expand All @@ -30,13 +30,13 @@ jobs:
id: getversion
- name: Push to GitHub Packages - Nightly
if: ${{ github.ref == 'refs/heads/vnext' }}
uses: docker/build-push-action@v4.0.0
uses: docker/build-push-action@v4.1.0
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
- name: Push to GitHub Packages - Release
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v4.0.0
uses: docker/build-push-action@v4.1.0
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}
22 changes: 20 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,36 @@
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"name": "Launch Hidi",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net7.0/Microsoft.OpenApi.Hidi.dll",
"args": [],
"args": ["plugin",
"-m","C:\\Users\\darrmi\\src\\github\\microsoft\\openapi.net\\test\\Microsoft.OpenApi.Hidi.Tests\\UtilityFiles\\exampleapimanifest.json",
"--of","./output"],
"cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
"name": "Launch Workbench",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/src/Microsoft.OpenApi.WorkBench/bin/Debug/net7.0-windows/Microsoft.OpenApi.Workbench.exe",
"args": [],
"cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Workbench",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
|--|--|
|Models and Writers|[![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.svg)](https://www.nuget.org/packages/Microsoft.OpenApi/) |
|Readers | [![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.Readers.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.Readers/) |
|Hidi|[![nuget](https://img.shields.io/nuget/v/Microsoft.OpenApi.Hidi.svg)](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi/)


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.
Expand Down Expand Up @@ -90,6 +91,28 @@ var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, Open

```

# Validating/Testing OpenAPI descriptions
In order to test the validity of an OpenApi document, we avail the following tools:
- [Microsoft.OpenApi.Hidi](https://www.nuget.org/packages/Microsoft.OpenApi.Hidi)

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)

- Microsoft.OpenApi.Workbench

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.

#### Installation guidelines:
1. Clone the repo locally by running this command:
`git clone https://github.com/microsoft/OpenAPI.NET.git`
2. Open the solution file `(.sln)` in the root of the project with Visual Studio
3. Navigate to the `src/Microsoft.OpenApi.Workbench` directory and set it as the startup project
4. Run the project and you'll see a GUI pop up resembling the one below:


<img src="https://user-images.githubusercontent.com/36787645/235884441-f45d2ef7-c27b-4e1a-a890-d6f7fbef87c3.png" width="700" height="500">

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.

# Build Status

|**master**|
Expand Down
19 changes: 19 additions & 0 deletions src/Microsoft.OpenApi.Hidi/Extensions/CommandExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System.Collections.Generic;
using System.CommandLine;

namespace Microsoft.OpenApi.Hidi.Extensions
{
internal static class CommandExtensions
{
public static void AddOptions(this Command command, IReadOnlyList<Option> options)
{
foreach (var option in options)
{
command.AddOption(option);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.OpenApi.Any;
using Microsoft.OpenApi.Interfaces;
using System.Collections.Generic;

namespace Microsoft.OpenApi.Hidi.Extensions
{
internal static class OpenApiExtensibleExtensions
{
/// <summary>
/// Gets an extension value from the extensions dictionary.
/// </summary>
/// <param name="extensions">A dictionary of <see cref="IOpenApiExtension"/>.</param>
/// <param name="extensionKey">The key corresponding to the <see cref="IOpenApiExtension"/>.</param>
/// <returns>A <see cref="string"/> value matching the provided extensionKey. Return null when extensionKey is not found. </returns>
public static string GetExtension(this IDictionary<string, IOpenApiExtension> extensions, string extensionKey)
{
if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiString castValue)
{
return castValue.Value;
}
return default;
}
}
}
43 changes: 43 additions & 0 deletions src/Microsoft.OpenApi.Hidi/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;

namespace Microsoft.OpenApi.Hidi.Extensions
{
/// <summary>
/// Extension class for <see cref="string"/>.
/// </summary>
internal static class StringExtensions
{
/// <summary>
/// Checks if the specified searchValue is equal to the target string based on the specified <see cref="StringComparison"/>.
/// </summary>
/// <param name="target">The target string to commpare to.</param>
/// <param name="searchValue">The search string to seek.</param>
/// <param name="comparison">The <see cref="StringComparison"/> to use. This defaults to <see cref="StringComparison.OrdinalIgnoreCase"/>.</param>
/// <returns>true if the searchValue parameter occurs within this string; otherwise, false.</returns>
public static bool IsEquals(this string target, string searchValue, StringComparison comparison = StringComparison.OrdinalIgnoreCase)
{
if (string.IsNullOrWhiteSpace(target) || string.IsNullOrWhiteSpace(searchValue))
{
return false;
}
return target.Equals(searchValue, comparison);
}

/// <summary>
/// Splits the target string in substrings based on the specified char separator.
/// </summary>
/// <param name="target">The target string to split by char. </param>
/// <param name="separator">The char separator.</param>
/// <returns>An <see cref="IList{String}"/> containing substrings.</returns>
public static IList<string> SplitByChar(this string target, char separator)
{
if (string.IsNullOrWhiteSpace(target))
{
return new List<string>();
}
return target.Split(new char[] { separator }, StringSplitOptions.RemoveEmptyEntries).ToList();
}
}
}
Loading