public void ParseMinimalInfoShouldSucceed() { using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "minimalInfo.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 openApiInfo = OpenApiV3Deserializer.LoadInfo(node); // Assert openApiInfo.Should().BeEquivalentTo( new OpenApiInfo { Title = "Minimal Info", Version = "1.0.1" }); } }
public void ParseAdvancedInfoShouldSucceed() { using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedInfo.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 openApiInfo = OpenApiV3Deserializer.LoadInfo(node); // Assert openApiInfo.Should().BeEquivalentTo( new OpenApiInfo { Title = "Advanced Info", Description = "Sample Description", Version = "1.0.0", TermsOfService = new Uri("http://example.org/termsOfService"), Contact = new OpenApiContact { Email = "*****@*****.**", Extensions = { ["x-twitter"] = new OpenApiString("@exampleTwitterHandler") }, Name = "John Doe", Url = new Uri("http://www.example.com/url1") }, License = new OpenApiLicense { Extensions = { ["x-disclaimer"] = new OpenApiString("Sample Extension String Disclaimer") }, Name = "licenseName", Url = new Uri("http://www.example.com/url2") }, Extensions = { ["x-something"] = new OpenApiString("Sample Extension String Something"), ["x-contact"] = new OpenApiObject { ["name"] = new OpenApiString("John Doe"), ["url"] = new OpenApiString("http://www.example.com/url3"), ["email"] = new OpenApiString("*****@*****.**") }, ["x-list"] = new OpenApiArray { new OpenApiString("1"), new OpenApiString("2") } } }); } }
public void ParseBasicInfoShouldSucceed() { using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicInfo.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 openApiInfo = OpenApiV3Deserializer.LoadInfo(node); // Assert openApiInfo.Should().BeEquivalentTo( new OpenApiInfo { Title = "Basic Info", Description = "Sample Description", Version = "1.0.1", TermsOfService = new Uri("http://swagger.io/terms/"), Contact = new OpenApiContact { Email = "*****@*****.**", Name = "API Support", Url = new Uri("http://www.swagger.io/support") }, License = new OpenApiLicense { Name = "Apache 2.0", Url = new Uri("http://www.apache.org/licenses/LICENSE-2.0.html") } }); } }