Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2c64dad
Add an optional --terse output commandline option
MaggieKimani1 Apr 13, 2022
2bf6b36
Add a terse object to the OpenApiWriterSettings
MaggieKimani1 Apr 13, 2022
afba9d8
Pass the terseOutput option provided to the OpenApiWriter settings fo…
MaggieKimani1 Apr 13, 2022
de72343
Update the command format to kebab case
MaggieKimani1 Apr 13, 2022
11c3466
Add check to prevent null reference exceptions when settings are null
MaggieKimani1 Apr 14, 2022
41c1983
Update public api interface
MaggieKimani1 Apr 14, 2022
540b624
Add a terseOutput parameter to the OpenApiJsonWriter and refactor code
MaggieKimani1 Apr 14, 2022
13e8888
Clean up
MaggieKimani1 Apr 14, 2022
ad5c872
Merge pull request #835 from microsoft/master
darrelmiller Apr 19, 2022
84ed1bc
Merge pull request #831 from microsoft/mk/add-terse-param
darrelmiller Apr 19, 2022
1a63ab8
Bump github/codeql-action from 1 to 2
dependabot[bot] Apr 25, 2022
4d256e5
Bump Verify from 16.5.4 to 16.7.0
dependabot[bot] Apr 29, 2022
8f52708
Bump Microsoft.OpenApi.OData from 1.0.10-preview3 to 1.0.10
dependabot[bot] May 10, 2022
64730ef
Merge pull request #852 from microsoft/dependabot/nuget/Microsoft.Ope…
baywet May 11, 2022
1fd8b8e
Bump Microsoft.OData.Edm from 7.10.0 to 7.11.0
dependabot[bot] May 11, 2022
fcb7fd1
Merge pull request #844 from microsoft/dependabot/nuget/Verify-16.7.0
baywet May 11, 2022
9ec47d0
Merge pull request #838 from microsoft/dependabot/github_actions/gith…
baywet May 11, 2022
731a2f4
Bump Verify.Xunit from 16.5.4 to 16.7.0
dependabot[bot] May 11, 2022
7ce406f
Bump xunit.runner.visualstudio from 2.4.3 to 2.4.5
dependabot[bot] May 11, 2022
3ce1566
Bump SharpYaml from 1.9.0 to 1.9.1
dependabot[bot] May 11, 2022
3b66e24
- bumps hidi version
baywet May 11, 2022
b2f2783
Merge pull request #843 from microsoft/dependabot/nuget/Microsoft.ODa…
baywet May 11, 2022
8c3ecf4
Merge pull request #849 from microsoft/dependabot/nuget/xunit.runner.…
baywet May 11, 2022
6dff962
Merge pull request #845 from microsoft/dependabot/nuget/Verify.Xunit-…
baywet May 11, 2022
ee11f67
Merge pull request #851 from microsoft/dependabot/nuget/SharpYaml-1.9.1
baywet May 11, 2022
f06e828
Merge pull request #854 from microsoft/baywet-patch-1
baywet May 11, 2022
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
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- name: Initialize CodeQL
id: init_codeql
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
queries: security-and-quality

Expand All @@ -43,6 +43,6 @@ jobs:

- name: Perform CodeQL Analysis
id: analyze_codeql
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2

# Built with ❤ by [Pipeline Foundation](https://pipeline.foundation)
10 changes: 5 additions & 5 deletions src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
<PackageId>Microsoft.OpenApi.Hidi</PackageId>
<ToolCommandName>hidi</ToolCommandName>
<PackageOutputPath>./../../artifacts</PackageOutputPath>
<Version>1.0.0-preview1</Version>
<Version>1.0.0-preview2</Version>
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<PackageTags>OpenAPI .NET</PackageTags>
<RepositoryUrl>https://github.com/Microsoft/OpenAPI.NET</RepositoryUrl>
<PackageReleaseNotes>
- Upgrades Microsoft.OpenApi.OData to 1.0.10-preview1
- Fixes an issue where hidi would not process async operations
- Upgrades Microsoft.OpenApi.OData to 1.0.10
- Upgrades Microsoft.OData.Edm to 7.11.0
</PackageReleaseNotes>
<AssemblyName>Microsoft.OpenApi.Hidi</AssemblyName>
<RootNamespace>Microsoft.OpenApi.Hidi</RootNamespace>
Expand All @@ -45,8 +45,8 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta3.22114.1" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.10.0" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.10-preview3" />
<PackageReference Include="Microsoft.OData.Edm" Version="7.11.0" />
<PackageReference Include="Microsoft.OpenApi.OData" Version="1.0.10" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Microsoft.OpenApi.Hidi/OpenApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static async Task<int> TransformOpenApiDocument(
bool cleanoutput,
string? version,
OpenApiFormat? format,
bool terseOutput,
LogLevel loglevel,
bool inlineLocal,
bool inlineExternal,
Expand Down Expand Up @@ -196,7 +197,7 @@ CancellationToken cancellationToken

IOpenApiWriter writer = openApiFormat switch
{
OpenApiFormat.Json => new OpenApiJsonWriter(textWriter, settings),
OpenApiFormat.Json => terseOutput ? new OpenApiJsonWriter(textWriter, settings, terseOutput) : new OpenApiJsonWriter(textWriter, settings, false),
OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings),
_ => throw new ArgumentException("Unknown format"),
};
Expand Down
8 changes: 6 additions & 2 deletions src/Microsoft.OpenApi.Hidi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ static async Task Main(string[] args)
var formatOption = new Option<OpenApiFormat?>("--format", "File format");
formatOption.AddAlias("-f");

