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

fix: missing ts path parameters #5248

Merged
merged 2 commits into from
Aug 27, 2024
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 @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed shorthand for refresh option in workspace experience. [#5240](https://github.com/microsoft/kiota/issues/5240)
- Fixed missing type options in help for plugin commands. [#5230](https://github.com/microsoft/kiota/issues/5230)
- Removed OpenAI plugins generation since the service does not support them anymore.
- Fixed an issue where TypeScript clients would be missing path parameters. [#5247](https://github.com/microsoft/kiota/issues/5247)
- Redirect status codes documenting an application/octet-stream content type now generate a stream return type. [#5246](https://github.com/microsoft/kiota/issues/5246)
- Fixed an issue where models would be missing when they had no properties and a single allOf entry. [#5014](https://github.com/microsoft/kiota/issues/5014)
- Reverts modification of responses in output openApi file when generating plugins [#4945](https://github.com/microsoft/kiota/issues/4945)
Expand Down
4 changes: 4 additions & 0 deletions src/Kiota.Builder/CodeDOM/CodeParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public bool Optional
public CodeDocumentation Documentation { get; set; } = new();
public string DefaultValue { get; set; } = string.Empty;
public string SerializationName { get; set; } = string.Empty;
public string WireName
{
get => string.IsNullOrEmpty(SerializationName) ? Name : SerializationName;
}
public DeprecationInformation? Deprecation
{
get;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
}
}

private void WriteNavigationMetadataConstant(CodeConstant codeElement, LanguageWriter writer)

Check warning on line 37 in src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Make 'WriteNavigationMetadataConstant' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)

Check warning on line 37 in src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Make 'WriteNavigationMetadataConstant' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
if (codeElement.OriginalCodeElement is not CodeClass codeClass) throw new InvalidOperationException("Original CodeElement cannot be null");

Check warning on line 39 in src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'Original CodeElement cannot be null' 4 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)

Check warning on line 39 in src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Define a constant instead of using this literal 'Original CodeElement cannot be null' 4 times. (https://rules.sonarsource.com/csharp/RSPEC-1192)
if (codeElement.Parent is not CodeFile parentCodeFile || parentCodeFile.FindChildByName<CodeInterface>(codeElement.Name.Replace(CodeConstant.NavigationMetadataSuffix, string.Empty, StringComparison.Ordinal), false) is not CodeInterface currentInterface)
throw new InvalidOperationException("Couldn't find the associated interface for the navigation metadata constant");
var navigationMethods = codeClass.Methods
Expand All @@ -56,7 +56,7 @@
{
writer.StartBlock($"{navigationMethod.Name.ToFirstCharacterLowerCase()}: {{");
var requestBuilderName = navigationMethod.ReturnType.Name.ToFirstCharacterUpperCase();
WriteNavigationMetadataEntry(parentNamespace, writer, requestBuilderName, navigationMethod.Parameters.Where(static x => x.Kind is CodeParameterKind.Path or CodeParameterKind.Custom && !string.IsNullOrEmpty(x.SerializationName)).Select(static x => $"\"{x.SerializationName}\"").ToArray());
WriteNavigationMetadataEntry(parentNamespace, writer, requestBuilderName, navigationMethod.Parameters.Where(static x => x.Kind is CodeParameterKind.Path or CodeParameterKind.Custom).Select(static x => $"\"{x.WireName}\"").ToArray());
writer.CloseBlock("},");
}
foreach (var navigationProperty in navigationProperties)
Expand All @@ -83,7 +83,7 @@
$"_{original.ToUpperInvariant()}" : // to avoid emitting strings that can't be minified
original.ToUpperInvariant();

private void WriteRequestsMetadataConstant(CodeConstant codeElement, LanguageWriter writer)

Check warning on line 86 in src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 34 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)

Check warning on line 86 in src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Refactor this method to reduce its Cognitive Complexity from 34 to the 15 allowed. (https://rules.sonarsource.com/csharp/RSPEC-3776)
{
if (codeElement.OriginalCodeElement is not CodeClass codeClass) throw new InvalidOperationException("Original CodeElement cannot be null");
if (codeClass.Methods
Expand Down Expand Up @@ -155,7 +155,7 @@
return "\"setContentFromParsable\"";
return "\"setContentFromScalar\"";
}
private string? GetBodySerializer(CodeParameter requestBody)

Check warning on line 158 in src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Make 'GetBodySerializer' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)

Check warning on line 158 in src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Make 'GetBodySerializer' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
if (requestBody.Type is CodeType currentType && (currentType.TypeDefinition is CodeInterface || currentType.Name.Equals("MultipartBody", StringComparison.OrdinalIgnoreCase)))
{
Expand Down Expand Up @@ -199,7 +199,7 @@
throw new InvalidOperationException($"Unable to find factory method for {targetClassName}");
}

private string GetSendRequestMethodName(bool isVoid, bool isStream, bool isCollection, bool isPrimitive, bool isEnum)

Check warning on line 202 in src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Make 'GetSendRequestMethodName' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
if (isVoid)
{
Expand All @@ -219,7 +219,7 @@
}
}

private void WriteUriTemplateConstant(CodeConstant codeElement, LanguageWriter writer)

Check warning on line 222 in src/Kiota.Builder/Writers/TypeScript/CodeConstantWriter.cs

View workflow job for this annotation

GitHub Actions / Build

Make 'WriteUriTemplateConstant' a static method. (https://rules.sonarsource.com/csharp/RSPEC-2325)
{
writer.WriteLine($"export const {codeElement.Name.ToFirstCharacterUpperCase()} = {codeElement.UriTemplate};");
}
Expand Down
Loading