test(api): enforce nullable channel now playing schema
This commit is contained in:
@@ -71,7 +71,32 @@ public class OpenApiErrorResponseContractTests
|
||||
stateProperties.TryGetProperty("channelId", out _).ShouldBeTrue();
|
||||
stateProperties.TryGetProperty("channelNumber", out _).ShouldBeTrue();
|
||||
stateProperties.TryGetProperty("onAir", out _).ShouldBeTrue();
|
||||
stateProperties.TryGetProperty("nowPlaying", out _).ShouldBeTrue();
|
||||
stateProperties.TryGetProperty("nowPlaying", out JsonElement nowPlaying).ShouldBeTrue();
|
||||
|
||||
JsonElement nowPlayingOneOf = nowPlaying.GetProperty("oneOf");
|
||||
nowPlayingOneOf.EnumerateArray().Count().ShouldBe(2);
|
||||
nowPlayingOneOf.EnumerateArray()
|
||||
.Any(s => s.TryGetProperty("type", out JsonElement type) && type.GetString() == "null")
|
||||
.ShouldBeTrue();
|
||||
nowPlayingOneOf.EnumerateArray()
|
||||
.Any(s => s.TryGetProperty("$ref", out JsonElement schemaRef) &&
|
||||
schemaRef.GetString() == "#/components/schemas/ChannelNowPlayingResponseModel")
|
||||
.ShouldBeTrue();
|
||||
|
||||
JsonElement nowPlayingProperties = document.RootElement
|
||||
.GetProperty("components")
|
||||
.GetProperty("schemas")
|
||||
.GetProperty("ChannelNowPlayingResponseModel")
|
||||
.GetProperty("properties");
|
||||
|
||||
nowPlayingProperties.TryGetProperty("title", out _).ShouldBeTrue();
|
||||
nowPlayingProperties.TryGetProperty("startUtc", out JsonElement startUtc).ShouldBeTrue();
|
||||
nowPlayingProperties.TryGetProperty("finishUtc", out JsonElement finishUtc).ShouldBeTrue();
|
||||
|
||||
startUtc.GetProperty("type").GetString().ShouldBe("string");
|
||||
startUtc.GetProperty("format").GetString().ShouldBe("date-time");
|
||||
finishUtc.GetProperty("type").GetString().ShouldBe("string");
|
||||
finishUtc.GetProperty("format").GetString().ShouldBe("date-time");
|
||||
}
|
||||
|
||||
[TestCase("/api/channels/{id}", "get", "404")]
|
||||
|
||||
@@ -3568,7 +3568,14 @@
|
||||
"type": "boolean"
|
||||
},
|
||||
"nowPlaying": {
|
||||
"$ref": "#/components/schemas/ChannelNowPlayingResponseModel"
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "null"
|
||||
},
|
||||
{
|
||||
"$ref": "#/components/schemas/ChannelNowPlayingResponseModel"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user