Example #1
0
        public void ParseAdvancedEncodingShouldSucceed()
        {
            using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedEncoding.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 encoding = OpenApiV3Deserializer.LoadEncoding(node);

                // Assert
                encoding.Should().BeEquivalentTo(
                    new OpenApiEncoding
                {
                    ContentType = "image/png, image/jpeg",
                    Headers     =
                    {
                        ["X-Rate-Limit-Limit"] =
                            new OpenApiHeader
                            {
                            Description = "The number of allowed requests in the current period",
                            Schema      = new OpenApiSchema
                            {
                            Type = "integer"
                            }
                            }
                    }
                });
            }
        }
Example #2
0
        public void ParseBasicEncodingShouldSucceed()
        {
            using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicEncoding.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 encoding = OpenApiV3Deserializer.LoadEncoding(node);

                // Assert
                encoding.Should().BeEquivalentTo(
                    new OpenApiEncoding
                {
                    ContentType = "application/xml; charset=utf-8"
                });
            }
        }