C# code generator improvements (#933)

* Escape quotes in generated C# strings

* Handle response with JSON body in C# code generator
This commit is contained in:
Cezary Piątek
2023-05-07 14:37:48 +02:00
committed by GitHub
parent 7019a5a78c
commit 7d9e450814
3 changed files with 95 additions and 4 deletions

View File

@@ -16,11 +16,13 @@ server
.UsingMethod("POST")
.WithPath("/foo2")
.WithParam("p2", "abc")
.WithHeader("h1", "W/\"234f2q3r\"", true)
)
.WithGuid("1b731398-4a5b-457f-a6e3-d65e541c428f")
.RespondWith(Response.Create()
.WithStatusCode("201")
.WithHeader("hk", "hv")
.WithHeader("ETag", "W/\"168d8e\"")
.WithBody("2")
);
@@ -32,5 +34,32 @@ server
.WithGuid("f74fd144-df53-404f-8e35-da22a640bd5f")
.RespondWith(Response.Create()
.WithStatusCode(208)
.WithBodyAsJson(new
{
a = 1,
b = 1.2,
d = true,
e = false,
f = new [] { 1, 2, 3, 4 },
g = new
{
z1 = 1,
z2 = 2,
z3 = new [] { "a", "b", "c" },
z4 = new []
{
new
{
a = 1,
b = 2
},
new
{
a = 2,
b = 3
}
}
}
})
);