Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- removes response handler generation in typescript #2843

Merged
merged 1 commit into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed an issue with query parameter name normalization in Ruby and Python. [#2825](https://github.com/microsoft/kiota/issues/2825)
- Fixed serialization of scalar members in union types for C#, Go, Java. [#2462](https://github.com/microsoft/kiota/issues/2462)
- Deprecated Visual Studio OpenAPI reference packages.
- Replaced response handler parameter by request option to reduce generated code size in TypeScript. [#1855](https://github.com/microsoft/kiota/issues/1855)
- Fixed a bug where a stackoverflow exception occurs when inlined schemas have self-references [2656](https://github.com/microsoft/kiota/issues/2656)
- Fixed nil safety while type casting values in collections in Go
- Moved common RequestBuilder ((request_adapter, url_template and path_parameters)) and RequestConfiguration(headers, options) properties to respective base classes in Python.[2440](https://github.com/microsoft/kiota/issues/2440)
Expand Down
3 changes: 1 addition & 2 deletions src/Kiota.Builder/Refiners/TypeScriptRefiner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public override Task Refine(CodeNamespace generatedCode, CancellationToken cance
return Task.Run(() =>
{
cancellationToken.ThrowIfCancellationRequested();
RemoveHandlerFromRequestBuilder(generatedCode);
ReplaceReservedNames(generatedCode, new TypeScriptReservedNamesProvider(), static x => $"{x}Escaped");
ReplaceReservedExceptionPropertyNames(generatedCode, new TypeScriptExceptionsReservedNamesProvider(), static x => $"{x}Escaped");
MoveRequestBuilderPropertiesToBaseType(generatedCode,
Expand Down Expand Up @@ -194,8 +195,6 @@ currentInterface.StartBlock is InterfaceDeclaration interfaceDeclaration &&
AbstractionsPackageName, "RequestOption"),
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestGenerator),
AbstractionsPackageName, "HttpMethod", "RequestInformation", "RequestOption"),
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor),
AbstractionsPackageName, "ResponseHandler"),
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Serializer),
AbstractionsPackageName, "SerializationWriter"),
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.Deserializer, CodeMethodKind.Factory),
Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Writers/TypeScript/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ private void WriteRequestExecutorBody(CodeMethod codeElement, CodeClass parentCl
}
writer.CloseBlock("} as Record<string, ParsableFactory<Parsable>>;");
}
writer.WriteLine($"return this.requestAdapter?.{genericTypeForSendMethod}(requestInfo,{newFactoryParameter} responseHandler, {errorMappingVarName}) ?? Promise.reject(new Error('request adapter is null'));");
writer.WriteLine($"return this.requestAdapter.{genericTypeForSendMethod}(requestInfo,{newFactoryParameter} {errorMappingVarName});");
}

private string GetTypeFactory(bool isVoid, bool isStream, CodeMethod codeElement, LanguageWriter writer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ public void WritesRequestExecutorBody()
Assert.Contains("\"403\": createError403FromDiscriminatorValue,", result);
Assert.Contains("as Record<string, ParsableFactory<Parsable>>", result);
Assert.Contains("sendAsync", result);
Assert.Contains("Promise.reject", result);
AssertExtensions.CurlyBracesAreClosed(result);
}
[Fact]
Expand Down