Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public OpenApiV2VersionService(OpenApiDiagnostic diagnostic)
private IDictionary<Type, Func<ParseNode, object>> _loaders = new Dictionary<Type, Func<ParseNode, object>>
{
[typeof(IOpenApiAny)] = OpenApiV2Deserializer.LoadAny,
[typeof(OpenApiContact)] = OpenApiV2Deserializer.LoadContact,
[typeof(OpenApiExternalDocs)] = OpenApiV2Deserializer.LoadExternalDocs,
[typeof(OpenApiHeader)] = OpenApiV2Deserializer.LoadHeader,
[typeof(OpenApiInfo)] = OpenApiV2Deserializer.LoadInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public OpenApiV3VersionService(OpenApiDiagnostic diagnostic)
[typeof(IOpenApiAny)] = OpenApiV3Deserializer.LoadAny,
[typeof(OpenApiCallback)] = OpenApiV3Deserializer.LoadCallback,
[typeof(OpenApiComponents)] = OpenApiV3Deserializer.LoadComponents,
[typeof(OpenApiContact)] = OpenApiV3Deserializer.LoadContact,
[typeof(OpenApiEncoding)] = OpenApiV3Deserializer.LoadEncoding,
[typeof(OpenApiExample)] = OpenApiV3Deserializer.LoadExample,
[typeof(OpenApiExternalDocs)] = OpenApiV3Deserializer.LoadExternalDocs,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using FluentAssertions;
using Microsoft.OpenApi.Models;
using System;
using Xunit;

namespace Microsoft.OpenApi.Readers.Tests.V2Tests
{
public class OpenApiContactTests
{
[Fact]
public void ParseStringContactFragmentShouldSucceed()
{
var input = @"
{
""name"": ""API Support"",
""url"": ""http://www.swagger.io/support"",
""email"": ""support@swagger.io""
}
";
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi2_0, out diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());

contact.Should().BeEquivalentTo(
new OpenApiContact
{
Email = "support@swagger.io",
Name = "API Support",
Url = new Uri("http://www.swagger.io/support")
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

using FluentAssertions;
using Microsoft.OpenApi.Models;
using System;
using Xunit;

namespace Microsoft.OpenApi.Readers.Tests.V3Tests
{
public class OpenApiContactTests
{
[Fact]
public void ParseStringContactFragmentShouldSucceed()
{
var input = @"
{
""name"": ""API Support"",
""url"": ""http://www.swagger.io/support"",
""email"": ""support@swagger.io""
}
";
var reader = new OpenApiStringReader();
var diagnostic = new OpenApiDiagnostic();

// Act
var contact = reader.ReadFragment<OpenApiContact>(input, OpenApiSpecVersion.OpenApi3_0, out diagnostic);

// Assert
diagnostic.Should().BeEquivalentTo(new OpenApiDiagnostic());

contact.Should().BeEquivalentTo(
new OpenApiContact
{
Email = "support@swagger.io",
Name = "API Support",
Url = new Uri("http://www.swagger.io/support")
});
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.