Skip to content

Commit e8280df

Browse files
Add list alias objects to petstore specification and regenerate samples
1 parent c89c889 commit e8280df

File tree

97 files changed

+293
-2391
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+293
-2391
lines changed

modules/openapi-generator/src/test/java/org/openapitools/codegen/csharpnetcore/CSharpModelTest.java

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,19 @@ public void nullablePropertyWithNullableReferenceTypesTest() {
376376
.addProperties("name", new StringSchema().nullable(true))
377377
.addProperties("subObject", new Schema().addProperties("name", new StringSchema())
378378
.nullable(true))
379-
.addProperties("deepAliasArray", new ArraySchema()
379+
.addProperties("deepNullableAliasArray", new ArraySchema()
380380
.items(new ArraySchema()
381-
.items(new StringSchema())
381+
.items(new StringSchema()
382+
.nullable(true))
382383
.nullable(true))
383384
.nullable(true))
385+
.addProperties("deepAliasArray", new ArraySchema()
386+
.items(new ArraySchema()
387+
.items(new StringSchema())))
388+
.addProperties("deepIntermediateNullableAliasArray", new ArraySchema()
389+
.items(new ArraySchema()
390+
.items(new StringSchema())
391+
.nullable(true)))
384392
.addRequiredItem("id");
385393
final DefaultCodegen codegen = new AspNetServerCodegen();
386394
codegen.processOpts();
@@ -393,7 +401,7 @@ public void nullablePropertyWithNullableReferenceTypesTest() {
393401
Assert.assertEquals(cm.name, "sample");
394402
Assert.assertEquals(cm.classname, "Sample");
395403
Assert.assertEquals(cm.description, "a sample model");
396-
Assert.assertEquals(cm.vars.size(), 5);
404+
Assert.assertEquals(cm.vars.size(), 7);
397405

398406
final CodegenProperty property1 = cm.vars.get(0);
399407
Assert.assertEquals(property1.baseName, "id");
@@ -434,15 +442,31 @@ public void nullablePropertyWithNullableReferenceTypesTest() {
434442
Assert.assertFalse(property4.isPrimitiveType);
435443

436444
final CodegenProperty property5 = cm.vars.get(4);
437-
Assert.assertEquals(property5.baseName, "deepAliasArray");
438-
Assert.assertEquals(property5.dataType, "List<List<string>>");
439-
Assert.assertEquals(property5.name, "DeepAliasArray");
445+
Assert.assertEquals(property5.baseName, "deepNullableAliasArray");
446+
Assert.assertEquals(property5.dataType, "List<List<string?>>");
447+
Assert.assertEquals(property5.name, "DeepNullableAliasArray");
440448
Assert.assertNull(property5.defaultValue);
441449
Assert.assertEquals(property5.baseType, "List?");
442450
Assert.assertEquals(property5.containerType, "array");
443451
Assert.assertFalse(property5.required);
444452
Assert.assertFalse(property5.isPrimitiveType);
445453
Assert.assertTrue(property5.isContainer);
454+
455+
final CodegenProperty property6 = cm.vars.get(5);
456+
Assert.assertEquals(property6.baseName, "deepAliasArray");
457+
Assert.assertEquals(property6.dataType, "List<List<string>>");
458+
Assert.assertEquals(property6.name, "DeepAliasArray");
459+
Assert.assertEquals(property6.baseType, "List");
460+
Assert.assertEquals(property6.containerType, "array");
461+
Assert.assertTrue(property6.isContainer);
462+
463+
final CodegenProperty property7 = cm.vars.get(6);
464+
Assert.assertEquals(property7.baseName, "deepIntermediateNullableAliasArray");
465+
Assert.assertEquals(property7.dataType, "List<List<string>>");
466+
Assert.assertEquals(property7.name, "DeepIntermediateNullableAliasArray");
467+
Assert.assertEquals(property7.baseType, "List");
468+
Assert.assertEquals(property7.containerType, "array");
469+
Assert.assertTrue(property7.isContainer);
446470
}
447471

448472
@Test(description = "convert a model with list property")

modules/openapi-generator/src/test/resources/3_0/csharp/petstore-with-fake-endpoints-models-for-testing-with-http-signature.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2935,16 +2935,16 @@ components:
29352935
description: list of named parameters for current message
29362936
additionalProperties:
29372937
type: string
2938-
list:
2939-
type: array
2940-
items:
2941-
type: string
2942-
deepList:
2943-
type: array
2944-
items:
2945-
type: array
2946-
items:
2947-
type: string
2938+
ListAlias:
2939+
type: array
2940+
items:
2941+
type: string
2942+
DeepListAlias:
2943+
type: array
2944+
items:
2945+
type: array
2946+
items:
2947+
type: string
29482948
TestResult:
29492949
type: object
29502950
allOf:

samples/client/petstore/csharp/generichost/net4.7/FormModels/api/openapi.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,17 +2686,17 @@ components:
26862686
type: string
26872687
description: list of named parameters for current message
26882688
type: object
2689-
list:
2690-
items:
2691-
type: string
2692-
type: array
2693-
deepList:
2694-
items:
2695-
items:
2696-
type: string
2697-
type: array
2698-
type: array
26992689
type: object
2690+
ListAlias:
2691+
items:
2692+
type: string
2693+
type: array
2694+
DeepListAlias:
2695+
items:
2696+
items:
2697+
type: string
2698+
type: array
2699+
type: array
27002700
TestResult:
27012701
allOf:
27022702
- $ref: "#/components/schemas/Result"

samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/Result.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**Code** | **string** | Result code | [optional]
88
**Data** | **Dictionary&lt;string, string&gt;** | list of named parameters for current message | [optional]
9-
**DeepList** | **List&lt;List&lt;string&gt;&gt;** | | [optional]
10-
**List** | **List&lt;string&gt;** | | [optional]
119
**Uuid** | **string** | Result unique identifier | [optional]
1210

1311
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

samples/client/petstore/csharp/generichost/net4.7/FormModels/docs/models/TestResult.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Name | Type | Description | Notes
66
------------ | ------------- | ------------- | -------------
77
**Code** | **TestResultCode** | | [optional]
88
**Data** | **Dictionary&lt;string, string&gt;** | list of named parameters for current message | [optional]
9-
**DeepList** | **List&lt;List&lt;string&gt;&gt;** | | [optional]
10-
**List** | **List&lt;string&gt;** | | [optional]
119
**Uuid** | **string** | Result unique identifier | [optional]
1210

1311
[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md)

samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/Result.cs

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -78,32 +78,6 @@ public Result(Option<string> code = default, Option<Dictionary<string, string>>
7878
[JsonPropertyName("data")]
7979
public Dictionary<string, string> Data { get { return this.DataOption; } set { this.DataOption = new Option<Dictionary<string, string>>(value); } }
8080

81-
/// <summary>
82-
/// Used to track the state of DeepList
83-
/// </summary>
84-
[JsonIgnore]
85-
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
86-
public Option<List<List<string>>> DeepListOption { get; private set; }
87-
88-
/// <summary>
89-
/// Gets or Sets DeepList
90-
/// </summary>
91-
[JsonPropertyName("deepList")]
92-
public List<List<string>> DeepList { get { return this.DeepListOption; } set { this.DeepListOption = new Option<List<List<string>>>(value); } }
93-
94-
/// <summary>
95-
/// Used to track the state of List
96-
/// </summary>
97-
[JsonIgnore]
98-
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
99-
public Option<List<string>> ListOption { get; private set; }
100-
101-
/// <summary>
102-
/// Gets or Sets List
103-
/// </summary>
104-
[JsonPropertyName("list")]
105-
public List<string> List { get { return this.ListOption; } set { this.ListOption = new Option<List<string>>(value); } }
106-
10781
/// <summary>
10882
/// Used to track the state of Uuid
10983
/// </summary>
@@ -134,8 +108,6 @@ public override string ToString()
134108
sb.Append("class Result {\n");
135109
sb.Append(" Code: ").Append(Code).Append("\n");
136110
sb.Append(" Data: ").Append(Data).Append("\n");
137-
sb.Append(" DeepList: ").Append(DeepList).Append("\n");
138-
sb.Append(" List: ").Append(List).Append("\n");
139111
sb.Append(" Uuid: ").Append(Uuid).Append("\n");
140112
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
141113
sb.Append("}\n");
@@ -177,8 +149,6 @@ public override Result Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
177149

178150
Option<string> code = default;
179151
Option<Dictionary<string, string>> data = default;
180-
Option<List<List<string>>> deepList = default;
181-
Option<List<string>> list = default;
182152
Option<string> uuid = default;
183153

184154
while (utf8JsonReader.Read())
@@ -202,12 +172,6 @@ public override Result Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
202172
case "data":
203173
data = new Option<Dictionary<string, string>>(JsonSerializer.Deserialize<Dictionary<string, string>>(ref utf8JsonReader, jsonSerializerOptions));
204174
break;
205-
case "deepList":
206-
deepList = new Option<List<List<string>>>(JsonSerializer.Deserialize<List<List<string>>>(ref utf8JsonReader, jsonSerializerOptions));
207-
break;
208-
case "list":
209-
list = new Option<List<string>>(JsonSerializer.Deserialize<List<string>>(ref utf8JsonReader, jsonSerializerOptions));
210-
break;
211175
case "uuid":
212176
uuid = new Option<string>(utf8JsonReader.GetString());
213177
break;
@@ -223,16 +187,10 @@ public override Result Read(ref Utf8JsonReader utf8JsonReader, Type typeToConver
223187
if (data.IsSet && data.Value == null)
224188
throw new ArgumentNullException(nameof(data), "Property is not nullable for class Result.");
225189

226-
if (deepList.IsSet && deepList.Value == null)
227-
throw new ArgumentNullException(nameof(deepList), "Property is not nullable for class Result.");
228-
229-
if (list.IsSet && list.Value == null)
230-
throw new ArgumentNullException(nameof(list), "Property is not nullable for class Result.");
231-
232190
if (uuid.IsSet && uuid.Value == null)
233191
throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class Result.");
234192

235-
return new Result(code, data, deepList, list, uuid);
193+
return new Result(code, data, uuid);
236194
}
237195

238196
/// <summary>
@@ -265,12 +223,6 @@ public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializer
265223
if (result.DataOption.IsSet && result.Data == null)
266224
throw new ArgumentNullException(nameof(result.Data), "Property is required for class Result.");
267225

268-
if (result.DeepListOption.IsSet && result.DeepList == null)
269-
throw new ArgumentNullException(nameof(result.DeepList), "Property is required for class Result.");
270-
271-
if (result.ListOption.IsSet && result.List == null)
272-
throw new ArgumentNullException(nameof(result.List), "Property is required for class Result.");
273-
274226
if (result.UuidOption.IsSet && result.Uuid == null)
275227
throw new ArgumentNullException(nameof(result.Uuid), "Property is required for class Result.");
276228

@@ -282,16 +234,6 @@ public void WriteProperties(Utf8JsonWriter writer, Result result, JsonSerializer
282234
writer.WritePropertyName("data");
283235
JsonSerializer.Serialize(writer, result.Data, jsonSerializerOptions);
284236
}
285-
if (result.DeepListOption.IsSet)
286-
{
287-
writer.WritePropertyName("deepList");
288-
JsonSerializer.Serialize(writer, result.DeepList, jsonSerializerOptions);
289-
}
290-
if (result.ListOption.IsSet)
291-
{
292-
writer.WritePropertyName("list");
293-
JsonSerializer.Serialize(writer, result.List, jsonSerializerOptions);
294-
}
295237
if (result.UuidOption.IsSet)
296238
writer.WriteString("uuid", result.Uuid);
297239
}

samples/client/petstore/csharp/generichost/net4.7/FormModels/src/Org.OpenAPITools/Model/TestResult.cs

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,12 @@ public partial class TestResult : IValidatableObject
3434
/// </summary>
3535
/// <param name="code">code</param>
3636
/// <param name="data">list of named parameters for current message</param>
37-
/// <param name="deepList">deepList</param>
38-
/// <param name="list">list</param>
3937
/// <param name="uuid">Result unique identifier</param>
4038
[JsonConstructor]
41-
public TestResult(Option<TestResultCode?> code = default, Option<Dictionary<string, string>> data = default, Option<List<List<string>>> deepList = default, Option<List<string>> list = default, Option<string> uuid = default)
39+
public TestResult(Option<TestResultCode?> code = default, Option<Dictionary<string, string>> data = default, Option<string> uuid = default)
4240
{
4341
CodeOption = code;
4442
DataOption = data;
45-
DeepListOption = deepList;
46-
ListOption = list;
4743
UuidOption = uuid;
4844
OnCreated();
4945
}
@@ -77,32 +73,6 @@ public TestResult(Option<TestResultCode?> code = default, Option<Dictionary<stri
7773
[JsonPropertyName("data")]
7874
public Dictionary<string, string> Data { get { return this.DataOption; } set { this.DataOption = new Option<Dictionary<string, string>>(value); } }
7975

80-
/// <summary>
81-
/// Used to track the state of DeepList
82-
/// </summary>
83-
[JsonIgnore]
84-
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
85-
public Option<List<List<string>>> DeepListOption { get; private set; }
86-
87-
/// <summary>
88-
/// Gets or Sets DeepList
89-
/// </summary>
90-
[JsonPropertyName("deepList")]
91-
public List<List<string>> DeepList { get { return this.DeepListOption; } set { this.DeepListOption = new Option<List<List<string>>>(value); } }
92-
93-
/// <summary>
94-
/// Used to track the state of List
95-
/// </summary>
96-
[JsonIgnore]
97-
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
98-
public Option<List<string>> ListOption { get; private set; }
99-
100-
/// <summary>
101-
/// Gets or Sets List
102-
/// </summary>
103-
[JsonPropertyName("list")]
104-
public List<string> List { get { return this.ListOption; } set { this.ListOption = new Option<List<string>>(value); } }
105-
10676
/// <summary>
10777
/// Used to track the state of Uuid
10878
/// </summary>
@@ -133,8 +103,6 @@ public override string ToString()
133103
sb.Append("class TestResult {\n");
134104
sb.Append(" Code: ").Append(Code).Append("\n");
135105
sb.Append(" Data: ").Append(Data).Append("\n");
136-
sb.Append(" DeepList: ").Append(DeepList).Append("\n");
137-
sb.Append(" List: ").Append(List).Append("\n");
138106
sb.Append(" Uuid: ").Append(Uuid).Append("\n");
139107
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
140108
sb.Append("}\n");
@@ -176,8 +144,6 @@ public override TestResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
176144

177145
Option<TestResultCode?> code = default;
178146
Option<Dictionary<string, string>> data = default;
179-
Option<List<List<string>>> deepList = default;
180-
Option<List<string>> list = default;
181147
Option<string> uuid = default;
182148

183149
while (utf8JsonReader.Read())
@@ -203,12 +169,6 @@ public override TestResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
203169
case "data":
204170
data = new Option<Dictionary<string, string>>(JsonSerializer.Deserialize<Dictionary<string, string>>(ref utf8JsonReader, jsonSerializerOptions));
205171
break;
206-
case "deepList":
207-
deepList = new Option<List<List<string>>>(JsonSerializer.Deserialize<List<List<string>>>(ref utf8JsonReader, jsonSerializerOptions));
208-
break;
209-
case "list":
210-
list = new Option<List<string>>(JsonSerializer.Deserialize<List<string>>(ref utf8JsonReader, jsonSerializerOptions));
211-
break;
212172
case "uuid":
213173
uuid = new Option<string>(utf8JsonReader.GetString());
214174
break;
@@ -224,16 +184,10 @@ public override TestResult Read(ref Utf8JsonReader utf8JsonReader, Type typeToCo
224184
if (data.IsSet && data.Value == null)
225185
throw new ArgumentNullException(nameof(data), "Property is not nullable for class TestResult.");
226186

227-
if (deepList.IsSet && deepList.Value == null)
228-
throw new ArgumentNullException(nameof(deepList), "Property is not nullable for class TestResult.");
229-
230-
if (list.IsSet && list.Value == null)
231-
throw new ArgumentNullException(nameof(list), "Property is not nullable for class TestResult.");
232-
233187
if (uuid.IsSet && uuid.Value == null)
234188
throw new ArgumentNullException(nameof(uuid), "Property is not nullable for class TestResult.");
235189

236-
return new TestResult(code, data, deepList, list, uuid);
190+
return new TestResult(code, data, uuid);
237191
}
238192

239193
/// <summary>
@@ -263,12 +217,6 @@ public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSe
263217
if (testResult.DataOption.IsSet && testResult.Data == null)
264218
throw new ArgumentNullException(nameof(testResult.Data), "Property is required for class TestResult.");
265219

266-
if (testResult.DeepListOption.IsSet && testResult.DeepList == null)
267-
throw new ArgumentNullException(nameof(testResult.DeepList), "Property is required for class TestResult.");
268-
269-
if (testResult.ListOption.IsSet && testResult.List == null)
270-
throw new ArgumentNullException(nameof(testResult.List), "Property is required for class TestResult.");
271-
272220
if (testResult.UuidOption.IsSet && testResult.Uuid == null)
273221
throw new ArgumentNullException(nameof(testResult.Uuid), "Property is required for class TestResult.");
274222

@@ -282,16 +230,6 @@ public void WriteProperties(Utf8JsonWriter writer, TestResult testResult, JsonSe
282230
writer.WritePropertyName("data");
283231
JsonSerializer.Serialize(writer, testResult.Data, jsonSerializerOptions);
284232
}
285-
if (testResult.DeepListOption.IsSet)
286-
{
287-
writer.WritePropertyName("deepList");
288-
JsonSerializer.Serialize(writer, testResult.DeepList, jsonSerializerOptions);
289-
}
290-
if (testResult.ListOption.IsSet)
291-
{
292-
writer.WritePropertyName("list");
293-
JsonSerializer.Serialize(writer, testResult.List, jsonSerializerOptions);
294-
}
295233
if (testResult.UuidOption.IsSet)
296234
writer.WriteString("uuid", testResult.Uuid);
297235
}

0 commit comments

Comments
 (0)