var terseOutputOption = new Option<bool>("--terse-output", "Produce terse json output");
terseOutputOption.AddAlias("-to");

var logLevelOption = new Option<LogLevel>("--loglevel", () => LogLevel.Information, "The log level to use when logging messages to the main output.");
logLevelOption.AddAlias("-ll");

Expand Down Expand Up @@ -74,6 +77,7 @@ static async Task Main(string[] args)
cleanOutputOption,
versionOption,
formatOption,
terseOutputOption,
logLevelOption,
filterByOperationIdsOption,
filterByTagsOption,
Expand All @@ -82,8 +86,8 @@ static async Task Main(string[] args)
inlineExternalOption
};

transformCommand.SetHandler<string, string, string, FileInfo, bool, string?, OpenApiFormat?, LogLevel, bool, bool, string, string, string, CancellationToken> (
OpenApiService.TransformOpenApiDocument, descriptionOption, csdlOption, csdlFilterOption, outputOption, cleanOutputOption, versionOption, formatOption, logLevelOption, inlineLocalOption, inlineExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption);
transformCommand.SetHandler<string, string, string, FileInfo, bool, string?, OpenApiFormat?, bool, LogLevel, bool, bool, string, string, string, CancellationToken> (
OpenApiService.TransformOpenApiDocument, descriptionOption, csdlOption, csdlFilterOption, outputOption, cleanOutputOption, versionOption, formatOption, terseOutputOption, logLevelOption, inlineLocalOption, inlineExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption);

rootCommand.Add(transformCommand);
rootCommand.Add(validateCommand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="SharpYaml" Version="1.9.0" />
<PackageReference Include="SharpYaml" Version="1.9.1" />
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 6 additions & 12 deletions src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,14 @@ public static void Serialize<T>(
throw Error.ArgumentNull(nameof(stream));
}

IOpenApiWriter writer;
var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture);
switch (format)
{
case OpenApiFormat.Json:
writer = new OpenApiJsonWriter(streamWriter,settings);
break;
case OpenApiFormat.Yaml:
writer = new OpenApiYamlWriter(streamWriter, settings);
break;
default:
throw new OpenApiException(string.Format(SRResource.OpenApiFormatNotSupported, format));
}

IOpenApiWriter writer = format switch
{
OpenApiFormat.Json => new OpenApiJsonWriter(streamWriter, settings, false),
OpenApiFormat.Yaml => new OpenApiYamlWriter(streamWriter, settings),
_ => throw new OpenApiException(string.Format(SRResource.OpenApiFormatNotSupported, format)),
};
element.Serialize(writer, specVersion);
}

Expand Down
4 changes: 3 additions & 1 deletion src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ public OpenApiJsonWriter(TextWriter textWriter, OpenApiJsonWriterSettings settin
/// </summary>
/// <param name="textWriter">The text writer.</param>
/// <param name="settings">Settings for controlling how the OpenAPI document will be written out.</param>
public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings) : base(textWriter, settings)
/// <param name="terseOutput"> Setting for allowing the JSON emitted to be in terse format.</param>
public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings, bool terseOutput = false) : base(textWriter, settings)
{
_produceTerseOutput = terseOutput;
}

/// <summary>
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public ReferenceInlineSetting ReferenceInline {
/// </summary>
public bool InlineExternalReferences { get; set; } = false;


internal bool ShouldInlineReference(OpenApiReference reference)
{
return (reference.IsLocal && InlineLocalReferences)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1">
</PackageReference>
<PackageReference Include="SharpYaml" Version="1.9.0">
<PackageReference Include="SharpYaml" Version="1.9.1">
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1">
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
8 changes: 4 additions & 4 deletions test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Moq" Version="4.17.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SharpYaml" Version="1.9.0" />
<PackageReference Include="Verify" Version="16.5.4" />
<PackageReference Include="Verify.Xunit" Version="16.5.4" />
<PackageReference Include="SharpYaml" Version="1.9.1" />
<PackageReference Include="Verify" Version="16.7.0" />
<PackageReference Include="Verify.Xunit" Version="16.7.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1281,7 +1281,7 @@ namespace Microsoft.OpenApi.Writers
{
public OpenApiJsonWriter(System.IO.TextWriter textWriter) { }
public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiJsonWriterSettings settings) { }
public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings settings) { }
public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings settings, bool terseOutput = false) { }
protected override int BaseIndentation { get; }
public override void WriteEndArray() { }
public override void WriteEndObject() { }
Expand Down