Skip to content

Commit f046f5c

Browse files
committed
1.40.0
1 parent 714e65c commit f046f5c

File tree

3 files changed

+55
-23
lines changed

3 files changed

+55
-23
lines changed

swagger_parser/CHANGELOG.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
## 1.40.0
22
- Add `include_paths` option for filtering endpoints by paths
3-
4-
## 1.39.2
53
- Add `generate_urls_constants` option for generating URL constants for all endpoints
64

75
## 1.39.1

swagger_parser/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: swagger_parser
22
description: Package that generates REST clients and data classes from OpenApi definition file
3-
version: 1.39.2
4-
repository: https://github.com/Carapacik/swagger_parser/tree/main/swagger_parser
3+
version: 1.40.0
4+
repository: https://github.com/Carapacik/swagger_parser
55
topics:
66
- swagger
77
- openapi

swagger_parser/test/src/parser/utils/path_match_test.dart

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,54 @@ void main() {
55
group('matchesPathPattern', () {
66
test('exact match without wildcards', () {
77
expect(matchesPathPattern('/api/users', ['/api/users']), isTrue);
8-
expect(matchesPathPattern('/api/users/profile', ['/api/users/profile']), isTrue);
9-
expect(matchesPathPattern('/exact/path/{id}', ['/exact/path/{id}']), isTrue);
8+
expect(matchesPathPattern('/api/users/profile', ['/api/users/profile']),
9+
isTrue);
10+
expect(
11+
matchesPathPattern('/exact/path/{id}', ['/exact/path/{id}']), isTrue);
1012
});
1113

1214
test('no match for different paths', () {
1315
expect(matchesPathPattern('/api/users', ['/api/posts']), isFalse);
14-
expect(matchesPathPattern('/api/users/profile', ['/api/users/settings']), isFalse);
16+
expect(matchesPathPattern('/api/users/profile', ['/api/users/settings']),
17+
isFalse);
1518
});
1619

1720
test('single asterisk wildcard (*)', () {
1821
// Basic single segment match
19-
expect(matchesPathPattern('/users/123/update', ['/users/*/update']), isTrue);
22+
expect(
23+
matchesPathPattern('/users/123/update', ['/users/*/update']), isTrue);
2024
expect(matchesPathPattern('/api/v1/users', ['/api/*/users']), isTrue);
2125

2226
// No match when path has more segments
23-
expect(matchesPathPattern('/users/123/profile/update', ['/users/*/update']), isFalse);
24-
expect(matchesPathPattern('/api/v1/extra/users', ['/api/*/users']), isFalse);
27+
expect(
28+
matchesPathPattern('/users/123/profile/update', ['/users/*/update']),
29+
isFalse);
30+
expect(
31+
matchesPathPattern('/api/v1/extra/users', ['/api/*/users']), isFalse);
2532

2633
// Match at different positions
2734
expect(matchesPathPattern('/users/123', ['/users/*']), isTrue);
28-
expect(matchesPathPattern('/api/123/endpoint', ['/api/*/endpoint']), isTrue);
35+
expect(
36+
matchesPathPattern('/api/123/endpoint', ['/api/*/endpoint']), isTrue);
2937
});
3038

3139
test('double asterisk wildcard (**) - long path', () {
32-
expect(matchesPathPattern('/api/service/loyalty/balance/history', ['/api/service/loyalty/**']), isTrue);
40+
expect(
41+
matchesPathPattern('/api/service/loyalty/balance/history',
42+
['/api/service/loyalty/**']),
43+
isTrue);
3344
});
3445

3546
test('double asterisk wildcard (**) - another', () {
36-
expect(matchesPathPattern('/another/wildcard/long/path', ['/another/wildcard/**']), isTrue);
47+
expect(
48+
matchesPathPattern(
49+
'/another/wildcard/long/path', ['/another/wildcard/**']),
50+
isTrue);
3751
});
3852

3953
test('double asterisk wildcard (**) - parts', () {
40-
expect(matchesPathPattern('path/with/several/parts', ['path/**/parts']), isTrue);
54+
expect(matchesPathPattern('path/with/several/parts', ['path/**/parts']),
55+
isTrue);
4156
});
4257

4358
test('double asterisk wildcard (**) - single', () {
@@ -53,9 +68,17 @@ void main() {
5368
});
5469

5570
test('multiple patterns', () {
56-
expect(matchesPathPattern('/users/123/update', ['/posts/*/create', '/users/*/update']), isTrue);
57-
expect(matchesPathPattern('/api/v1/users', ['/api/v2/users', '/api/v1/*']), isTrue);
58-
expect(matchesPathPattern('/api/service/loyalty/balance', ['/api/*/loyalty', '/api/service/**']), isTrue);
71+
expect(
72+
matchesPathPattern(
73+
'/users/123/update', ['/posts/*/create', '/users/*/update']),
74+
isTrue);
75+
expect(
76+
matchesPathPattern('/api/v1/users', ['/api/v2/users', '/api/v1/*']),
77+
isTrue);
78+
expect(
79+
matchesPathPattern('/api/service/loyalty/balance',
80+
['/api/*/loyalty', '/api/service/**']),
81+
isTrue);
5982
});
6083

6184
test('special regex characters in paths', () {
@@ -76,7 +99,8 @@ void main() {
7699

77100
// Empty path
78101
expect(matchesPathPattern('', ['']), isTrue);
79-
expect(matchesPathPattern('', ['*']), isFalse); // * requires at least one non-slash char
102+
expect(matchesPathPattern('', ['*']),
103+
isFalse); // * requires at least one non-slash char
80104
expect(matchesPathPattern('', ['**']), isTrue);
81105

82106
// Root path
@@ -86,22 +110,32 @@ void main() {
86110

87111
test('complex patterns', () {
88112
// Mixed wildcards
89-
expect(matchesPathPattern('/api/v1/users/123/posts/456/comments', ['/api/*/users/*/posts/**']), isTrue);
90-
expect(matchesPathPattern('/users/123/profile/settings/advanced', ['/users/*/profile/**']), isTrue);
113+
expect(
114+
matchesPathPattern('/api/v1/users/123/posts/456/comments',
115+
['/api/*/users/*/posts/**']),
116+
isTrue);
117+
expect(
118+
matchesPathPattern(
119+
'/users/123/profile/settings/advanced', ['/users/*/profile/**']),
120+
isTrue);
91121

92122
// Wildcard at start (matches one segment)
93123
expect(matchesPathPattern('/dynamic/endpoint', ['*/endpoint']), isTrue);
94-
expect(matchesPathPattern('/some/deep/path/endpoint', ['**/endpoint']), isTrue);
124+
expect(matchesPathPattern('/some/deep/path/endpoint', ['**/endpoint']),
125+
isTrue);
95126
});
96127

97128
test('no match cases', () {
98129
// Different structure
99-
expect(matchesPathPattern('/users/123/update', ['/posts/*/create']), isFalse);
130+
expect(matchesPathPattern('/users/123/update', ['/posts/*/create']),
131+
isFalse);
100132
expect(matchesPathPattern('/api/v1/users', ['/api/v2/*']), isFalse);
101133

102134
// Too many segments for single *
103135
expect(matchesPathPattern('/api/deep/nested/path', ['/api/*']), isFalse);
104-
expect(matchesPathPattern('/users/123/profile/update', ['/users/*/update']), isFalse);
136+
expect(
137+
matchesPathPattern('/users/123/profile/update', ['/users/*/update']),
138+
isFalse);
105139

106140
// Insufficient segments for **
107141
expect(matchesPathPattern('/api', ['/api/**/endpoint']), isFalse);

0 commit comments

Comments
 (0)