Skip to content

Commit

Permalink
Merge branch 'feature/generate-adaptive-cards' of https://github.com/…
Browse files Browse the repository at this point in the history
…microsoft/kiota into feature/generate-adaptive-cards
  • Loading branch information
thewahome committed Jan 14, 2025
2 parents cf7ec73 + c145912 commit fc43b0a
Show file tree
Hide file tree
Showing 18 changed files with 170 additions and 90 deletions.
40 changes: 40 additions & 0 deletions .github/policies/branch-protection.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: kiota-branch-protection
description: Branch protection policy for the kiota repository
resource: repository
configuration:
branchProtectionRules:
- branchNamePattern: main
# Specifies whether this branch can be deleted. boolean
allowsDeletions: false
# Specifies whether forced pushes are allowed on this branch. boolean
allowsForcePushes: false
# Specifies whether new commits pushed to the matching branches dismiss pull request review approvals. boolean
dismissStaleReviews: true
# Specifies whether admins can overwrite branch protection. boolean
isAdminEnforced: false
# Indicates whether "Require a pull request before merging" is enabled. boolean
requiresPullRequestBeforeMerging: true
# Specifies the number of pull request reviews before merging. int (0-6). Should be null/empty if PRs are not required
requiredApprovingReviewsCount: 2
# Require review from Code Owners. Requires requiredApprovingReviewsCount. boolean
requireCodeOwnersReview: true
# Are commits required to be signed. boolean.
requiresCommitSignatures: true
# Are conversations required to be resolved before merging? boolean
requiresConversationResolution: true
# Are merge commits prohibited from being pushed to this branch. boolean
requiresLinearHistory: false
# Required status checks to pass before merging. Values can be any string, but if the value does not correspond to any existing status check, the status check will be stuck on pending for status since nothing exists to push an actual status
requiredStatusChecks:
- license/cla
- Analyze (csharp)
- dotnet-build
- check-idempotency-tests
- check-integration-tests
- build_extension
# Require branches to be up to date before merging
requiresStrictStatusChecks: true
# Indicates whether there are restrictions on who can push. boolean. Should be set with whoCanPush.
restrictsPushes: false
# Restrict who can dismiss pull request reviews. boolean
restrictsReviewDismissals: false
2 changes: 1 addition & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:
]

jobs:
build:
dotnet-build:
runs-on: ubuntu-latest

steps:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/idempotency-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,16 @@ jobs:
with:
artifact_name: "generator"
min_bytes: "0"

# Aggregates result of the idempotency tests for use in branch policy
check-idempotency-tests:
runs-on: ubuntu-latest
needs: idempotency
if: always()
steps:
- name: All build matrix options are successful
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: One or more build matrix options failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
13 changes: 13 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,16 @@ jobs:
with:
artifact_name: "generator"
min_bytes: "0"

