Skip to content

Commit 2e89e6a

Browse files
committed
Fix issue in Github action 2 - related to different symfony/yaml version
1 parent 61fe216 commit 2e89e6a

File tree

4 files changed

+282
-3
lines changed

4 files changed

+282
-3
lines changed
File renamed without changes.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
openapi: 3.0.0
2+
info:
3+
title: 'Test REST API'
4+
description: 'Specifications for the Test REST API.'
5+
contact:
6+
name: bplainia
7+
8+
version: '2021-05-18'
9+
servers:
10+
-
11+
url: 'http://localhost:8000'
12+
description: Test
13+
paths:
14+
'/v1/organizations/{organizationId}/user':
15+
post:
16+
tags:
17+
- pets
18+
summary: 'Creates a user'
19+
requestBody:
20+
content:
21+
application/json:
22+
schema:
23+
type: object
24+
properties:
25+
data:
26+
type: object
27+
properties:
28+
id:
29+
type: string
30+
format: uuid
31+
name:
32+
type: string
33+
required: true
34+
responses:
35+
'201':
36+
description: Created
37+
content:
38+
application/json:
39+
schema:
40+
type: object
41+
properties:
42+
data:
43+
type: object
44+
properties:
45+
id:
46+
type: string
47+
format: uuid
48+
name:
49+
type: string
50+
'400':
51+
description: 'Bad Request'
52+
'403':
53+
description: Forbidden
54+
security:
55+
-
56+
BearerAuth: []
57+
parameters:
58+
-
59+
name: api-version
60+
in: header
61+
description: 'The API version'
62+
required: false
63+
schema:
64+
type: string
65+
format: date
66+
example: '2021-05-18'
67+
-
68+
name: organizationId
69+
in: path
70+
description: 'The Organization ID'
71+
required: true
72+
schema:
73+
type: string
74+
format: uuid
75+
'/v1/organizations/{organizationId}/user/{id}':
76+
get:
77+
summary: 'Gets a user'
78+
responses:
79+
'200':
80+
description: 'A bar'
81+
content:
82+
application/json:
83+
schema:
84+
type: object
85+
properties:
86+
data:
87+
type: object
88+
properties:
89+
id:
90+
type: string
91+
format: uuid
92+
name:
93+
type: string
94+
'400':
95+
description: 'Bad Request'
96+
'403':
97+
description: Forbidden
98+
'404':
99+
description: 'Not Found'
100+
security:
101+
-
102+
BearerAuth: []
103+
parameters:
104+
-
105+
name: api-version
106+
in: header
107+
description: 'The API version'
108+
required: false
109+
schema:
110+
type: string
111+
format: date
112+
example: '2021-05-18'
113+
-
114+
name: organizationId
115+
in: path
116+
description: 'The Organization ID'
117+
required: true
118+
schema:
119+
type: string
120+
format: uuid
121+
-
122+
name: id
123+
in: path
124+
description: 'User''s ID'
125+
required: true
126+
schema:
127+
type: string
128+
format: uuid
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
openapi: 3.0.0
2+
info:
3+
title: 'Test REST API'
4+
description: 'Specifications for the Test REST API.'
5+
contact:
6+
name: bplainia
7+
8+
version: '2021-05-18'
9+
servers:
10+
-
11+
url: 'http://localhost:8000'
12+
description: Test
13+
paths:
14+
'/v1/organizations/{organizationId}/user':
15+
post:
16+
tags:
17+
- pets
18+
summary: 'Creates a user'
19+
requestBody:
20+
content:
21+
application/json:
22+
schema:
23+
type: object
24+
properties:
25+
data:
26+
type: object
27+
properties:
28+
id:
29+
type: string
30+
format: uuid
31+
name:
32+
type: string
33+
required: true
34+
responses:
35+
'201':
36+
description: Created
37+
content:
38+
application/json:
39+
schema:
40+
type: object
41+
properties:
42+
data:
43+
type: object
44+
properties:
45+
id:
46+
type: string
47+
format: uuid
48+
name:
49+
type: string
50+
'400':
51+
description: 'Bad Request'
52+
'403':
53+
description: Forbidden
54+
security:
55+
-
56+
BearerAuth: []
57+
parameters:
58+
-
59+
name: api-version
60+
in: header
61+
description: 'The API version'
62+
required: false
63+
schema:
64+
type: string
65+
format: date
66+
example: '2021-05-18'
67+
-
68+
name: organizationId
69+
in: path
70+
description: 'The Organization ID'
71+
required: true
72+
schema:
73+
type: string
74+
format: uuid
75+
'/v1/organizations/{organizationId}/user/{id}':
76+
get:
77+
summary: 'Gets a user'
78+
responses:
79+
'200':
80+
description: 'A bar'
81+
content:
82+
application/json:
83+
schema:
84+
type: object
85+
properties:
86+
data:
87+
type: object
88+
properties:
89+
id:
90+
type: string
91+
format: uuid
92+
name:
93+
type: string
94+
'400':
95+
description: 'Bad Request'
96+
'403':
97+
description: Forbidden
98+
'404':
99+
description: 'Not Found'
100+
security:
101+
-
102+
BearerAuth: []
103+
parameters:
104+
-
105+
name: api-version
106+
in: header
107+
description: 'The API version'
108+
required: false
109+
schema:
110+
type: string
111+
format: date
112+
example: '2021-05-18'
113+
-
114+
name: organizationId
115+
in: path
116+
description: 'The Organization ID'
117+
required: true
118+
schema:
119+
type: string
120+
format: uuid
121+
-
122+
name: id
123+
in: path
124+
description: 'User''s ID'
125+
required: true
126+
schema:
127+
type: string
128+
format: uuid

tests/spec/PathTest.php

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,30 @@ public function testPathParametersAreArrays()
223223
$this->assertEquals('id', $userIdPath->parameters[2]->name);
224224
$dirSep = DIRECTORY_SEPARATOR;
225225
shell_exec(dirname(__DIR__, 2) . "{$dirSep}bin{$dirSep}php-openapi inline " . $file . ' ' . dirname(__DIR__) . $dirSep.'/compiled.yml');
226-
$this->assertFileEquals(dirname(__DIR__) . $dirSep.'compiled.yml', dirname(__DIR__) . "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled.yml");
227-
unlink(dirname(__DIR__) . $dirSep.'compiled.yml');
228-
}
226+
227+
$expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-7.yml";
228+
229+
if (static::majorSymfonyYamlVersion() == 6) {
230+
$expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml";
231+
} elseif (static::majorSymfonyYamlVersion() == 7) {
232+
$expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml";
233+
}
234+
235+
$this->assertFileEquals(dirname(__DIR__) . $dirSep.'compiled.yml', dirname(__DIR__) . $expected);
236+
unlink(dirname(__DIR__) . '/compiled.yml');
237+
}
238+
239+
public static function majorSymfonyYamlVersion()
240+
{
241+
$package = 'symfony/yaml';
242+
$installed = json_decode(file_get_contents(__DIR__ . '/../../composer.lock'), true);
243+
244+
foreach ($installed['packages'] as $pkg) {
245+
if ($pkg['name'] === $package) {
246+
$version = explode('.', $pkg['version'])[0];
247+
return str_replace('v', '', $version);
248+
}
249+
}
250+
return 7;
251+
}
229252
}

0 commit comments

Comments
 (0)