Skip to content

Commit a4330d4

Browse files
committed
WIP
1 parent 73c4043 commit a4330d4

File tree

3 files changed

+510
-8
lines changed

3 files changed

+510
-8
lines changed

src/NSwag.CodeGeneration.CSharp.Tests/IssueTests.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,83 @@ namespace NSwag.CodeGeneration.CSharp.Tests
55
{
66
public class IssueTests
77
{
8+
[Fact]
9+
public async Task Issue4587_allow_nullable_path_parameters()
10+
{
11+
// Arrange
12+
var swagger =
13+
@"{
14+
""openapi"": ""3.0.1"",
15+
""paths"": {
16+
""/api/1/{param}"": {
17+
""get"": {
18+
""parameters"": [
19+
{
20+
""name"": ""param"",
21+
""in"": ""path"",
22+
""required"": false,
23+
""schema"": {
24+
""type"": ""string"",
25+
}
26+
}
27+
],
28+
""responses"": {
29+
""200"": {
30+
""content"": {
31+
""application/json"": {
32+
""schema"": {
33+
""type"": ""string""
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
},
41+
""/api/2/{param}/info"": {
42+
""get"": {
43+
""parameters"": [
44+
{
45+
""name"": ""param"",
46+
""in"": ""path"",
47+
""required"": false,
48+
""schema"": {
49+
""type"": ""string"",
50+
}
51+
}
52+
],
53+
""responses"": {
54+
""200"": {
55+
""content"": {
56+
""application/json"": {
57+
""schema"": {
58+
""type"": ""string""
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}";
68+
var document = await OpenApiDocument.FromJsonAsync(swagger);
69+
70+
// Act
71+
var codeGen = new CSharpClientGenerator(document, new CSharpClientGeneratorSettings()
72+
{
73+
UseBaseUrl = false,
74+
GenerateClientInterfaces = true,
75+
OperationNameGenerator = new SingleClientFromOperationIdOperationNameGenerator()
76+
});
77+
78+
var code = codeGen.GenerateFile();
79+
80+
// Assert
81+
await VerifyHelper.Verify(code);
82+
CSharpCompiler.AssertCompile(code);
83+
}
84+
885
[Fact]
986
public async Task Issue5260_compilation_error_in_query_string_array_parameters()
1087
{

0 commit comments

Comments
 (0)