Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c61da25
chore: upgrades oai.net to preview 17
baywet Apr 17, 2025
f6aab41
chore: fixes bad collection initialization syntax in tests
baywet Apr 17, 2025
1ccce15
chore: further collection initialization fixes
baywet Apr 17, 2025
8805bf4
chore: code linting
baywet Apr 17, 2025
03c76d2
fix: a bug where operation query parameters would be missing
baywet May 14, 2025
40d5873
chore: fixes ill-defined unit tests
baywet May 14, 2025
31f34c8
fix: partial discriminator mapping
baywet May 14, 2025
feeca50
fix: missing value for unit tests
baywet May 14, 2025
ee3187c
fix: url parameter templating
baywet May 14, 2025
f23ca73
fix: null reference exception
baywet May 14, 2025
f18fc19
fix: missing operation path parameters when building uri template
baywet May 14, 2025
0d7f03b
fix: indexer parameter type
baywet May 14, 2025
895c7fd
fix: test definition
baywet May 14, 2025
77ff5f9
chore: typo fix
baywet May 14, 2025
4fc5ff0
chore: typo fix
baywet May 14, 2025
2d63b74
fix: merged schema class name
baywet May 14, 2025
d4983e6
Merge branch 'main' into chore/upgrade-oainet
baywet May 15, 2025
ba005ef
Merge branch 'main' into chore/upgrade-oainet
baywet May 15, 2025
a6f0214
fix: indexer type mapping
baywet May 15, 2025
6940e72
fix: circular lookup for discriminator mappings
baywet May 15, 2025
a57c090
chore: linting
baywet May 15, 2025
0ad9713
chore: upgrade oai.net to preview18
baywet May 15, 2025
a55e475
chore: removes inextising namespace reference
baywet May 15, 2025
664078d
Merge branch 'main' into chore/upgrade-oainet
baywet May 15, 2025
58e3f71
Merge branch 'main' into chore/upgrade-oainet
baywet May 16, 2025
2111f3e
chore: bumps oai.net to preview19
baywet May 16, 2025
8fb154e
Merge branch 'main' into chore/upgrade-oainet
baywet May 16, 2025
bf64e84
Merge branch 'chore/upgrade-oainet' of https://github.com/microsoft/k…
baywet May 19, 2025
8ca6471
Merge branch 'main' into chore/upgrade-oainet
baywet May 19, 2025
72fa438
fix: trailing slashes causing mayhem
baywet May 19, 2025
fb3cbbc
Merge branch 'main' into chore/upgrade-oainet
baywet May 20, 2025
b7ed453
chore: upgrades oai.net to preview 20
baywet May 20, 2025
f7a4396
fix: converts to await block to get the actual call stack when except…
baywet May 20, 2025
3b150cd
fix: path management in unit test definition
baywet May 20, 2025
092e41b
chore: do not use path combine with GetTempFileName as it already is …
baywet May 20, 2025
de02126
chore: formatting
baywet May 20, 2025
f49d655
ci: fixes test definition due to new nullability updates
baywet May 20, 2025
2741211
Merge branch 'main' into chore/upgrade-oainet
baywet May 21, 2025
6481440
chore: upgrades oai.net to preview 21
baywet May 21, 2025
cd23cf5
fix: nodes merging not happening because of null values
baywet May 21, 2025
871f4bb
fix: indexer parameter lookup when merging nodes
baywet May 21, 2025
d5edb12
Merge branch 'main' into chore/upgrade-oainet
baywet May 21, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Fixed a bug where path items with a trailing slash would cause collisions, missing query parameters and more.
- Fixed a bug where path items with a trailing slash would be missing query parameters. [#6569](https://github.com/microsoft/kiota/issues/6569)
- Fixed an issue where migration from lock to workspace would fail because of stream management. [#6515](https://github.com/microsoft/kiota/issues/6515)

Expand Down
2 changes: 2 additions & 0 deletions src/Kiota.Builder/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace Kiota.Builder;

public static class Constants
{
public const string DefaultOpenApiLabel = "default";
public const string TempDirectoryName = "kiota";
internal const string KiotaSegmentNameTreeNodeExtensionKey = "x-ms-kiota-new-segment-name";
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal static DeprecationInformation GetDeprecationInformation(this OpenApiOpe
if (operation.Deprecated && operation.Extensions is not null && operation.Extensions.TryGetValue(OpenApiDeprecationExtension.Name, out var deprecatedExtension) && deprecatedExtension is OpenApiDeprecationExtension deprecatedValue)
return deprecatedValue.ToDeprecationInformation();
else if (operation.Responses?.Values
.SelectMany(static x => x.Content?.Values ?? [])
.SelectMany(static x => x.Content?.Values.Select(static x => x) ?? [])
.Select(static x => x?.Schema)
.OfType<OpenApiSchema>()
.Select(static x => x.GetDeprecationInformation())
Expand Down
28 changes: 16 additions & 12 deletions src/Kiota.Builder/Extensions/OpenApiSchemaExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Text.Json;
using Kiota.Builder.OpenApiExtensions;
using Microsoft.OpenApi.Interfaces;
using Microsoft.OpenApi.Models;
using Microsoft.OpenApi.Models.Interfaces;
using Microsoft.OpenApi.Models.References;
Expand Down Expand Up @@ -198,7 +199,7 @@ private static OpenApiSchema GetSchemaOrTargetShallowCopy(this IOpenApiSchema? s
{
if (string.IsNullOrEmpty(result.Discriminator.PropertyName) && !string.IsNullOrEmpty(discriminator.PropertyName))
result.Discriminator.PropertyName = discriminator.PropertyName;
if (discriminator.Mapping?.Any() ?? false)
if (discriminator.Mapping is { Count: > 0 })
result.Discriminator.Mapping = discriminator.Mapping.ToDictionary(static x => x.Key, static x => x.Value);
}

Expand All @@ -218,7 +219,8 @@ private static OpenApiSchema GetSchemaOrTargetShallowCopy(this IOpenApiSchema? s
/// <param name="result">Resulting merged schema.</param>
private static void AddOriginalReferenceIdExtension(this IOpenApiSchema schema, OpenApiSchema result)
{
if (schema is not OpenApiSchemaReference schemaReference || string.IsNullOrEmpty(schemaReference.Reference.Id) || result.Extensions is null) return;
if (schema is not OpenApiSchemaReference schemaReference || string.IsNullOrEmpty(schemaReference.Reference.Id)) return;
result.Extensions ??= new Dictionary<string, IOpenApiExtension>(StringComparer.Ordinal);
result.Extensions.TryAdd(OpenApiKiotaMergedExtension.Name, new OpenApiKiotaMergedExtension(schemaReference.Reference.Id));
}

Expand Down Expand Up @@ -272,13 +274,13 @@ private static bool IsODataPrimitiveTypeBackwardCompatible(this IOpenApiSchema s
{
return schema.IsExclusiveUnion() &&
schema.OneOf is { Count: 3 } &&
schema.OneOf.Count(static x => x.Enum?.Any() ?? false) == 1 &&
schema.OneOf.Count(static x => x.Enum is { Count: > 0 }) == 1 &&
schema.OneOf.Count(isODataType) == 1 &&
schema.OneOf.Count(isStringType) == 1
||
schema.IsInclusiveUnion() &&
schema.AnyOf is { Count: 3 } &&
schema.AnyOf.Count(static x => x.Enum?.Any() ?? false) == 1 &&
schema.AnyOf.Count(static x => x.Enum is { Count: > 0 }) == 1 &&
schema.AnyOf.Count(isODataType) == 1 &&
schema.AnyOf.Count(isStringType) == 1;
}
Expand All @@ -287,13 +289,13 @@ public static bool IsODataPrimitiveType(this IOpenApiSchema schema)
if (schema is null) return false;
return schema.IsExclusiveUnion() &&
schema.OneOf is { Count: 3 } &&
schema.OneOf.Count(static x => isStringType(x) && (x.Enum?.Any() ?? false)) == 1 &&
schema.OneOf.Count(static x => isStringType(x) && (x.Enum is { Count: > 0 })) == 1 &&
schema.OneOf.Count(isODataType) == 1 &&
schema.OneOf.Count(isStringType) == 2
||
schema.IsInclusiveUnion() &&
schema.AnyOf is { Count: 3 } &&
schema.AnyOf.Count(static x => isStringType(x) && (x.Enum?.Any() ?? false)) == 1 &&
schema.AnyOf.Count(static x => isStringType(x) && (x.Enum is { Count: > 0 })) == 1 &&
schema.AnyOf.Count(isODataType) == 1 &&
schema.AnyOf.Count(isStringType) == 2
||
Expand Down Expand Up @@ -411,14 +413,14 @@ internal static IEnumerable<KeyValuePair<string, string>> GetDiscriminatorMappin
{
if (schema == null)
return [];
if (!(schema.Discriminator?.Mapping?.Any() ?? false))
if (schema.Discriminator?.Mapping is not { Count: > 0 })
if (schema.OneOf is { Count: > 0 })
return schema.OneOf.SelectMany(x => GetDiscriminatorMappings(x, inheritanceIndex));
else if (schema.AnyOf is { Count: > 0 })
return schema.AnyOf.SelectMany(x => GetDiscriminatorMappings(x, inheritanceIndex));
else if ((schema.AllOf?.Any(allOfEvaluatorForMappings) ?? false) && schema.AllOf[^1].Equals(schema.AllOf.Last(allOfEvaluatorForMappings)))
// ensure the matched AllOf entry is the last in the list
return GetDiscriminatorMappings(schema.AllOf.Last(allOfEvaluatorForMappings), inheritanceIndex);
else if (schema.IsInherited() && schema.AllOf?.OfType<OpenApiSchema>().FirstOrDefault(allOfEvaluatorForMappings) is { } allOfEntry)
// ensure we're in an inheritance context and get the discriminator from the parent when available
return GetDiscriminatorMappings(allOfEntry, inheritanceIndex);
else if (schema.GetReferenceId() is string refId && !string.IsNullOrEmpty(refId))
return GetAllInheritanceSchemaReferences(refId, inheritanceIndex)
.Where(static x => !string.IsNullOrEmpty(x))
Expand All @@ -428,9 +430,11 @@ internal static IEnumerable<KeyValuePair<string, string>> GetDiscriminatorMappin
return [];

return schema.Discriminator
.Mapping;
.Mapping
.Where(static x => !string.IsNullOrEmpty(x.Value.Reference.Id))
.Select(static x => KeyValuePair.Create(x.Key, x.Value.Reference.Id!));
}
private static readonly Func<IOpenApiSchema, bool> allOfEvaluatorForMappings = static x => x.Discriminator?.Mapping?.Any() ?? false;
private static readonly Func<IOpenApiSchema, bool> allOfEvaluatorForMappings = static x => x.Discriminator?.Mapping is { Count: > 0 };
private static IEnumerable<string> GetAllInheritanceSchemaReferences(string currentReferenceId, ConcurrentDictionary<string, ConcurrentDictionary<string, bool>> inheritanceIndex)
{
ArgumentException.ThrowIfNullOrEmpty(currentReferenceId);
Expand Down
Loading
Loading