Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
0d15ba1
Bump docker/build-push-action from 6.1.0 to 6.2.0
dependabot[bot] Jul 1, 2024
041938d
Merge pull request #1713 from microsoft/dependabot/github_actions/doc…
andrueastman Jul 2, 2024
d4057f2
Bump Verify.Xunit from 25.0.4 to 25.2.0
dependabot[bot] Jul 2, 2024
3d971de
Merge pull request #1714 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Jul 3, 2024
05713cb
Bump Verify.Xunit from 25.2.0 to 25.3.0
dependabot[bot] Jul 3, 2024
d8eda7a
Make library trim-compatible
captainsafia Jul 4, 2024
08718e1
Avoid using generic overload for all enum types
captainsafia Jul 4, 2024
9a7f078
Merge pull request #1716 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Jul 4, 2024
11466d7
Update PublicApi.Approved.txt
captainsafia Jul 4, 2024
015448f
make verified files as lf and utf8
SimonCropp Jul 5, 2024
a0b6f9d
Avoid binary compat break in CloneFromCopyConstructor
captainsafia Jul 6, 2024
a70f2be
Bump dependabot/fetch-metadata from 2.1.0 to 2.2.0
dependabot[bot] Jul 8, 2024
827339f
Bump docker/build-push-action from 6.2.0 to 6.3.0
dependabot[bot] Jul 8, 2024
5b006b2
Add obsoletion attributes and fix CloneFromCopyConstructor
captainsafia Jul 9, 2024
734e84f
Merge pull request #1720 from microsoft/dependabot/github_actions/dep…
andrueastman Jul 9, 2024
b2469d4
Bump xunit.runner.visualstudio from 2.8.1 to 2.8.2 (#1723)
dependabot[bot] Jul 9, 2024
0199484
Merge pull request #1721 from microsoft/dependabot/github_actions/doc…
andrueastman Jul 9, 2024
06bf70b
Bump xunit from 2.8.1 to 2.9.0 (#1722)
dependabot[bot] Jul 9, 2024
8ea0964
Add ReferenceType.Path and tests for display names
captainsafia Jul 9, 2024
2a602ca
Bump Microsoft.Windows.Compatibility from 8.0.6 to 8.0.7
dependabot[bot] Jul 9, 2024
4470204
Merge pull request #1724 from microsoft/dependabot/nuget/Microsoft.Wi…
baywet Jul 10, 2024
b9bff33
Bump Verify.Xunit from 25.3.0 to 25.3.1
dependabot[bot] Jul 11, 2024
1eae046
Merge pull request #1725 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Jul 12, 2024
2128408
Guard ReferenceType consumption for ExternalResource
captainsafia Jul 15, 2024
07076a7
Bump docker/build-push-action from 6.3.0 to 6.4.0
dependabot[bot] Jul 15, 2024
f0ce99f
Merge pull request #1718 from SimonCropp/make-verified-files-as-lf-an…
MaggieKimani1 Jul 16, 2024
513abb9
Merge pull request #1728 from microsoft/dependabot/github_actions/doc…
MaggieKimani1 Jul 16, 2024
bced7d5
Add trimming test project and fix warnings
captainsafia Jul 17, 2024
be1046d
Apply suggestions from code review
baywet Jul 17, 2024
4cc030d
ci: adds trimming project to solution
baywet Jul 17, 2024
74275b8
ci: adds readers project to trimming test project
baywet Jul 17, 2024
7f7c54a
ci: adds missing trimming root assembly directive
baywet Jul 17, 2024
06b54c3
Fix build, address feedback, and remove Readers from trim tests
captainsafia Jul 17, 2024
887d88b
Bump Verify.Xunit from 25.3.1 to 25.3.2
dependabot[bot] Jul 17, 2024
6899d5f
Merge pull request #1731 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Jul 18, 2024
598f2b6
Create test for bug
Jul 18, 2024
691d99d
Add null check to OpenApiDocument.Components
Jul 18, 2024
c117bc5
Rely on enum fields never being trimmed
captainsafia Jul 18, 2024
d0829ab
Fix copy constructor for arrays and objects
martincostello Jul 19, 2024
35811cc
Address feedback
captainsafia Jul 19, 2024
8267c40
Add back doc comment on M.O.Readers
captainsafia Jul 19, 2024
bd7dcc8
add verify settings to editorconfig
SimonCropp Jul 20, 2024
b873da7
Merge pull request #1734 from kanales/kanales/fix-null-pointer-error-…
andrueastman Jul 22, 2024
134dd0c
Remove redundant section
martincostello Jul 22, 2024
6200767
Update test/Microsoft.OpenApi.Tests/Attributes/DisplayAttributeTests.cs
MaggieKimani1 Jul 22, 2024
1ed30a0
Merge pull request #1739 from martincostello/patch-1
MaggieKimani1 Jul 22, 2024
0f93f39
Merge pull request #1737 from SimonCropp/add-verify-settings-to-edito…
MaggieKimani1 Jul 22, 2024
0646b23
Merge pull request #1736 from martincostello/fix-example-clone
MaggieKimani1 Jul 22, 2024
47ad39d
Fix syntax error
MaggieKimani1 Jul 22, 2024
3f597ba
Merge branch 'vnext' into safia/trimmable
MaggieKimani1 Jul 22, 2024
321e20d
Use native AOT-friendly generic overload
MaggieKimani1 Jul 22, 2024
1a2877f
Merge pull request #1717 from captainsafia/safia/trimmable
MaggieKimani1 Jul 22, 2024
f3dbb1a
Bump docker/build-push-action from 6.4.0 to 6.5.0
dependabot[bot] Jul 22, 2024
c936197
Bump docker/login-action from 3.2.0 to 3.3.0
dependabot[bot] Jul 22, 2024
bc9bed9
Bump Verify.Xunit from 25.3.2 to 26.0.0
dependabot[bot] Jul 22, 2024
a04963b
Merge pull request #1742 from microsoft/dependabot/github_actions/doc…
andrueastman Jul 23, 2024
8a569bc
Merge pull request #1741 from microsoft/dependabot/github_actions/doc…
andrueastman Jul 23, 2024
2565ec0
Merge pull request #1743 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Jul 23, 2024
4a01599
Initialize stream reader with default encoding and buffer size values…
MaggieKimani1 Jul 23, 2024
29acad7
Add test
MaggieKimani1 Jul 23, 2024
f40afd4
Bump Verify.Xunit from 26.0.0 to 26.0.1
dependabot[bot] Jul 23, 2024
4e4ba5d
Merge pull request #1745 from microsoft/dependabot/nuget/Verify.Xunit…
andrueastman Jul 24, 2024
b651e63
Merge pull request #1744 from microsoft/mk/fix-stream-reader-bug
MaggieKimani1 Jul 24, 2024
c87ef1f
Bump up lib versions
MaggieKimani1 Jul 24, 2024
9406dad
Merge pull request #1746 from microsoft/mk/update-package-versions
MaggieKimani1 Jul 24, 2024
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
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,14 @@ csharp_preserve_single_line_blocks = true
[*.vb]
# Modifier preferences
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion


# Verify settings
[*.{received,verified}.{txt,xml,json}]
charset = "utf-8-bom"
end_of_line = lf
indent_size = unset
indent_style = unset
insert_final_newline = false
tab_width = unset
trim_trailing_whitespace = false
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

# VerifyTests
*.verified.txt text eol=lf working-tree-encoding=UTF-8
2 changes: 1 addition & 1 deletion .github/workflows/auto-merge-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2.1.0
uses: dependabot/fetch-metadata@v2.2.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"

Expand Down
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@v4
- name: Login to GitHub package feed
uses: docker/login-action@v3.2.0
uses: docker/login-action@v3.3.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@v6.1.0
uses: docker/build-push-action@v6.5.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@v6.1.0
uses: docker/build-push-action@v6.5.0
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}
7 changes: 7 additions & 0 deletions Microsoft.OpenApi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "s
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Hidi.Tests", "test\Microsoft.OpenApi.Hidi.Tests\Microsoft.OpenApi.Hidi.Tests.csproj", "{D8F799DD-04AC-4A13-B344-45A5B944450A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Trimming.Tests", "test\Microsoft.OpenApi.Trimming.Tests\Microsoft.OpenApi.Trimming.Tests.csproj", "{1D2E0C6E-B103-4CB6-912E-D56FA1501296}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -68,6 +70,10 @@ Global
{D8F799DD-04AC-4A13-B344-45A5B944450A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8F799DD-04AC-4A13-B344-45A5B944450A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8F799DD-04AC-4A13-B344-45A5B944450A}.Release|Any CPU.Build.0 = Release|Any CPU
{1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D2E0C6E-B103-4CB6-912E-D56FA1501296}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -81,6 +87,7 @@ Global
{AD79B61D-88CF-497C-9ED5-41AE3867C5AC} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE} = {E546B92F-20A8-49C3-8323-4B25BB78F3E1}
{D8F799DD-04AC-4A13-B344-45A5B944450A} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
{1D2E0C6E-B103-4CB6-912E-D56FA1501296} = {6357D7FD-2DE4-4900-ADB9-ABC37052040A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9F171EFC-0DB5-4B10-ABFA-AF48D52CC565}
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,6 @@ In order to test the validity of an OpenApi document, we avail the following too

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**|
|--|
|[![Build status](https://ci.appveyor.com/api/projects/status/9l6hly3vjeu0tmtx/branch/master?svg=true)](https://ci.appveyor.com/project/MicrosoftOpenAPINETAdmin/openapi-net-54e7i/branch/master)|

# Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.6.15</Version>
<Version>1.6.16</Version>
<Description>OpenAPI.NET Readers for JSON and YAML documents</Description>
<SignAssembly>true</SignAssembly>
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->
Expand Down
11 changes: 7 additions & 4 deletions src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.OpenApi.Interfaces;
Expand Down Expand Up @@ -41,7 +42,7 @@ public OpenApiStreamReader(OpenApiReaderSettings settings = null)
/// <returns>Instance of newly created OpenApiDocument.</returns>
public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic)
{
using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen);
using var reader = new StreamReader(input, Encoding.UTF8, true, 4096, _settings.LeaveStreamOpen);
return new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic);
}

