-
Notifications
You must be signed in to change notification settings - Fork 304
Description
What are you generating using Kiota, clients or plugins?
API Client/SDK
In what context or format are you using Kiota?
Nuget tool
Client library/SDK language
Csharp
Describe the bug
I am trying to generate a CSharp client out of a openapi.json. The json contains a schema with a property containing escaped characters.
It seems like the generated client escapes the characters on generation which can cause compilation errors.
link to repo: https://github.com/mchanyeechoy/kiota-generation-bug
Rather than generating:
public FilesInfoInput()
{
AdditionalData = new Dictionary<string, object>();
Content = "this is a test file with\nlinebreaks\nand \"strings surrounded by double quotes\"";
}it generated (which does not compile):
public FilesInfoInput()
{
AdditionalData = new Dictionary<string, object>();
Content = "this is a test file with
linebreaks
and "strings surrounded by double quotes"";
}Expected behavior
The property string should stay how it is from the json file. From the provided example, the \n and \" should not be converted to linebreaks and ". I would have expected the string: "this is a test file with\nlinebreaks\nand \"strings surrounded by double quotes\""
There should not be a requirement of escaping an already escaped character such as \\n.
How to reproduce
The repo contains the bug https://github.com/mchanyeechoy/kiota-generation-bug
I ran the command kiota generate -l CSharp -d ./openapi.json --exclude-backward-compatible --clean-output
The CSharp generated should be invalid
Open API description file
Kiota Version
1.25.1+1d771798165084d73f745111fd99df79bbea913c
Latest Kiota version known to work for scenario above?(Not required)
No response
Known Workarounds
using a script to escape the backslash characters so they won't get escaped on generation
e.g. replace \n to \\n
Configuration
- OS: Windows 10/11
- Architecture: x64
Debug output
Click to expand log
```info: Kiota.Builder.KiotaBuilder[0]
Cleaning output directory D:\git\kiota-generation-bug.\output
dbug: Kiota.Builder.KiotaBuilder[0]
kiota version 1.25.1
info: Kiota.Builder.KiotaBuilder[0]
loaded description from local source
dbug: Kiota.Builder.KiotaBuilder[0]
step 1 - reading the stream - took 00:00:00.0551996
warn: Kiota.Builder.KiotaBuilder[0]
OpenAPI warning: #/ - A servers entry (v3) or host + basePath + schemes properties (v2) was not present in the OpenAPI description. The root URL will need to be set manually with the request adapter.
dbug: Kiota.Builder.KiotaBuilder[0]
step 2 - parsing the document - took 00:00:00.0746349
dbug: Kiota.Builder.KiotaBuilder[0]
step 3 - updating generation configuration from kiota extension - took 00:00:00.0001001
dbug: Kiota.Builder.KiotaBuilder[0]
step 4 - filtering API paths with patterns - took 00:00:00.0655893
warn: Kiota.Builder.KiotaBuilder[0]
No server url found in the OpenAPI document. The base url will need to be set when using the client.
dbug: Kiota.Builder.KiotaBuilder[0]
step 5 - checking whether the output should be updated - took 00:00:00.0152149
dbug: Kiota.Builder.KiotaBuilder[0]
step 6 - create uri space - took 00:00:00.0016100
dbug: Kiota.Builder.KiotaBuilder[0]
InitializeInheritanceIndex 00:00:00.0031435
dbug: Kiota.Builder.KiotaBuilder[0]
CreateRequestBuilderClass 00:00:00
dbug: Kiota.Builder.KiotaBuilder[0]
MapTypeDefinitions 00:00:00.0021102
dbug: Kiota.Builder.KiotaBuilder[0]
TrimInheritedModels 00:00:00
dbug: Kiota.Builder.KiotaBuilder[0]
CleanUpInternalState 00:00:00
dbug: Kiota.Builder.KiotaBuilder[0]
step 7 - create source model - took 00:00:00.0486331
dbug: Kiota.Builder.KiotaBuilder[0]
21ms: Language refinement applied
dbug: Kiota.Builder.KiotaBuilder[0]
step 8 - refine by language - took 00:00:00.0219925
dbug: Kiota.Builder.KiotaBuilder[0]
step 9 - writing files - took 00:00:00.0265587
info: Kiota.Builder.KiotaBuilder[0]
loaded description from local source
dbug: Kiota.Builder.KiotaBuilder[0]
step 10 - writing lock file - took 00:00:00.0138631
Generation completed successfully
dbug: Kiota.Builder.KiotaBuilder[0]
Api manifest path: D:\git\kiota-generation-bug\apimanifest.json
Hint: use the info command to get the list of dependencies you need to add to your project.
Example: kiota info -d "D:\git\kiota-generation-bug.\openapi.json" -l CSharp
Hint: use the --include-path and --exclude-path options with glob patterns to filter the paths generated.
Example: kiota generate --include-path "**/foo" -d "D:\git\kiota-generation-bug.\openapi.json"
</details>
### Other information
_No response_
Metadata
Metadata
Assignees
Labels
Type
Projects
Status