# Aggregates result of the integration tests for use in branch policy
check-integration-tests:
runs-on: ubuntu-latest
needs: integration
if: always()
steps:
- name: All build matrix options are successful
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: One or more build matrix options failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Drops Python 3.8 support by removing deprecated type aliases from generated code. [microsoft/kiota-python#349](https://github.com/microsoft/kiota-python/issues/349)
- Removes superfluous inline imports in serializer methods in Python Generation.

## [1.22.2]

### Added

### Changed

- Fixed a bug showing an error popup in the VS Code extension after generation [5988](https://github.com/microsoft/kiota/issues/5988)

## [1.22.1] - 2025-01-10

### Added

### Changed

- Fixed a bug in the VS Code extension plugin generation [#5978](https://github.com/microsoft/kiota/issues/5978)

## [1.22.0] - 2025-01-09
Expand Down
18 changes: 9 additions & 9 deletions it/python/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pylint==3.3.3

pytest==8.3.4

pytest-asyncio==0.25.1
pytest-asyncio==0.25.2

requests==2.32.3 ; python_version >= '3.7'

Expand All @@ -60,7 +60,7 @@ typing-extensions==4.12.2 ; python_version >= '3.7'

urllib3==2.3.0 ; python_version >= '3.7'

wrapt==1.17.0 ; python_version < '3.11'
wrapt==1.17.1 ; python_version < '3.11'

yapf==0.43.0

Expand Down Expand Up @@ -98,19 +98,19 @@ httpx[http2]==0.28.1

hyperframe==6.0.1 ; python_full_version >= '3.6.1'

microsoft-kiota-abstractions==1.6.8
microsoft-kiota-abstractions==1.7.0

microsoft-kiota-authentication-azure==1.6.8
microsoft-kiota-authentication-azure==1.7.0

microsoft-kiota-http==1.6.8
microsoft-kiota-http==1.7.0

microsoft-kiota-serialization-json==1.6.8
microsoft-kiota-serialization-json==1.7.0

microsoft-kiota-serialization-text==1.6.8
microsoft-kiota-serialization-text==1.7.0

microsoft-kiota-serialization-form==1.6.8
microsoft-kiota-serialization-form==1.7.0

microsoft-kiota-serialization-multipart==1.6.8
microsoft-kiota-serialization-multipart==1.7.0

msal==1.31.1

Expand Down
45 changes: 24 additions & 21 deletions it/typescript/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions it/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"prettier": "./.prettierrc.json",
"devDependencies": {
"@es-exec/esbuild-plugin-start": "^0.0.5",
"@stylistic/eslint-plugin-ts": "^2.12.1",
"@stylistic/eslint-plugin-ts": "^2.13.0",
"@types/node": "^22.10.5",
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "^8.19.1",
"esbuild": "^0.24.2",
"eslint": "^9.17.0",
"eslint": "^9.18.0",
"eslint-config-prettier": "^9.1.0",
"minimist": "^1.2.8",
"prettier": "^3.4.2",
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Kiota.Builder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Title>Microsoft.OpenApi.Kiota.Builder</Title>
<PackageId>Microsoft.OpenApi.Kiota.Builder</PackageId>
<PackageOutputPath>./nupkg</PackageOutputPath>
<VersionPrefix>1.22.2</VersionPrefix>
<VersionPrefix>1.23.0</VersionPrefix>
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
<PackageReleaseNotes>
https://github.com/microsoft/kiota/releases
Expand Down
23 changes: 14 additions & 9 deletions src/Kiota.Builder/Refiners/PythonRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public override Task RefineAsync(CodeNamespace generatedCode, CancellationToken
private const string StoreModuleName = $"{AbstractionsPackageName}.store";
private static readonly AdditionalUsingEvaluator[] defaultUsingEvaluators = {
new (static x => x is CodeClass, "__future__", "annotations"),
new (static x => x is CodeClass, "typing", "Any, Callable, Dict, List, Optional, TYPE_CHECKING, Union"),
new (static x => x is CodeClass, "typing", "Any, Optional, TYPE_CHECKING, Union"),
new (static x => x is CodeClass, "collections.abc", "Callable"),
new (static x => x is CodeProperty prop && prop.IsOfKind(CodePropertyKind.RequestAdapter),
$"{AbstractionsPackageName}.request_adapter", "RequestAdapter"),
new (static x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator),
Expand Down Expand Up @@ -271,36 +272,40 @@ private static void CorrectPropertyType(CodeProperty currentProperty)
if (currentProperty.IsOfKind(CodePropertyKind.RequestAdapter))
currentProperty.Type.Name = "RequestAdapter";
else if (currentProperty.IsOfKind(CodePropertyKind.BackingStore))
currentProperty.Type.Name = currentProperty.Type.Name[1..]; // removing the "I"
currentProperty.Type.Name = currentProperty.Type.Name[1..].ToFirstCharacterUpperCase(); // removing the "I"
else if (currentProperty.IsOfKind(CodePropertyKind.Options))
currentProperty.Type.Name = "List[RequestOption]";
currentProperty.Type.Name = "list[RequestOption]";
else if (currentProperty.IsOfKind(CodePropertyKind.Headers))
currentProperty.Type.Name = "Dict[str, Union[str, List[str]]]";
currentProperty.Type.Name = "dict[str, Union[str, list[str]]]";
else if (currentProperty.IsOfKind(CodePropertyKind.AdditionalData))
{
currentProperty.Type.Name = "Dict[str, Any]";
currentProperty.Type.Name = "dict[str, Any]";
currentProperty.DefaultValue = "field(default_factory=dict)";
}
else if (currentProperty.IsOfKind(CodePropertyKind.PathParameters))
{
currentProperty.Type.IsNullable = false;
currentProperty.Type.Name = "Union[str, Dict[str, Any]]";
currentProperty.Type.Name = "Union[str, dict[str, Any]]";
if (!string.IsNullOrEmpty(currentProperty.DefaultValue))
currentProperty.DefaultValue = "{}";
}
else if (currentProperty.Kind is CodePropertyKind.Custom && currentProperty.Type.IsNullable && string.IsNullOrEmpty(currentProperty.DefaultValue))
{
currentProperty.DefaultValue = "None";
currentProperty.Type.Name = currentProperty.Type.Name.ToFirstCharacterUpperCase();
}
else
{
currentProperty.Type.Name = currentProperty.Type.Name.ToFirstCharacterUpperCase();
}
currentProperty.Type.Name = currentProperty.Type.Name.ToFirstCharacterUpperCase();
CorrectCoreTypes(currentProperty.Parent as CodeClass, DateTypesReplacements, currentProperty.Type);
}
private static void CorrectMethodType(CodeMethod currentMethod)
{
if (currentMethod.IsOfKind(CodeMethodKind.Serializer))
currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.Serializer) && x.Type.Name.StartsWith('I')).ToList().ForEach(x => x.Type.Name = x.Type.Name[1..]);
else if (currentMethod.IsOfKind(CodeMethodKind.Deserializer))
currentMethod.ReturnType.Name = "Dict[str, Callable[[ParseNode], None]]";
currentMethod.ReturnType.Name = "dict[str, Callable[[ParseNode], None]]";
else if (currentMethod.IsOfKind(CodeMethodKind.ClientConstructor, CodeMethodKind.Constructor, CodeMethodKind.Factory))
{
currentMethod.Parameters.Where(x => x.IsOfKind(CodeParameterKind.RequestAdapter, CodeParameterKind.BackingStore, CodeParameterKind.ParseNode))
Expand All @@ -311,7 +316,7 @@ private static void CorrectMethodType(CodeMethod currentMethod)
if (urlTplParams != null &&
urlTplParams.Type is CodeType originalType)
{
originalType.Name = "Union[str, Dict[str, Any]]";
originalType.Name = "Union[str, dict[str, Any]]";
urlTplParams.Documentation.DescriptionTemplate = "The raw url or the url-template parameters for the request.";
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/Kiota.Builder/Writers/Python/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ private void WriteDeserializerBodyForIntersectionModel(CodeClass parentClass, La
private void WriteDeserializerBodyForInheritedModel(bool inherits, CodeMethod codeElement, CodeClass parentClass, LanguageWriter writer)
{
_codeUsingWriter.WriteInternalImports(parentClass, writer);
writer.StartBlock($"fields: Dict[str, Callable[[Any], {NoneKeyword}]] = {{");
writer.StartBlock($"fields: dict[str, Callable[[Any], {NoneKeyword}]] = {{");
foreach (var otherProp in parentClass
.GetPropertiesOfKind(CodePropertyKind.Custom)
.Where(static x => !x.ExistsInBaseType)
Expand Down Expand Up @@ -599,7 +599,7 @@ private void WriteRequestExecutorBody(CodeMethod codeElement, RequestParams requ
{
_codeUsingWriter.WriteInternalErrorMappingImports(parentClass, writer);
errorMappingVarName = "error_mapping";
writer.StartBlock($"{errorMappingVarName}: Dict[str, type[ParsableFactory]] = {{");
writer.StartBlock($"{errorMappingVarName}: dict[str, type[ParsableFactory]] = {{");
foreach (var errorMapping in codeElement.ErrorMappings)
{
writer.WriteLine($"\"{errorMapping.Key.ToUpperInvariant()}\": {errorMapping.Value.Name},");
Expand Down Expand Up @@ -656,7 +656,6 @@ private void WriteSerializerBodyForInheritedModel(bool inherits, CodeClass paren
{
if (inherits)
writer.WriteLine("super().serialize(writer)");
_codeUsingWriter.WriteInternalImports(parentClass, writer);
foreach (var otherProp in parentClass
.GetPropertiesOfKind(CodePropertyKind.Custom)
.Where(static x => !x.ExistsInBaseType && !x.ReadOnly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override string GetTypeString(CodeTypeBase code, CodeElement targetElemen
ArgumentNullException.ThrowIfNull(targetElement);
if (code is null)
return string.Empty;
var collectionPrefix = code.CollectionKind == CodeTypeCollectionKind.None && includeCollectionInformation ? string.Empty : "List[";
var collectionPrefix = code.CollectionKind == CodeTypeCollectionKind.None && includeCollectionInformation ? string.Empty : "list[";
var collectionSuffix = code.CollectionKind == CodeTypeCollectionKind.None && includeCollectionInformation ? string.Empty : "]";
if (code is CodeComposedTypeBase currentUnion && currentUnion.Types.Any())
return currentUnion.Types.Select(x => GetTypeString(x, targetElement, true, writer)).Aggregate((x, y) => $"Union[{x}, {TranslateAllTypes(y)}]");
Expand Down
2 changes: 1 addition & 1 deletion src/kiota/kiota.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Title>Microsoft.OpenApi.Kiota</Title>
<PackageId>Microsoft.OpenApi.Kiota</PackageId>
<PackageOutputPath>./nupkg</PackageOutputPath>
<VersionPrefix>1.22.2</VersionPrefix>
<VersionPrefix>1.23.0</VersionPrefix>
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
<PackageReleaseNotes>
https://github.com/microsoft/kiota/releases
Expand Down
Loading

0 comments on commit fc43b0a

Please sign in to comment.