Expand All @@ -54,6 +55,7 @@ public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic)
public async Task<ReadResult> ReadAsync(Stream input, CancellationToken cancellationToken = default)
{
MemoryStream bufferedStream;
int bufferSize = 4096;
if (input is MemoryStream stream)
{
bufferedStream = stream;
Expand All @@ -63,11 +65,12 @@ public async Task<ReadResult> ReadAsync(Stream input, CancellationToken cancella
// Buffer stream so that OpenApiTextReaderReader can process it synchronously
// YamlDocument doesn't support async reading.
bufferedStream = new();
await input.CopyToAsync(bufferedStream, 81920, cancellationToken);
bufferSize = 81920;
await input.CopyToAsync(bufferedStream, bufferSize, cancellationToken);
bufferedStream.Position = 0;
}

using var reader = new StreamReader(bufferedStream, default, true, -1, _settings.LeaveStreamOpen);
using var reader = new StreamReader(bufferedStream, Encoding.UTF8, true, bufferSize, _settings.LeaveStreamOpen);
return await new OpenApiTextReaderReader(_settings).ReadAsync(reader, cancellationToken);
}

Expand All @@ -80,7 +83,7 @@ public async Task<ReadResult> ReadAsync(Stream input, CancellationToken cancella
/// <returns>Instance of newly created OpenApiDocument</returns>
public T ReadFragment<T>(Stream input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic) where T : IOpenApiReferenceable
{
using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen);
using var reader = new StreamReader(input, Encoding.UTF8, true, 4096, _settings.LeaveStreamOpen);
return new OpenApiTextReaderReader(_settings).ReadFragment<T>(reader, version, out diagnostic);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers" Version="0.4.421302" PrivateAssets="all" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.6" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.7" />
</ItemGroup>
<ItemGroup>
<Resource Include="Themes\Metro\HowToApplyTheme.txt" />
Expand Down
27 changes: 26 additions & 1 deletion src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using System.Reflection;
using System;
using System.Diagnostics.CodeAnalysis;

namespace Microsoft.OpenApi.Any
{
/// <summary>
/// Contains logic for cloning objects through copy constructors.
/// </summary>
public class OpenApiAnyCloneHelper

Check warning on line 12 in src/Microsoft.OpenApi/Any/OpenApiAnyCloneHelper.cs

View workflow job for this annotation

GitHub Actions / Build

Add a 'protected' constructor or the 'static' keyword to the class declaration. (https://rules.sonarsource.com/csharp/RSPEC-1118)
{
/// <summary>
/// Clones an instance of <see cref="IOpenApiAny"/> object from the copy constructor
/// </summary>
/// <param name="obj">The object instance.</param>
/// <returns>A clone copy or the object itself.</returns>
[Obsolete("Use native AoT-friendly generic overload of CloneFromCopyConstructor instead.")]
[RequiresUnreferencedCode("CloneFromCopyConstructor is not trim-compatible. Recommended to use native AoT-friendly type-specific overloads of CloneFromCopyConstructor instead.")]
public static IOpenApiAny CloneFromCopyConstructor(IOpenApiAny obj)
{
if (obj != null)
Expand All @@ -32,5 +35,27 @@

return obj;
}

/// <summary>
/// Clones an instance of <see cref="IOpenApiAny"/> object from the copy constructor
/// </summary>
/// <param name="obj">The object instance.</param>
/// <returns>A clone copy or the object itself.</returns>
public static T CloneFromCopyConstructor<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(T obj) where T : IOpenApiAny
{
if (obj != null)
{
foreach (var ci in typeof(T).GetConstructors())
{
var pi = ci.GetParameters();
if (pi.Length == 1 && pi[0].ParameterType == typeof(T))
{
return (T)ci.Invoke([obj]);
}
}
}

return obj;
}
}
}
4 changes: 4 additions & 0 deletions src/Microsoft.OpenApi/Any/OpenApiArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public OpenApiArray() { }
public OpenApiArray(OpenApiArray array)
{
AnyType = array.AnyType;
foreach (var item in array)
{
Add(OpenApiAnyCloneHelper.CloneFromCopyConstructor<IOpenApiAny>(item));
}
}

/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions src/Microsoft.OpenApi/Any/OpenApiObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public OpenApiObject() { }
public OpenApiObject(OpenApiObject obj)
{
AnyType = obj.AnyType;
foreach (var key in obj.Keys)
{
this[key] = OpenApiAnyCloneHelper.CloneFromCopyConstructor<IOpenApiAny>(obj[key]);
}
}

/// <summary>
Expand Down
Loading
Loading