Skip to content

Commit 329e9b3

Browse files
committed
feat: adds path translation from v3 to v2 for validation errors
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
1 parent 101979e commit 329e9b3

File tree

5 files changed

+749
-0
lines changed

5 files changed

+749
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
#nullable enable
2+
Microsoft.OpenApi.OpenApiPathHelper
3+
static Microsoft.OpenApi.OpenApiPathHelper.GetVersionedPath(string! path, Microsoft.OpenApi.OpenApiSpecVersion targetVersion) -> string?
4+
Microsoft.OpenApi.OpenApiValidatorError.GetVersionedPointer(Microsoft.OpenApi.OpenApiSpecVersion targetVersion) -> string?
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT license.
3+
4+
namespace Microsoft.OpenApi;
5+
/// <summary>
6+
/// Defines a policy for matching and transforming OpenAPI JSON Pointer paths
7+
/// between specification versions.
8+
/// </summary>
9+
internal interface IOpenApiPathRepresentationPolicy
10+
{
11+
/// <summary>
12+
/// Determines whether this policy can handle the given path.
13+
/// </summary>
14+
/// <param name="path">The JSON Pointer path to evaluate.</param>
15+
/// <returns><c>true</c> if this policy applies to the given path; otherwise, <c>false</c>.</returns>
16+
bool IsMatch(string path);
17+
18+
/// <summary>
19+
/// Transforms the given path to its equivalent in the target specification version.
20+
/// </summary>
21+
/// <param name="path">The JSON Pointer path to transform.</param>
22+
/// <returns>The transformed path, or <c>null</c> if the path has no equivalent in the target version.</returns>
23+
string? GetVersionedPath(string path);
24+
}

0 commit comments

Comments
 (0)