Skip to content

Commit 6730987

Browse files
authored
Merge branch 'main' into fix-no-difference-between-empty-and-no-security-requirements-on-operation
2 parents 305c3ca + 27bf18f commit 6730987

File tree

83 files changed

+1116
-538
lines changed

Some content is hidden

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

83 files changed

+1116
-538
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
pull_request:
77
schedule:
88
- cron: '0 8 * * *'
9+
workflow_dispatch:
910

1011
permissions:
1112
contents: read # these permissions are required to run the codeql analysis

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "2.0.0-preview.16"
2+
".": "2.0.0-preview.17"
33
}

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Changelog
22

3+
## [2.0.0-preview.17](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.16...v2.0.0-preview.17) (2025-04-16)
4+
5+
6+
### Features
7+
8+
* discriminator mappings now use schema references ([b4877f6](https://github.com/microsoft/OpenAPI.NET/commit/b4877f674ad1a240a367390d40d122eebccc0b20))
9+
* openapiformat enum cleanup ([#2326](https://github.com/microsoft/OpenAPI.NET/issues/2326)) ([19ffd13](https://github.com/microsoft/OpenAPI.NET/commit/19ffd136a7d2137f3de0896148d9a39f469ac711))
10+
* Remove default collection initialization for perf reasons ([#2284](https://github.com/microsoft/OpenAPI.NET/issues/2284)) ([3604382](https://github.com/microsoft/OpenAPI.NET/commit/36043829d29340a47fc93c6477a38ea93e59ef57))
11+
12+
13+
### Bug Fixes
14+
15+
* Empty tag causes error generating Kiota client [#2283](https://github.com/microsoft/OpenAPI.NET/issues/2283) ([#2286](https://github.com/microsoft/OpenAPI.NET/issues/2286)) ([521d636](https://github.com/microsoft/OpenAPI.NET/commit/521d636e2c437c25e1758e9f6a22793d74adf2d7))
16+
* hidi fails to parse yaml files when fixing references ([a5c4d61](https://github.com/microsoft/OpenAPI.NET/commit/a5c4d6109c433b949cdb1665c00ad778b82b28b0))
17+
* hidi fails to parse yaml files when fixing references ([c5b69fe](https://github.com/microsoft/OpenAPI.NET/commit/c5b69fed9c413a6399c36e0f543e1019faac77e6))
18+
* Improve handling of OpenAPI tag references ([#2325](https://github.com/microsoft/OpenAPI.NET/issues/2325)) ([bf9954a](https://github.com/microsoft/OpenAPI.NET/commit/bf9954a257691231fac6f56667bde208a98a5b42))
19+
* read (Exclusive)Maximum and (Exclusive)Minimum values as strings and write their raw values during serialization ([#2309](https://github.com/microsoft/OpenAPI.NET/issues/2309)) ([ac66756](https://github.com/microsoft/OpenAPI.NET/commit/ac667560a951bef2824851c208c55ba070e96163))
20+
* relative references in subdirectory documents are not loading [#1674](https://github.com/microsoft/OpenAPI.NET/issues/1674) ([#2243](https://github.com/microsoft/OpenAPI.NET/issues/2243)) ([4bcbd51](https://github.com/microsoft/OpenAPI.NET/commit/4bcbd51caff689a73e90efbc08f683383741e004))
21+
* renames annotations schema property to metadata to match [#2241](https://github.com/microsoft/OpenAPI.NET/issues/2241) ([28e4a75](https://github.com/microsoft/OpenAPI.NET/commit/28e4a7590fb3525e30970112191d72eaf048ad6b))
22+
* renames annotations schema property to metadata to match [#2241](https://github.com/microsoft/OpenAPI.NET/issues/2241) ([33fc7cb](https://github.com/microsoft/OpenAPI.NET/commit/33fc7cbcda71efea47070ab7a6ebf9db8787a7f8))
23+
* set format to binary for file uploads ([#2305](https://github.com/microsoft/OpenAPI.NET/issues/2305)) ([47f10d3](https://github.com/microsoft/OpenAPI.NET/commit/47f10d323e78b9e6caa757c0d2efa378a19fc28c))
24+
325
## [2.0.0-preview.16](https://github.com/microsoft/OpenAPI.NET/compare/v2.0.0-preview.15...v2.0.0-preview.16) (2025-03-20)
426

527

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageProjectUrl>https://github.com/Microsoft/OpenAPI.NET</PackageProjectUrl>
1313
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1414
<PackageTags>OpenAPI .NET</PackageTags>
15-
<Version>2.0.0-preview.16</Version>
15+
<Version>2.0.0-preview.17</Version>
1616
</PropertyGroup>
1717
<!-- https://github.com/clairernovotny/DeterministicBuilds#deterministic-builds -->
1818
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ var stream = await httpClient.GetStreamAsync("main/examples/v3.0/petstore.yaml")
8888
var openApiDocument = new OpenApiStreamReader().Read(stream, out var diagnostic);
8989

9090
// Write V2 as JSON
91-
var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiFormat.Json);
91+
var outputString = openApiDocument.Serialize(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json);
9292

9393
```
9494

docs/upgrade-guide-2.md

Lines changed: 297 additions & 147 deletions
Large diffs are not rendered by default.

performance/resultsComparer/resultsComparer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.4" />
1212
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.4" />
1313
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.4" />
14-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.3" />
14+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.4" />
1515
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
1616
<PackageReference Include="system.text.json" Version="9.0.4" />
1717
</ItemGroup>

src/Microsoft.OpenApi.Hidi/Extensions/OpenApiExtensibleExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.OpenApi.Any;
1+
using Microsoft.OpenApi.Extensions;
22
using Microsoft.OpenApi.Interfaces;
33
using System.Collections.Generic;
44
using System.Text.Json.Nodes;
@@ -15,7 +15,7 @@ internal static class OpenApiExtensibleExtensions
1515
/// <returns>A <see cref="string"/> value matching the provided extensionKey. Return null when extensionKey is not found. </returns>
1616
internal static string GetExtension(this Dictionary<string, IOpenApiExtension> extensions, string extensionKey)
1717
{
18-
if (extensions.TryGetValue(extensionKey, out var value) && value is OpenApiAny { Node: JsonValue castValue } && castValue.TryGetValue<string>(out var stringValue))
18+
if (extensions.TryGetValue(extensionKey, out var value) && value is JsonNodeExtension { Node: JsonValue castValue } && castValue.TryGetValue<string>(out var stringValue))
1919
{
2020
return stringValue;
2121
}

src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.4" />
3232
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.4" />
3333
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.4" />
34-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.2" />
34+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.4" />
3535
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.13.61">
3636
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3737
<PrivateAssets>all</PrivateAssets>
3838
</PackageReference>
3939
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" />
4040
<PackageReference Include="Microsoft.OData.Edm" Version="8.2.3" />
41-
<PackageReference Include="Microsoft.OpenApi.OData" Version="2.0.0-preview.12" />
42-
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="2.0.0-preview3" />
41+
<PackageReference Include="Microsoft.OpenApi.OData" Version="2.0.0-preview.13" />
42+
<PackageReference Include="Microsoft.OpenApi.ApiManifest" Version="2.0.0-preview4" />
4343
<PackageReference Include="System.CommandLine.Hosting" Version="0.4.0-alpha.22272.1" />
4444
</ItemGroup>
4545

src/Microsoft.OpenApi.Hidi/OpenApiService.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog
5555
if (options.Output == null)
5656
{
5757
#pragma warning disable CA1308 // Normalize strings to uppercase
58-
var extension = options.OpenApiFormat?.GetDisplayName().ToLowerInvariant();
58+
var extension = options.OpenApiFormat?.ToLowerInvariant();
5959
var inputExtension = !string.IsNullOrEmpty(extension) ? string.Concat(".", extension)
6060
: GetInputPathExtension(options.OpenApi, options.Csdl);
6161

@@ -73,7 +73,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog
7373
}
7474

7575
// Default to yaml and OpenApiVersion 3_1 during csdl to OpenApi conversion
76-
var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiFormat.Yaml);
76+
var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiConstants.Yaml);
7777
var openApiVersion = options.Version != null ? TryParseOpenApiSpecVersion(options.Version) : OpenApiSpecVersion.OpenApi3_1;
7878

7979
// If ApiManifest is provided, set the referenced OpenAPI document
@@ -92,7 +92,7 @@ public static async Task TransformOpenApiDocumentAsync(HidiOptions options, ILog
9292
}
9393

9494
// Load OpenAPI document
95-
var document = await GetOpenApiAsync(options, openApiFormat.GetDisplayName(), logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false);
95+
var document = await GetOpenApiAsync(options, openApiFormat, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false);
9696

9797
if (options.FilterOptions != null && document is not null)
9898
{
@@ -189,7 +189,7 @@ private static OpenApiDocument ApplyFilters(HidiOptions options, ILogger logger,
189189
return document;
190190
}
191191

192-
private static async Task WriteOpenApiAsync(HidiOptions options, OpenApiFormat openApiFormat, OpenApiSpecVersion openApiVersion, OpenApiDocument document, ILogger logger, CancellationToken cancellationToken)
192+
private static async Task WriteOpenApiAsync(HidiOptions options, string openApiFormat, OpenApiSpecVersion openApiVersion, OpenApiDocument document, ILogger logger, CancellationToken cancellationToken)
193193
{
194194
using (logger.BeginScope("Output"))
195195
{
@@ -202,11 +202,12 @@ private static async Task WriteOpenApiAsync(HidiOptions options, OpenApiFormat o
202202
InlineLocalReferences = options.InlineLocal,
203203
InlineExternalReferences = options.InlineExternal
204204
};
205-
206-
IOpenApiWriter writer = openApiFormat switch
205+
#pragma warning disable CA1308
206+
IOpenApiWriter writer = openApiFormat.ToLowerInvariant() switch
207+
#pragma warning restore CA1308
207208
{
208-
OpenApiFormat.Json => options.TerseOutput ? new(textWriter, settings, options.TerseOutput) : new OpenApiJsonWriter(textWriter, settings, false),
209-
OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings),
209+
OpenApiConstants.Json => options.TerseOutput ? new(textWriter, settings, options.TerseOutput) : new OpenApiJsonWriter(textWriter, settings, false),
210+
OpenApiConstants.Yaml => new OpenApiYamlWriter(textWriter, settings),
210211
_ => throw new ArgumentException("Unknown format"),
211212
};
212213

@@ -560,10 +561,10 @@ SecurityException or
560561
/// <param name="input"></param>
561562
/// <param name="logger"></param>
562563
/// <returns></returns>
563-
private static OpenApiFormat GetOpenApiFormat(string input, ILogger logger)
564+
private static string GetOpenApiFormat(string input, ILogger logger)
564565
{
565566
logger.LogTrace("Getting the OpenApi format");
566-
return !input.StartsWith("http", StringComparison.OrdinalIgnoreCase) && Path.GetExtension(input) == ".json" ? OpenApiFormat.Json : OpenApiFormat.Yaml;
567+
return !input.StartsWith("http", StringComparison.OrdinalIgnoreCase) && Path.GetExtension(input) == ".json" ? OpenApiConstants.Json : OpenApiConstants.Yaml;
567568
}
568569

569570
private static string GetInputPathExtension(string? openapi = null, string? csdl = null)
@@ -590,8 +591,8 @@ private static string GetInputPathExtension(string? openapi = null, string? csdl
590591
throw new ArgumentException("Please input a file path or URL");
591592
}
592593

593-
var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiFormat.Yaml);
594-
var document = await GetOpenApiAsync(options, openApiFormat.GetDisplayName(), logger, null, cancellationToken).ConfigureAwait(false);
594+
var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi) ? GetOpenApiFormat(options.OpenApi, logger) : OpenApiConstants.Yaml);
595+
var document = await GetOpenApiAsync(options, openApiFormat, logger, null, cancellationToken).ConfigureAwait(false);
595596
if (document is not null)
596597
{
597598
using (logger.BeginScope("Creating diagram"))
@@ -754,10 +755,10 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg
754755
}
755756

756757
var openApiFormat = options.OpenApiFormat ?? (!string.IsNullOrEmpty(options.OpenApi)
757-
? GetOpenApiFormat(options.OpenApi, logger) : OpenApiFormat.Yaml);
758+
? GetOpenApiFormat(options.OpenApi, logger) : OpenApiConstants.Yaml);
758759

759760
// Load OpenAPI document
760-
var document = await GetOpenApiAsync(options, openApiFormat.GetDisplayName(), logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false);
761+
var document = await GetOpenApiAsync(options, openApiFormat, logger, options.MetadataVersion, cancellationToken).ConfigureAwait(false);
761762

762763
cancellationToken.ThrowIfCancellationRequested();
763764

@@ -777,7 +778,7 @@ internal static async Task PluginManifestAsync(HidiOptions options, ILogger logg
777778
options.TerseOutput = true;
778779
if (document is not null)
779780
{
780-
await WriteOpenApiAsync(options, OpenApiFormat.Json, OpenApiSpecVersion.OpenApi3_1, document, logger, cancellationToken).ConfigureAwait(false);
781+
await WriteOpenApiAsync(options, OpenApiConstants.Json, OpenApiSpecVersion.OpenApi3_1, document, logger, cancellationToken).ConfigureAwait(false);
781782

782783
// Create OpenAIPluginManifest from ApiDependency and OpenAPI document
783784
var manifest = new OpenAIPluginManifest(document.Info.Title ?? "Title",

0 commit comments

Comments
 (0)