File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed
src/Microsoft.OpenApi/Validations/Rules Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT license.
33
4+ using System ;
45using System . Collections . Generic ;
56using System . Text . RegularExpressions ;
67using Microsoft . OpenApi . Models ;
@@ -35,21 +36,21 @@ public static class OpenApiPathsRules
3536 }
3637 } ) ;
3738
39+ private static readonly Regex regexPath = new Regex ( "\\ {([^/]+)\\ }" , RegexOptions . Compiled , TimeSpan . FromMilliseconds ( 100 ) ) ;
3840 /// <summary>
3941 /// A relative path to an individual endpoint. The field name MUST begin with a slash.
4042 /// </summary>
4143 public static ValidationRule < OpenApiPaths > PathMustBeUnique =>
4244 new ValidationRule < OpenApiPaths > (
4345 ( context , item ) =>
4446 {
45- const string regexPath = "\\ {([^/]+)\\ }" ;
4647 var hashSet = new HashSet < string > ( ) ;
4748
4849 foreach ( var path in item . Keys )
4950 {
5051 context . Enter ( path ) ;
5152
52- var pathSignature = Regex . Replace ( path , regexPath , "{}" ) ;
53+ var pathSignature = regexPath . Replace ( path , "{}" ) ;
5354
5455 if ( ! hashSet . Add ( pathSignature ) )
5556 context . CreateError ( nameof ( PathMustBeUnique ) ,
You can’t perform that action at this time.
0 commit comments