Skip to content

Commit 97b2b45

Browse files
committed
chore: adds additional multiple levels of references test cases
1 parent 85f1dfb commit 97b2b45

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/Microsoft.OpenApi.Readers.Tests/V31Tests/RelativeReferenceTests.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,39 @@ public async Task ShouldResolveReferencesInSchemasFromSystemTextJson()
434434
var updatedTagsProperty = Assert.IsType<OpenApiSchemaReference>(schema.Properties["tags"]);
435435
Assert.Equal(absoluteReferenceId, updatedTagsProperty.Reference.ReferenceV3);
436436
Assert.Equal(JsonSchemaType.Array | JsonSchemaType.Null, updatedTagsProperty.Type);
437+
Assert.Equal(JsonSchemaType.Object, updatedTagsProperty.Items.Type);
438+
439+
var pathItem = new OpenApiPathItem
440+
{
441+
Operations = new Dictionary<HttpMethod, OpenApiOperation>
442+
{
443+
[HttpMethod.Post] = new OpenApiOperation
444+
{
445+
Responses = new OpenApiResponses
446+
{
447+
["200"] = new OpenApiResponse
448+
{
449+
}
450+
},
451+
RequestBody = new OpenApiRequestBody
452+
{
453+
Content = new Dictionary<string, OpenApiMediaType>
454+
{
455+
["application/json"] = new OpenApiMediaType
456+
{
457+
Schema = new OpenApiSchemaReference("#/components/schemas/Foo", document)
458+
}
459+
}
460+
}
461+
}
462+
}
463+
};
464+
document.Paths.Add("/", pathItem);
465+
466+
var requestBodySchema = pathItem.Operations[HttpMethod.Post].RequestBody.Content["application/json"].Schema;
467+
Assert.NotNull(requestBodySchema);
468+
var requestBodyTagsProperty = Assert.IsType<OpenApiSchemaReference>(requestBodySchema.Properties["tags"]);
469+
Assert.Equal(JsonSchemaType.Object, requestBodyTagsProperty.Items.Type);
437470
}
438471
}
439472
}

0 commit comments

Comments
 (0)