Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
baywet authored Feb 22, 2024
1 parent 2bb8492 commit dc3c443
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Kiota.Builder/Writers/Ruby/CodeMethodWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,16 @@ private void WriteRequestGeneratorBody(CodeMethod codeElement, RequestParams req
}
if (requestParams.requestBody != null)
{
var sanitizedRequestBodyContentType = codeElement.RequestBodyContentType.SanitizeDoubleQuote();
var sanitizedRequestBodyContentType = codeElement.RequestBodyContentType.SanitizeSingleQuote();
if (requestParams.requestBody.Type.Name.Equals(conventions.StreamTypeName, StringComparison.OrdinalIgnoreCase))
{
if (requestParams.requestContentType is not null)
writer.WriteLine($"request_info.set_stream_content({requestParams.requestBody.Name}, {requestParams.requestContentType.Name})");
else if (!string.IsNullOrEmpty(sanitizedRequestBodyContentType))
writer.WriteLine($"request_info.set_stream_content({requestParams.requestBody.Name}, \"{sanitizedRequestBodyContentType}\")");
writer.WriteLine($"request_info.set_stream_content({requestParams.requestBody.Name}, '{sanitizedRequestBodyContentType}')");
}
else if (parentClass.GetPropertyOfKind(CodePropertyKind.RequestAdapter) is CodeProperty requestAdapterProperty)
writer.WriteLine($"request_info.set_content_from_parsable(@{requestAdapterProperty.Name.ToSnakeCase()}, \"{sanitizedRequestBodyContentType}\", {requestParams.requestBody.Name})");
writer.WriteLine($"request_info.set_content_from_parsable(@{requestAdapterProperty.Name.ToSnakeCase()}, '{sanitizedRequestBodyContentType}', {requestParams.requestBody.Name})");
}
}
if (parentClass.GetPropertyOfKind(CodePropertyKind.PathParameters) is CodeProperty urlTemplateParamsProperty &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,6 @@ public void WritesRequestGeneratorContentTypeQuotes()
method.RequestBodyContentType = "application/json; profile=\"CamelCase\"";
writer.Write(method);
var result = tw.ToString();
Assert.Contains("\"application/json; profile=\\\"CamelCase\\\"\"", result);
Assert.Contains("'application/json; profile=\\'CamelCase\\''", result);
}
}

0 comments on commit dc3c443

Please sign in to comment.