Skip to content

Commit

Permalink
Fixed invalid code in Php caused by "*/*/" in property description
Browse files Browse the repository at this point in the history
  • Loading branch information
Microsoft Graph DevX Tooling authored and Microsoft Graph DevX Tooling committed Nov 13, 2024
1 parent 5fdd328 commit 2b23581
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

### Changed

- Fixed Python error when a class inherits from a base class and implements an interface. [5637](https://github.com/microsoft/kiota/issues/5637)
- Fix anyOf/oneOf generation in TypeScript. [5353](https://github.com/microsoft/kiota/issues/5353)
- Fixed invalid code in Php caused by "*/*/" in property description. [5635](https://github.com/microsoft/kiota/issues/5635)

## [1.20.0] - 2024-11-07

Expand Down
2 changes: 1 addition & 1 deletion src/Kiota.Builder/Writers/Php/PhpConventionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ private string GetCollectionDocString(CodeParameter codeParameter)
return codeParameter.Optional ? $"{doc}|null" : doc;
}

internal static string RemoveInvalidDescriptionCharacters(string originalDescription) => originalDescription.Replace("\\", "/", StringComparison.OrdinalIgnoreCase);
internal static string RemoveInvalidDescriptionCharacters(string originalDescription) => originalDescription.Replace("\\", "/", StringComparison.OrdinalIgnoreCase).Replace("*/", "", StringComparison.OrdinalIgnoreCase);
public override bool WriteShortDescription(IDocumentedElement element, LanguageWriter writer, string prefix = "", string suffix = "")
{
ArgumentNullException.ThrowIfNull(writer);
Expand Down
22 changes: 22 additions & 0 deletions tests/Kiota.Builder.Tests/Writers/Php/CodePropertyWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,26 @@ public async Task WriteRequestOptionAsync()
Assert.Contains("@var array<RequestOption>|null $options", result);
Assert.Contains("public ?array $options = null;", result);
}

[Fact]
public void WritePropertyWithDescription()
{
CodeProperty property = new CodeProperty
{
Name = "name",
Documentation = new()
{
DescriptionTemplate = "The name pattern that branches must match in order to deploy to the environment.Wildcard characters will not match `/`. For example, to match branches that begin with `release/` and contain an additional single slash, use `release/*/*`.For more information about pattern matching syntax, see the [Ruby File.fnmatch documentation](https://ruby-doc.org/core-2.5.1/File.html#method-c-fnmatch).",
},
Type = new CodeType
{
Name = "string"
},
Access = AccessModifier.Private
};
parentClass.AddProperty(property);
propertyWriter.WriteCodeElement(property, languageWriter);
var result = stringWriter.ToString();
Assert.DoesNotContain("/*/*", result);
}
}

0 comments on commit 2b23581

Please sign in to comment.