示例#1
0
        public void ParseBasicDiscriminatorShouldSucceed()
        {
            using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicDiscriminator.yaml")))
            {
                var yamlStream = new YamlStream();
                yamlStream.Load(new StreamReader(stream));
                var yamlNode = yamlStream.Documents.First().RootNode;

                var diagnostic = new OpenApiDiagnostic();
                var context    = new ParsingContext(diagnostic);

                var node = new MapNode(context, (YamlMappingNode)yamlNode);

                // Act
                var discriminator = OpenApiV3Deserializer.LoadDiscriminator(node);

                // Assert
                discriminator.Should().BeEquivalentTo(
                    new OpenApiDiscriminator
                {
                    PropertyName = "pet_type",
                    Mapping      =
                    {
                        ["puppy"]  = "#/components/schemas/Dog",
                        ["kitten"] = "Cat"
                    }
                });
            }
        }