@@ -81,7 +81,7 @@ public void CreateStructuredTypeSchemaThrowArgumentNullEnumType()
81
81
}
82
82
83
83
[ Fact ]
84
- public void CreateStructuredTypeSchemaWithDiscriminatorValueEnabledReturnsCorrectSchema ( )
84
+ public void CreateStructuredTypeSchemaForEntityTypeWithDiscriminatorValueEnabledReturnsCorrectSchema ( )
85
85
{
86
86
// Arrange
87
87
IEdmModel model = EdmModelHelper . GraphBetaModel ;
@@ -142,6 +142,48 @@ public void CreateStructuredTypeSchemaWithDiscriminatorValueEnabledReturnsCorrec
142
142
}" . ChangeLineBreaks ( ) , json ) ;
143
143
}
144
144
145
+ [ Fact ]
146
+ public void CreateStructuredTypeSchemaForComplexTypeWithDiscriminatorValueEnabledReturnsCorrectSchema ( )
147
+ {
148
+ // Arrange
149
+ IEdmModel model = EdmModelHelper . GraphBetaModel ;
150
+ ODataContext context = new ( model , new OpenApiConvertSettings
151
+ {
152
+ EnableDiscriminatorValue = true ,
153
+ } ) ;
154
+
155
+ IEdmComplexType complex = model . SchemaElements . OfType < IEdmComplexType > ( ) . First ( t => t . Name == "userSet" ) ;
156
+ Assert . NotNull ( complex ) ; // Guard
157
+
158
+ // Act
159
+ var schema = context . CreateStructuredTypeSchema ( complex ) ;
160
+ string json = schema . SerializeAsJson ( OpenApiSpecVersion . OpenApi3_0 ) ;
161
+
162
+ // Assert
163
+ Assert . NotNull ( json ) ;
164
+ Assert . Equal ( @"{
165
+ ""title"": ""userSet"",
166
+ ""type"": ""object"",
167
+ ""properties"": {
168
+ ""isBackup"": {
169
+ ""type"": ""boolean"",
170
+ ""nullable"": true
171
+ }
172
+ },
173
+ ""discriminator"": {
174
+ ""propertyName"": ""@odata.type"",
175
+ ""mapping"": {
176
+ ""#microsoft.graph.connectedOrganizationMembers"": ""#/components/schemas/microsoft.graph.connectedOrganizationMembers"",
177
+ ""#microsoft.graph.externalSponsors"": ""#/components/schemas/microsoft.graph.externalSponsors"",
178
+ ""#microsoft.graph.groupMembers"": ""#/components/schemas/microsoft.graph.groupMembers"",
179
+ ""#microsoft.graph.internalSponsors"": ""#/components/schemas/microsoft.graph.internalSponsors"",
180
+ ""#microsoft.graph.requestorManager"": ""#/components/schemas/microsoft.graph.requestorManager"",
181
+ ""#microsoft.graph.singleUser"": ""#/components/schemas/microsoft.graph.singleUser""
182
+ }
183
+ }
184
+ }" . ChangeLineBreaks ( ) , json ) ;
185
+ }
186
+
145
187
[ Fact ]
146
188
public void CreateStructuredTypePropertiesSchemaWithCustomAttributeReturnsCorrectSchema ( )
147
189
{
0 commit comments