|
| 1 | +using System.Linq; |
1 | 2 | using System.Net.Http;
|
2 | 3 | using System.Threading.Tasks;
|
3 | 4 |
|
@@ -55,32 +56,64 @@ public void Given_OpenApiDocument_Then_It_Should_Not_Return_ReferenceSchema(stri
|
55 | 56 | }
|
56 | 57 |
|
57 | 58 | [DataTestMethod]
|
58 |
| - [DataRow("baseObjectModel", "baseObjectValue", true)] |
59 |
| - [DataRow("baseObjectModel", "nonObjectValue", false)] |
60 |
| - [DataRow("baseObjectModel", "subObjectValue", false)] |
61 |
| - [DataRow("baseSubObjectModel", "baseSubObjectValue", true)] |
62 |
| - public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Expected_Type(string @ref, string propName, bool isBaseObject) |
| 59 | + [DataRow("baseObjectModel", "baseObjectValue")] |
| 60 | + [DataRow("baseSubObjectModel", "baseSubObjectValue")] |
| 61 | + public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Expected_TypeOf_Object(string @ref, string propName) |
63 | 62 | {
|
64 | 63 | var schemas = this._doc["components"]["schemas"];
|
65 | 64 |
|
66 | 65 | var type = schemas?[@ref]?["properties"]?[propName]?["type"]?.Value<string>() ;
|
67 | 66 |
|
68 |
| - if (isBaseObject) |
69 |
| - { |
70 |
| - type.Should().Be("object"); |
71 |
| - } |
72 |
| - else |
73 |
| - { |
74 |
| - type.Should().NotBe("object"); |
75 |
| - } |
| 67 | + type.Should().Be("object"); |
76 | 68 | }
|
77 | 69 |
|
78 |
| - // [TestMethod] |
79 |
| - // public void Given_OpenApiDocument_Then_It_Should_Return_Null() |
80 |
| - // { |
81 |
| - // var @object = this._doc["components"]["schemas"]["object"]; |
| 70 | + [DataTestMethod] |
| 71 | + [DataRow("baseObjectModel", "nonObjectValue")] |
| 72 | + [DataRow("baseObjectModel", "subObjectValue")] |
| 73 | + public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Not_Return_Expected_TypeOf_Object(string @ref, string propName) |
| 74 | + { |
| 75 | + var schemas = this._doc["components"]["schemas"]; |
| 76 | + |
| 77 | + var type = schemas?[@ref]?["properties"]?[propName]?["type"]?.Value<string>() ; |
| 78 | + |
| 79 | + type.Should().NotBe("object"); |
| 80 | + } |
| 81 | + |
| 82 | + [DataTestMethod] |
| 83 | + [DataRow("baseObjectModel", "baseObjectList", "array")] |
| 84 | + [DataRow("baseObjectModel", "baseObjectDictionary", "object")] |
| 85 | + public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Expected_Type(string @ref, string propName, string listType) |
| 86 | + { |
| 87 | + var schemas = this._doc["components"]["schemas"]; |
| 88 | + |
| 89 | + var type = schemas?[@ref]?["properties"]?[propName]?["type"]?.Value<string>(); |
| 90 | + |
| 91 | + type.Should().Be(listType); |
| 92 | + } |
82 | 93 |
|
83 |
| - // @object.Should().BeNull(); |
84 |
| - // } |
| 94 | + [DataTestMethod] |
| 95 | + [DataRow("baseObjectModel", "baseObjectList", "items", "object")] |
| 96 | + [DataRow("baseObjectModel", "baseObjectDictionary", "additionalProperties", "object")] |
| 97 | + public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Expected_SubType(string @ref, string propName, string attrName, string subType) |
| 98 | + { |
| 99 | + var schemas = this._doc["components"]["schemas"]; |
| 100 | + |
| 101 | + var property = schemas?[@ref]?["properties"]?[propName]; |
| 102 | + var attr = property[attrName]; |
| 103 | + |
| 104 | + attr["type"].Value<string>().Should().Be(subType); |
| 105 | + } |
| 106 | + |
| 107 | + [DataTestMethod] |
| 108 | + [DataRow("baseObjectModel", "baseObjectList", "items")] |
| 109 | + [DataRow("baseObjectModel", "baseObjectDictionary", "additionalProperties")] |
| 110 | + public void Given_OpenApiDocument_And_BaseObject_Then_It_Should_Return_Null_Title(string @ref, string propName, string attr) |
| 111 | + { |
| 112 | + var schemas = this._doc["components"]["schemas"]; |
| 113 | + |
| 114 | + var title = schemas?[@ref]?["properties"]?[propName]?[attr]?["title"]?.Value<string>(); |
| 115 | + |
| 116 | + title.Should().BeNull(); |
| 117 | + } |
85 | 118 | }
|
86 | 119 | }
|
0 commit comments