From c843243488dd31e32100444161e6b2e2321c5325 Mon Sep 17 00:00:00 2001 From: Arinzechukwu Date: Wed, 13 Sep 2023 15:50:58 +0100 Subject: [PATCH 01/32] Added test to confirm referenced parameters are compiling to arrays --- tests/spec/PathTest.php | 31 ++++++++++ tests/spec/data/path-params/global.yaml | 28 +++++++++ tests/spec/data/path-params/openapi.yaml | 18 ++++++ tests/spec/data/path-params/user.yaml | 76 ++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 tests/spec/data/path-params/global.yaml create mode 100644 tests/spec/data/path-params/openapi.yaml create mode 100644 tests/spec/data/path-params/user.yaml diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 6c46e4b0..e5be1bfd 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -192,4 +192,35 @@ public function testPathItemReference() $this->assertEquals('A bar', $barPath->get->responses['200']->description); $this->assertEquals('non-existing resource', $barPath->get->responses['404']->description); } + + public function testPathParametersAreArrays() + { + $file = __DIR__ . '/data/path-params/openapi.yaml'; + /** @var $openapi \cebe\openapi\spec\OpenApi */ + $openapi = Reader::readFromYamlFile($file, \cebe\openapi\spec\OpenApi::class, true); + + $result = $openapi->validate(); + $this->assertEquals([], $openapi->getErrors(), print_r($openapi->getErrors(), true)); + $this->assertTrue($result); + + $this->assertInstanceOf(Paths::class, $openapi->paths); + $this->assertIsArray($openapi->paths->getPaths()); + $this->assertInstanceOf(PathItem::class, $usersPath = $openapi->paths['/v1/{organizationId}/user']); + $this->assertInstanceOf(PathItem::class, $userIdPath = $openapi->paths['/v1/{organizationId}/user/{id}']); + + $result = $usersPath->validate(); + $this->assertTrue($result); + $this->assertIsArray($usersPath->parameters); + $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $usersPath->parameters[0]); + $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $usersPath->parameters[1]); + $this->assertEquals($usersPath->parameters[0]->name, 'api-version'); + + $result = $userIdPath->validate(); + $this->assertTrue($result); + $this->assertIsArray($userIdPath->parameters); + $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[0]); + $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[1]); + $this->assertEquals($userIdPath->parameters[2]->name, 'id'); + + } } diff --git a/tests/spec/data/path-params/global.yaml b/tests/spec/data/path-params/global.yaml new file mode 100644 index 00000000..38348ee4 --- /dev/null +++ b/tests/spec/data/path-params/global.yaml @@ -0,0 +1,28 @@ +components: + parameters: + Version: + in: header + name: api-version + required: false + schema: + type: string + format: date + example: '2021-05-18' + description: The API version + OrganizationId: + in: path + name: organizationId + required: true + schema: + type: string + format: uuid + description: The Organization ID + responses: + BadRequest: + description: Bad Request + Forbidden: + description: Forbidden + NotFound: + description: Not Found + Success: + description: Success \ No newline at end of file diff --git a/tests/spec/data/path-params/openapi.yaml b/tests/spec/data/path-params/openapi.yaml new file mode 100644 index 00000000..722d8184 --- /dev/null +++ b/tests/spec/data/path-params/openapi.yaml @@ -0,0 +1,18 @@ +openapi: 3.0.0 +info: + version: "2021-05-18" + title: Test REST API + description: Specifications for the Test REST API. + contact: + name: bplainia + email: bplainia@lhespotlight.org + +servers: + - url: 'http://localhost:8000' + description: 'Test' + +paths: + /v1/{organizationId}/user: + $ref: 'user.yaml#/paths/Users' + /v1/{organizationId}/user/{id}: + $ref: 'user.yaml#/paths/UserId' \ No newline at end of file diff --git a/tests/spec/data/path-params/user.yaml b/tests/spec/data/path-params/user.yaml new file mode 100644 index 00000000..a842e783 --- /dev/null +++ b/tests/spec/data/path-params/user.yaml @@ -0,0 +1,76 @@ +paths: + Users: + parameters: + - $ref: 'global.yaml#/components/parameters/Version' + - $ref: 'global.yaml#/components/parameters/OrganizationId' + post: + summary: Creates a user + security: + - BearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/User' + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/User' + '400': + $ref: 'global.yaml#/components/responses/BadRequest' + '403': + $ref: 'global.yaml#/components/responses/Forbidden' + UserId: + parameters: + - $ref: 'global.yaml#/components/parameters/Version' + - $ref: 'global.yaml#/components/parameters/OrganizationId' + - $ref: '#/components/parameters/UserId' + get: + summary: Gets a user + security: + - BearerAuth: [] + responses: + '200': + description: A bar + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/User' + '400': + $ref: 'global.yaml#/components/responses/BadRequest' + '403': + $ref: 'global.yaml#/components/responses/Forbidden' + '404': + $ref: 'global.yaml#/components/responses/NotFound' +components: + schemas: + User: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + parameters: + UserId: + in: path + name: id + required: true + schema: + type: string + format: uuid + description: User's ID \ No newline at end of file From 9acecc87c5d671c0c4dba8c0a201a22c2096e2c9 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Fri, 25 Apr 2025 18:15:53 +0530 Subject: [PATCH 02/32] Failing test --- compiled.yml | 124 +++++++++++++++++++++++ tests/spec/PathTest.php | 6 +- tests/spec/data/path-params/openapi.yaml | 6 +- tests/spec/data/path-params/user.yaml | 3 +- 4 files changed, 132 insertions(+), 7 deletions(-) create mode 100644 compiled.yml diff --git a/compiled.yml b/compiled.yml new file mode 100644 index 00000000..d544b3c3 --- /dev/null +++ b/compiled.yml @@ -0,0 +1,124 @@ +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: hi there + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: id + in: path + description: 'User''s ID' + required: true + schema: + type: string + format: uuid diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index e5be1bfd..1ce585ae 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -205,8 +205,8 @@ public function testPathParametersAreArrays() $this->assertInstanceOf(Paths::class, $openapi->paths); $this->assertIsArray($openapi->paths->getPaths()); - $this->assertInstanceOf(PathItem::class, $usersPath = $openapi->paths['/v1/{organizationId}/user']); - $this->assertInstanceOf(PathItem::class, $userIdPath = $openapi->paths['/v1/{organizationId}/user/{id}']); + $this->assertInstanceOf(PathItem::class, $usersPath = $openapi->paths['/v1/organizations/{organizationId}/user']); + $this->assertInstanceOf(PathItem::class, $userIdPath = $openapi->paths['/v1/organizations/{organizationId}/user/{id}']); $result = $usersPath->validate(); $this->assertTrue($result); @@ -220,7 +220,7 @@ public function testPathParametersAreArrays() $this->assertIsArray($userIdPath->parameters); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[0]); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[1]); - $this->assertEquals($userIdPath->parameters[2]->name, 'id'); + $this->assertEquals($userIdPath->parameters[2]->name, 'id'); } } diff --git a/tests/spec/data/path-params/openapi.yaml b/tests/spec/data/path-params/openapi.yaml index 722d8184..9decce27 100644 --- a/tests/spec/data/path-params/openapi.yaml +++ b/tests/spec/data/path-params/openapi.yaml @@ -11,8 +11,8 @@ servers: - url: 'http://localhost:8000' description: 'Test' -paths: - /v1/{organizationId}/user: +paths: + /v1/organizations/{organizationId}/user: $ref: 'user.yaml#/paths/Users' - /v1/{organizationId}/user/{id}: + /v1/organizations/{organizationId}/user/{id}: $ref: 'user.yaml#/paths/UserId' \ No newline at end of file diff --git a/tests/spec/data/path-params/user.yaml b/tests/spec/data/path-params/user.yaml index a842e783..23857811 100644 --- a/tests/spec/data/path-params/user.yaml +++ b/tests/spec/data/path-params/user.yaml @@ -1,3 +1,4 @@ + paths: Users: parameters: @@ -73,4 +74,4 @@ components: schema: type: string format: uuid - description: User's ID \ No newline at end of file + description: User's ID From 3ab78b6b4a8ba79d79b241b620e454a6a1019b47 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 26 Apr 2025 09:44:25 +0530 Subject: [PATCH 03/32] Original compiled file --- compiled.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/compiled.yml b/compiled.yml index d544b3c3..380bd8a5 100644 --- a/compiled.yml +++ b/compiled.yml @@ -53,14 +53,16 @@ paths: - BearerAuth: [] parameters: - - name: organizationId + '1': + name: organizationId in: path description: 'The Organization ID' required: true schema: type: string format: uuid - - name: api-version + '0': + name: api-version in: header description: 'The API version' required: false @@ -73,7 +75,7 @@ paths: summary: 'Gets a user' responses: '200': - description: hi there + description: 'A bar' content: application/json: schema: @@ -97,7 +99,7 @@ paths: - BearerAuth: [] parameters: - - + '1': name: organizationId in: path description: 'The Organization ID' @@ -105,7 +107,7 @@ paths: schema: type: string format: uuid - - + '0': name: api-version in: header description: 'The API version' @@ -114,7 +116,7 @@ paths: type: string format: date example: '2021-05-18' - - + '2': name: id in: path description: 'User''s ID' From a946647b976e639690d8737679db63b3f06fa114 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Tue, 29 Apr 2025 12:38:29 +0530 Subject: [PATCH 04/32] Fix typo --- bin/php-openapi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/php-openapi b/bin/php-openapi index ae2ffdc8..aa4b0697 100755 --- a/bin/php-openapi +++ b/bin/php-openapi @@ -215,7 +215,7 @@ switch ($command) { if ($outputFile === null) { if ($outputFormat === null) { - error("No output fromat specified, please specify --write-json or --write-yaml.", "usage"); + error("No output format specified, please specify --write-json or --write-yaml.", "usage"); } elseif ($outputFormat === 'json') { fwrite(STDOUT, \cebe\openapi\Writer::writeToJson($openApi)); } else { From aaff77168508b3d41ef2df307da089e1ffcc9470 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 07:47:17 +0530 Subject: [PATCH 05/32] Fix this issue --- compiled.yml | 40 ++++++++++++++------------- src/SpecBaseObject.php | 4 +++ tests/spec/data/path-params/user.yaml | 2 ++ 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/compiled.yml b/compiled.yml index 380bd8a5..e1774005 100644 --- a/compiled.yml +++ b/compiled.yml @@ -13,6 +13,8 @@ servers: paths: '/v1/organizations/{organizationId}/user': post: + tags: + - pets summary: 'Creates a user' requestBody: content: @@ -53,15 +55,7 @@ paths: - BearerAuth: [] parameters: - '1': - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '0': + - name: api-version in: header description: 'The API version' @@ -70,6 +64,14 @@ paths: type: string format: date example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid '/v1/organizations/{organizationId}/user/{id}': get: summary: 'Gets a user' @@ -99,15 +101,7 @@ paths: - BearerAuth: [] parameters: - '1': - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '0': + - name: api-version in: header description: 'The API version' @@ -116,7 +110,15 @@ paths: type: string format: date example: '2021-05-18' - '2': + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - name: id in: path description: 'User''s ID' diff --git a/src/SpecBaseObject.php b/src/SpecBaseObject.php index ef93401e..a1008ce9 100644 --- a/src/SpecBaseObject.php +++ b/src/SpecBaseObject.php @@ -210,6 +210,10 @@ public function getSerializableData() // case 2: Attribute type is an object (specified in attributes() by an array which specifies two items (key and value type) $toObject = true; } + if ($k === 'parameters') { + ksort($data[$k]); + $toObject = false; + } if ($toObject) { $data[$k] = (object) $data[$k]; } diff --git a/tests/spec/data/path-params/user.yaml b/tests/spec/data/path-params/user.yaml index 23857811..6f1402bd 100644 --- a/tests/spec/data/path-params/user.yaml +++ b/tests/spec/data/path-params/user.yaml @@ -6,6 +6,8 @@ paths: - $ref: 'global.yaml#/components/parameters/OrganizationId' post: summary: Creates a user + tags: + - pets security: - BearerAuth: [] requestBody: From e02cce13728aa8a9d764b069d0e94374cc554e75 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 08:18:45 +0530 Subject: [PATCH 06/32] Fix this issue in more proper way --- src/SpecBaseObject.php | 4 ---- src/spec/PathItem.php | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/SpecBaseObject.php b/src/SpecBaseObject.php index a1008ce9..ef93401e 100644 --- a/src/SpecBaseObject.php +++ b/src/SpecBaseObject.php @@ -210,10 +210,6 @@ public function getSerializableData() // case 2: Attribute type is an object (specified in attributes() by an array which specifies two items (key and value type) $toObject = true; } - if ($k === 'parameters') { - ksort($data[$k]); - $toObject = false; - } if ($toObject) { $data[$k] = (object) $data[$k]; } diff --git a/src/spec/PathItem.php b/src/spec/PathItem.php index 4b2debcd..6930e0af 100644 --- a/src/spec/PathItem.php +++ b/src/spec/PathItem.php @@ -180,7 +180,7 @@ public function resolveReferences(ReferenceContext $context = null) foreach ($this->$attribute as $k => $item) { if ($item instanceof Reference) { $referencedObject = $item->resolve(); - $this->$attribute = [$k => $referencedObject] + $this->$attribute; + $this->$attribute = $this->$attribute + [$k => $referencedObject]; if (!$referencedObject instanceof Reference && $referencedObject !== null) { $referencedObject->resolveReferences(); } From e8b8b2e627df63ec338f46c400eb819ec6f31017 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 08:28:27 +0530 Subject: [PATCH 07/32] Fix failing test --- tests/spec/PathTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 1ce585ae..d4b54ed1 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -204,7 +204,7 @@ public function testPathParametersAreArrays() $this->assertTrue($result); $this->assertInstanceOf(Paths::class, $openapi->paths); - $this->assertIsArray($openapi->paths->getPaths()); + $this->assertSame(gettype($openapi->paths->getPaths()), 'array'); $this->assertInstanceOf(PathItem::class, $usersPath = $openapi->paths['/v1/organizations/{organizationId}/user']); $this->assertInstanceOf(PathItem::class, $userIdPath = $openapi->paths['/v1/organizations/{organizationId}/user/{id}']); @@ -213,14 +213,14 @@ public function testPathParametersAreArrays() $this->assertIsArray($usersPath->parameters); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $usersPath->parameters[0]); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $usersPath->parameters[1]); - $this->assertEquals($usersPath->parameters[0]->name, 'api-version'); + $this->assertEquals('api-version', $usersPath->parameters[0]->name); $result = $userIdPath->validate(); $this->assertTrue($result); $this->assertIsArray($userIdPath->parameters); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[0]); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[1]); - $this->assertEquals($userIdPath->parameters[2]->name, 'id'); + $this->assertEquals('id', $userIdPath->parameters[2]->name); } } From 9dfa3e80322376bddd133da9eb7c71923fb8bde3 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 08:34:44 +0530 Subject: [PATCH 08/32] Fix failing test 2 --- tests/spec/PathTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index d4b54ed1..83b7aab5 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -210,14 +210,14 @@ public function testPathParametersAreArrays() $result = $usersPath->validate(); $this->assertTrue($result); - $this->assertIsArray($usersPath->parameters); + $this->assertSame(gettype($usersPath->parameters), 'array'); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $usersPath->parameters[0]); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $usersPath->parameters[1]); $this->assertEquals('api-version', $usersPath->parameters[0]->name); $result = $userIdPath->validate(); $this->assertTrue($result); - $this->assertIsArray($userIdPath->parameters); + $this->assertSame(gettype($userIdPath->parameters), 'array'); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[0]); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[1]); $this->assertEquals('id', $userIdPath->parameters[2]->name); From f0a27b743b4a47dd5c127bb0e016af5bbdd03837 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 09:03:59 +0530 Subject: [PATCH 09/32] Add more assertions --- compiled.yml => tests/data/issue/155/compiled.yml | 0 tests/spec/PathTest.php | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) rename compiled.yml => tests/data/issue/155/compiled.yml (100%) diff --git a/compiled.yml b/tests/data/issue/155/compiled.yml similarity index 100% rename from compiled.yml rename to tests/data/issue/155/compiled.yml diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 83b7aab5..522ff924 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -221,6 +221,7 @@ public function testPathParametersAreArrays() $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[0]); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[1]); $this->assertEquals('id', $userIdPath->parameters[2]->name); - + shell_exec(dirname(__DIR__, 2) . '/bin/php-openapi inline ' . $file . ' ' . dirname(__DIR__) . '/tmp/compiled.yml'); + $this->assertFileEquals(dirname(__DIR__) . '/tmp/compiled.yml', dirname(__DIR__) . '/data/issue/155/compiled.yml'); } } From 02b63bdb3d0251aafdae0e6f5126a8b28b1b8fbc Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 14:02:45 +0530 Subject: [PATCH 10/32] Fix issue in Github action --- tests/spec/PathTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 522ff924..8fbc6fcc 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -221,7 +221,8 @@ public function testPathParametersAreArrays() $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[0]); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[1]); $this->assertEquals('id', $userIdPath->parameters[2]->name); - shell_exec(dirname(__DIR__, 2) . '/bin/php-openapi inline ' . $file . ' ' . dirname(__DIR__) . '/tmp/compiled.yml'); - $this->assertFileEquals(dirname(__DIR__) . '/tmp/compiled.yml', dirname(__DIR__) . '/data/issue/155/compiled.yml'); + shell_exec(dirname(__DIR__, 2) . '/bin/php-openapi inline ' . $file . ' ' . dirname(__DIR__) . '/compiled.yml'); + $this->assertFileEquals(dirname(__DIR__) . '/compiled.yml', dirname(__DIR__) . '/data/issue/155/compiled.yml'); + unlink(dirname(__DIR__) . '/compiled.yml'); } } From 61fe21687ebbc080002ee36da3a91eb88b343ecc Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 14:14:38 +0530 Subject: [PATCH 11/32] Fix issue in Github action for Windows --- tests/spec/PathTest.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 8fbc6fcc..ad9a24c7 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -221,8 +221,9 @@ public function testPathParametersAreArrays() $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[0]); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[1]); $this->assertEquals('id', $userIdPath->parameters[2]->name); - shell_exec(dirname(__DIR__, 2) . '/bin/php-openapi inline ' . $file . ' ' . dirname(__DIR__) . '/compiled.yml'); - $this->assertFileEquals(dirname(__DIR__) . '/compiled.yml', dirname(__DIR__) . '/data/issue/155/compiled.yml'); - unlink(dirname(__DIR__) . '/compiled.yml'); + $dirSep = DIRECTORY_SEPARATOR; + shell_exec(dirname(__DIR__, 2) . "{$dirSep}bin{$dirSep}php-openapi inline " . $file . ' ' . dirname(__DIR__) . $dirSep.'/compiled.yml'); + $this->assertFileEquals(dirname(__DIR__) . $dirSep.'compiled.yml', dirname(__DIR__) . "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled.yml"); + unlink(dirname(__DIR__) . $dirSep.'compiled.yml'); } } From 2e89e6add318c3acfd4d8abda4d562d88e766fee Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 15:23:09 +0530 Subject: [PATCH 12/32] Fix issue in Github action 2 - related to different symfony/yaml version --- .../{compiled.yml => compiled-symfony-5.yml} | 0 tests/data/issue/155/compiled-symfony-6.yml | 128 ++++++++++++++++++ tests/data/issue/155/compiled-symfony-7.yml | 128 ++++++++++++++++++ tests/spec/PathTest.php | 29 +++- 4 files changed, 282 insertions(+), 3 deletions(-) rename tests/data/issue/155/{compiled.yml => compiled-symfony-5.yml} (100%) create mode 100644 tests/data/issue/155/compiled-symfony-6.yml create mode 100644 tests/data/issue/155/compiled-symfony-7.yml diff --git a/tests/data/issue/155/compiled.yml b/tests/data/issue/155/compiled-symfony-5.yml similarity index 100% rename from tests/data/issue/155/compiled.yml rename to tests/data/issue/155/compiled-symfony-5.yml diff --git a/tests/data/issue/155/compiled-symfony-6.yml b/tests/data/issue/155/compiled-symfony-6.yml new file mode 100644 index 00000000..e1774005 --- /dev/null +++ b/tests/data/issue/155/compiled-symfony-6.yml @@ -0,0 +1,128 @@ +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + tags: + - pets + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: 'A bar' + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: id + in: path + description: 'User''s ID' + required: true + schema: + type: string + format: uuid diff --git a/tests/data/issue/155/compiled-symfony-7.yml b/tests/data/issue/155/compiled-symfony-7.yml new file mode 100644 index 00000000..e1774005 --- /dev/null +++ b/tests/data/issue/155/compiled-symfony-7.yml @@ -0,0 +1,128 @@ +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + tags: + - pets + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: 'A bar' + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: id + in: path + description: 'User''s ID' + required: true + schema: + type: string + format: uuid diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index ad9a24c7..9d3e2e6d 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -223,7 +223,30 @@ public function testPathParametersAreArrays() $this->assertEquals('id', $userIdPath->parameters[2]->name); $dirSep = DIRECTORY_SEPARATOR; shell_exec(dirname(__DIR__, 2) . "{$dirSep}bin{$dirSep}php-openapi inline " . $file . ' ' . dirname(__DIR__) . $dirSep.'/compiled.yml'); - $this->assertFileEquals(dirname(__DIR__) . $dirSep.'compiled.yml', dirname(__DIR__) . "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled.yml"); - unlink(dirname(__DIR__) . $dirSep.'compiled.yml'); - } + + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-7.yml"; + + if (static::majorSymfonyYamlVersion() == 6) { + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml"; + } elseif (static::majorSymfonyYamlVersion() == 7) { + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml"; + } + + $this->assertFileEquals(dirname(__DIR__) . $dirSep.'compiled.yml', dirname(__DIR__) . $expected); + unlink(dirname(__DIR__) . '/compiled.yml'); + } + + public static function majorSymfonyYamlVersion() + { + $package = 'symfony/yaml'; + $installed = json_decode(file_get_contents(__DIR__ . '/../../composer.lock'), true); + + foreach ($installed['packages'] as $pkg) { + if ($pkg['name'] === $package) { + $version = explode('.', $pkg['version'])[0]; + return str_replace('v', '', $version); + } + } + return 7; + } } From e04fc8371b2f1c37f13ae1e6383b27cee2af0502 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 15:26:30 +0530 Subject: [PATCH 13/32] Fix issue in Github action 3 - related to different symfony/yaml version --- tests/spec/PathTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 9d3e2e6d..4a3f4cb8 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -228,8 +228,8 @@ public function testPathParametersAreArrays() if (static::majorSymfonyYamlVersion() == 6) { $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml"; - } elseif (static::majorSymfonyYamlVersion() == 7) { - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml"; + } elseif (static::majorSymfonyYamlVersion() == 5) { + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-5.yml"; } $this->assertFileEquals(dirname(__DIR__) . $dirSep.'compiled.yml', dirname(__DIR__) . $expected); From b12c74660a7232a91b002f85fe6766912d785d5a Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 15:31:39 +0530 Subject: [PATCH 14/32] Fix issue in Github action 4 - related to different symfony/yaml version --- tests/data/issue/155/compiled-symfony-6.yml | 2 +- tests/data/issue/155/compiled-symfony-7.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/data/issue/155/compiled-symfony-6.yml b/tests/data/issue/155/compiled-symfony-6.yml index e1774005..e7a45025 100644 --- a/tests/data/issue/155/compiled-symfony-6.yml +++ b/tests/data/issue/155/compiled-symfony-6.yml @@ -121,7 +121,7 @@ paths: - name: id in: path - description: 'User''s ID' + description: "User's ID" required: true schema: type: string diff --git a/tests/data/issue/155/compiled-symfony-7.yml b/tests/data/issue/155/compiled-symfony-7.yml index e1774005..e7a45025 100644 --- a/tests/data/issue/155/compiled-symfony-7.yml +++ b/tests/data/issue/155/compiled-symfony-7.yml @@ -121,7 +121,7 @@ paths: - name: id in: path - description: 'User''s ID' + description: "User's ID" required: true schema: type: string From db60bff10aec8e16d711fa2348cc7c67427714bf Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 15:35:23 +0530 Subject: [PATCH 15/32] Fix issue in Github action 5 - related to different symfony/yaml version --- tests/data/issue/155/compiled-symfony-6.yml | 2 +- tests/spec/PathTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/data/issue/155/compiled-symfony-6.yml b/tests/data/issue/155/compiled-symfony-6.yml index e7a45025..e1774005 100644 --- a/tests/data/issue/155/compiled-symfony-6.yml +++ b/tests/data/issue/155/compiled-symfony-6.yml @@ -121,7 +121,7 @@ paths: - name: id in: path - description: "User's ID" + description: 'User''s ID' required: true schema: type: string diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 4a3f4cb8..d79fcca3 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -232,7 +232,7 @@ public function testPathParametersAreArrays() $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-5.yml"; } - $this->assertFileEquals(dirname(__DIR__) . $dirSep.'compiled.yml', dirname(__DIR__) . $expected); + $this->assertFileEquals(dirname(__DIR__) . $expected, dirname(__DIR__) . $dirSep.'compiled.yml'); unlink(dirname(__DIR__) . '/compiled.yml'); } From 7f34a3bc6112fc40019f2c169b56a76302faed76 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Wed, 30 Apr 2025 15:39:17 +0530 Subject: [PATCH 16/32] Fix issue in Github action 6 - related to different symfony/yaml version --- tests/data/issue/155/compiled-symfony-6.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/issue/155/compiled-symfony-6.yml b/tests/data/issue/155/compiled-symfony-6.yml index e1774005..e7a45025 100644 --- a/tests/data/issue/155/compiled-symfony-6.yml +++ b/tests/data/issue/155/compiled-symfony-6.yml @@ -121,7 +121,7 @@ paths: - name: id in: path - description: 'User''s ID' + description: "User's ID" required: true schema: type: string From e05cbd03d92f66204c7d96b88f3d9cdf702483e6 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Fri, 2 May 2025 16:38:10 +0530 Subject: [PATCH 17/32] Fix issue in Github action 7 - related to different symfony/yaml version --- tests/data/issue/155/compiled-symfony-6.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/issue/155/compiled-symfony-6.yml b/tests/data/issue/155/compiled-symfony-6.yml index e7a45025..e1774005 100644 --- a/tests/data/issue/155/compiled-symfony-6.yml +++ b/tests/data/issue/155/compiled-symfony-6.yml @@ -121,7 +121,7 @@ paths: - name: id in: path - description: "User's ID" + description: 'User''s ID' required: true schema: type: string From 9811689cb5d43d650dbf406d8cedba7476a983f5 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Fri, 2 May 2025 16:46:13 +0530 Subject: [PATCH 18/32] Fix issue in Github action 8 - related to different symfony/yaml version --- tests/spec/PathTest.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index d79fcca3..d0d18fb6 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -228,6 +228,9 @@ public function testPathParametersAreArrays() if (static::majorSymfonyYamlVersion() == 6) { $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml"; + if (version_compare(PHP_VERSION, '8.1', '>=')) { + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-7.yml"; + } } elseif (static::majorSymfonyYamlVersion() == 5) { $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-5.yml"; } From 7e721bf037e25fa644644853ac82085049cf001a Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Fri, 2 May 2025 17:40:55 +0530 Subject: [PATCH 19/32] Fix issue in Github action 9 - related to different symfony/yaml version --- tests/spec/PathTest.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index d0d18fb6..92f9082f 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -225,13 +225,15 @@ public function testPathParametersAreArrays() shell_exec(dirname(__DIR__, 2) . "{$dirSep}bin{$dirSep}php-openapi inline " . $file . ' ' . dirname(__DIR__) . $dirSep.'/compiled.yml'); $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-7.yml"; + $version = static::symfonyYamlVersion(); + $majorVersion = explode('.', $version)[0]; - if (static::majorSymfonyYamlVersion() == 6) { + if ($majorVersion == 6) { $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml"; - if (version_compare(PHP_VERSION, '8.1', '>=')) { + if (version_compare(PHP_VERSION, '8.1', '>=') && version_compare($version, '6.0.0', '!=')) { $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-7.yml"; } - } elseif (static::majorSymfonyYamlVersion() == 5) { + } elseif ($majorVersion == 5) { $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-5.yml"; } @@ -239,17 +241,16 @@ public function testPathParametersAreArrays() unlink(dirname(__DIR__) . '/compiled.yml'); } - public static function majorSymfonyYamlVersion() + public static function symfonyYamlVersion() { $package = 'symfony/yaml'; $installed = json_decode(file_get_contents(__DIR__ . '/../../composer.lock'), true); foreach ($installed['packages'] as $pkg) { if ($pkg['name'] === $package) { - $version = explode('.', $pkg['version'])[0]; - return str_replace('v', '', $version); + return str_replace('v', '', $pkg['version']); } } - return 7; + return '7.0.0'; } } From 241c469e5f61aa6bcd37f74268b62f15ac01c277 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Fri, 2 May 2025 17:51:05 +0530 Subject: [PATCH 20/32] Fix test on Windows --- tests/spec/PathTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 92f9082f..1b5e3845 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -222,7 +222,7 @@ public function testPathParametersAreArrays() $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[1]); $this->assertEquals('id', $userIdPath->parameters[2]->name); $dirSep = DIRECTORY_SEPARATOR; - shell_exec(dirname(__DIR__, 2) . "{$dirSep}bin{$dirSep}php-openapi inline " . $file . ' ' . dirname(__DIR__) . $dirSep.'/compiled.yml'); + shell_exec('php '.dirname(__DIR__, 2) . "{$dirSep}bin{$dirSep}php-openapi inline " . $file . ' ' . dirname(__DIR__) . $dirSep.'/compiled.yml'); $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-7.yml"; $version = static::symfonyYamlVersion(); From 1e379ae61b9f1bc59bfcb6818d80e403bca43c51 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 07:24:03 +0530 Subject: [PATCH 21/32] Fix test on Windows 2 --- ....yml => compiled-symfony-6-windows-lf.yml} | 256 +++++++++--------- tests/spec/PathTest.php | 5 +- 2 files changed, 132 insertions(+), 129 deletions(-) rename tests/data/issue/155/{compiled-symfony-5.yml => compiled-symfony-6-windows-lf.yml} (96%) diff --git a/tests/data/issue/155/compiled-symfony-5.yml b/tests/data/issue/155/compiled-symfony-6-windows-lf.yml similarity index 96% rename from tests/data/issue/155/compiled-symfony-5.yml rename to tests/data/issue/155/compiled-symfony-6-windows-lf.yml index e1774005..70aa7317 100644 --- a/tests/data/issue/155/compiled-symfony-5.yml +++ b/tests/data/issue/155/compiled-symfony-6-windows-lf.yml @@ -1,128 +1,128 @@ -openapi: 3.0.0 -info: - title: 'Test REST API' - description: 'Specifications for the Test REST API.' - contact: - name: bplainia - email: bplainia@lhespotlight.org - version: '2021-05-18' -servers: - - - url: 'http://localhost:8000' - description: Test -paths: - '/v1/organizations/{organizationId}/user': - post: - tags: - - pets - summary: 'Creates a user' - requestBody: - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - required: true - responses: - '201': - description: Created - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '/v1/organizations/{organizationId}/user/{id}': - get: - summary: 'Gets a user' - responses: - '200': - description: 'A bar' - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - '404': - description: 'Not Found' - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - - - name: id - in: path - description: 'User''s ID' - required: true - schema: - type: string - format: uuid +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + tags: + - pets + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: 'A bar' + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: id + in: path + description: 'User''s ID' + required: true + schema: + type: string + format: uuid diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 1b5e3845..9d2b0727 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -234,7 +234,10 @@ public function testPathParametersAreArrays() $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-7.yml"; } } elseif ($majorVersion == 5) { - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-5.yml"; + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml"; + } + if (stripos(PHP_OS, 'WIN') === 0) { + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6-windows-lf.yml"; } $this->assertFileEquals(dirname(__DIR__) . $expected, dirname(__DIR__) . $dirSep.'compiled.yml'); From 5bebb98868fecc52ab9cf717585aef9ad5d85ced Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 07:48:27 +0530 Subject: [PATCH 22/32] Fix test related to line ending --- .../155/compiled-symfony-6-windows-lf.yml | 256 +++++++++--------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/tests/data/issue/155/compiled-symfony-6-windows-lf.yml b/tests/data/issue/155/compiled-symfony-6-windows-lf.yml index 70aa7317..e1774005 100644 --- a/tests/data/issue/155/compiled-symfony-6-windows-lf.yml +++ b/tests/data/issue/155/compiled-symfony-6-windows-lf.yml @@ -1,128 +1,128 @@ -openapi: 3.0.0 -info: - title: 'Test REST API' - description: 'Specifications for the Test REST API.' - contact: - name: bplainia - email: bplainia@lhespotlight.org - version: '2021-05-18' -servers: - - - url: 'http://localhost:8000' - description: Test -paths: - '/v1/organizations/{organizationId}/user': - post: - tags: - - pets - summary: 'Creates a user' - requestBody: - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - required: true - responses: - '201': - description: Created - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '/v1/organizations/{organizationId}/user/{id}': - get: - summary: 'Gets a user' - responses: - '200': - description: 'A bar' - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - '404': - description: 'Not Found' - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - - - name: id - in: path - description: 'User''s ID' - required: true - schema: - type: string - format: uuid +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + tags: + - pets + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: 'A bar' + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: id + in: path + description: 'User''s ID' + required: true + schema: + type: string + format: uuid From 1da45e96b1dc19400c3b209c8a18d78234b019c4 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 08:17:50 +0530 Subject: [PATCH 23/32] Fix test related to line ending 2 --- tests/spec/PathTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 9d2b0727..3587e699 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -236,9 +236,9 @@ public function testPathParametersAreArrays() } elseif ($majorVersion == 5) { $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml"; } - if (stripos(PHP_OS, 'WIN') === 0) { - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6-windows-lf.yml"; - } +// if (stripos(PHP_OS, 'WIN') === 0) { +//// $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6-windows-lf.yml"; +// } $this->assertFileEquals(dirname(__DIR__) . $expected, dirname(__DIR__) . $dirSep.'compiled.yml'); unlink(dirname(__DIR__) . '/compiled.yml'); From c7a965ff93bdc5833a13e056489ebabd6de3e701 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 08:27:59 +0530 Subject: [PATCH 24/32] Fix test related to line ending 3 --- .../155/compiled-symfony-6-windows-lf.yml | 256 +++++++++--------- tests/data/issue/155/compiled-symfony-6.yml | 256 +++++++++--------- tests/data/issue/155/compiled-symfony-7.yml | 256 +++++++++--------- 3 files changed, 384 insertions(+), 384 deletions(-) diff --git a/tests/data/issue/155/compiled-symfony-6-windows-lf.yml b/tests/data/issue/155/compiled-symfony-6-windows-lf.yml index e1774005..70aa7317 100644 --- a/tests/data/issue/155/compiled-symfony-6-windows-lf.yml +++ b/tests/data/issue/155/compiled-symfony-6-windows-lf.yml @@ -1,128 +1,128 @@ -openapi: 3.0.0 -info: - title: 'Test REST API' - description: 'Specifications for the Test REST API.' - contact: - name: bplainia - email: bplainia@lhespotlight.org - version: '2021-05-18' -servers: - - - url: 'http://localhost:8000' - description: Test -paths: - '/v1/organizations/{organizationId}/user': - post: - tags: - - pets - summary: 'Creates a user' - requestBody: - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - required: true - responses: - '201': - description: Created - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '/v1/organizations/{organizationId}/user/{id}': - get: - summary: 'Gets a user' - responses: - '200': - description: 'A bar' - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - '404': - description: 'Not Found' - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - - - name: id - in: path - description: 'User''s ID' - required: true - schema: - type: string - format: uuid +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + tags: + - pets + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: 'A bar' + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: id + in: path + description: 'User''s ID' + required: true + schema: + type: string + format: uuid diff --git a/tests/data/issue/155/compiled-symfony-6.yml b/tests/data/issue/155/compiled-symfony-6.yml index e1774005..70aa7317 100644 --- a/tests/data/issue/155/compiled-symfony-6.yml +++ b/tests/data/issue/155/compiled-symfony-6.yml @@ -1,128 +1,128 @@ -openapi: 3.0.0 -info: - title: 'Test REST API' - description: 'Specifications for the Test REST API.' - contact: - name: bplainia - email: bplainia@lhespotlight.org - version: '2021-05-18' -servers: - - - url: 'http://localhost:8000' - description: Test -paths: - '/v1/organizations/{organizationId}/user': - post: - tags: - - pets - summary: 'Creates a user' - requestBody: - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - required: true - responses: - '201': - description: Created - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '/v1/organizations/{organizationId}/user/{id}': - get: - summary: 'Gets a user' - responses: - '200': - description: 'A bar' - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - '404': - description: 'Not Found' - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - - - name: id - in: path - description: 'User''s ID' - required: true - schema: - type: string - format: uuid +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + tags: + - pets + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: 'A bar' + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: id + in: path + description: 'User''s ID' + required: true + schema: + type: string + format: uuid diff --git a/tests/data/issue/155/compiled-symfony-7.yml b/tests/data/issue/155/compiled-symfony-7.yml index e7a45025..1f4921b0 100644 --- a/tests/data/issue/155/compiled-symfony-7.yml +++ b/tests/data/issue/155/compiled-symfony-7.yml @@ -1,128 +1,128 @@ -openapi: 3.0.0 -info: - title: 'Test REST API' - description: 'Specifications for the Test REST API.' - contact: - name: bplainia - email: bplainia@lhespotlight.org - version: '2021-05-18' -servers: - - - url: 'http://localhost:8000' - description: Test -paths: - '/v1/organizations/{organizationId}/user': - post: - tags: - - pets - summary: 'Creates a user' - requestBody: - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - required: true - responses: - '201': - description: Created - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '/v1/organizations/{organizationId}/user/{id}': - get: - summary: 'Gets a user' - responses: - '200': - description: 'A bar' - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - '404': - description: 'Not Found' - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - - - name: id - in: path - description: "User's ID" - required: true - schema: - type: string - format: uuid +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + tags: + - pets + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: 'A bar' + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: id + in: path + description: "User's ID" + required: true + schema: + type: string + format: uuid From 6947e2480fc5cb1fb1c7e2ee9c066bf0da9032ed Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 08:33:27 +0530 Subject: [PATCH 25/32] Revert "Fix test related to line ending 3" This reverts commit c7a965ff93bdc5833a13e056489ebabd6de3e701. --- .../155/compiled-symfony-6-windows-lf.yml | 256 +++++++++--------- tests/data/issue/155/compiled-symfony-6.yml | 256 +++++++++--------- tests/data/issue/155/compiled-symfony-7.yml | 256 +++++++++--------- 3 files changed, 384 insertions(+), 384 deletions(-) diff --git a/tests/data/issue/155/compiled-symfony-6-windows-lf.yml b/tests/data/issue/155/compiled-symfony-6-windows-lf.yml index 70aa7317..e1774005 100644 --- a/tests/data/issue/155/compiled-symfony-6-windows-lf.yml +++ b/tests/data/issue/155/compiled-symfony-6-windows-lf.yml @@ -1,128 +1,128 @@ -openapi: 3.0.0 -info: - title: 'Test REST API' - description: 'Specifications for the Test REST API.' - contact: - name: bplainia - email: bplainia@lhespotlight.org - version: '2021-05-18' -servers: - - - url: 'http://localhost:8000' - description: Test -paths: - '/v1/organizations/{organizationId}/user': - post: - tags: - - pets - summary: 'Creates a user' - requestBody: - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - required: true - responses: - '201': - description: Created - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '/v1/organizations/{organizationId}/user/{id}': - get: - summary: 'Gets a user' - responses: - '200': - description: 'A bar' - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - '404': - description: 'Not Found' - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - - - name: id - in: path - description: 'User''s ID' - required: true - schema: - type: string - format: uuid +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + tags: + - pets + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: 'A bar' + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: id + in: path + description: 'User''s ID' + required: true + schema: + type: string + format: uuid diff --git a/tests/data/issue/155/compiled-symfony-6.yml b/tests/data/issue/155/compiled-symfony-6.yml index 70aa7317..e1774005 100644 --- a/tests/data/issue/155/compiled-symfony-6.yml +++ b/tests/data/issue/155/compiled-symfony-6.yml @@ -1,128 +1,128 @@ -openapi: 3.0.0 -info: - title: 'Test REST API' - description: 'Specifications for the Test REST API.' - contact: - name: bplainia - email: bplainia@lhespotlight.org - version: '2021-05-18' -servers: - - - url: 'http://localhost:8000' - description: Test -paths: - '/v1/organizations/{organizationId}/user': - post: - tags: - - pets - summary: 'Creates a user' - requestBody: - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - required: true - responses: - '201': - description: Created - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '/v1/organizations/{organizationId}/user/{id}': - get: - summary: 'Gets a user' - responses: - '200': - description: 'A bar' - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - '404': - description: 'Not Found' - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - - - name: id - in: path - description: 'User''s ID' - required: true - schema: - type: string - format: uuid +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + tags: + - pets + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: 'A bar' + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: id + in: path + description: 'User''s ID' + required: true + schema: + type: string + format: uuid diff --git a/tests/data/issue/155/compiled-symfony-7.yml b/tests/data/issue/155/compiled-symfony-7.yml index 1f4921b0..e7a45025 100644 --- a/tests/data/issue/155/compiled-symfony-7.yml +++ b/tests/data/issue/155/compiled-symfony-7.yml @@ -1,128 +1,128 @@ -openapi: 3.0.0 -info: - title: 'Test REST API' - description: 'Specifications for the Test REST API.' - contact: - name: bplainia - email: bplainia@lhespotlight.org - version: '2021-05-18' -servers: - - - url: 'http://localhost:8000' - description: Test -paths: - '/v1/organizations/{organizationId}/user': - post: - tags: - - pets - summary: 'Creates a user' - requestBody: - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - required: true - responses: - '201': - description: Created - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '/v1/organizations/{organizationId}/user/{id}': - get: - summary: 'Gets a user' - responses: - '200': - description: 'A bar' - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - '404': - description: 'Not Found' - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - - - name: id - in: path - description: "User's ID" - required: true - schema: - type: string - format: uuid +openapi: 3.0.0 +info: + title: 'Test REST API' + description: 'Specifications for the Test REST API.' + contact: + name: bplainia + email: bplainia@lhespotlight.org + version: '2021-05-18' +servers: + - + url: 'http://localhost:8000' + description: Test +paths: + '/v1/organizations/{organizationId}/user': + post: + tags: + - pets + summary: 'Creates a user' + requestBody: + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + required: true + responses: + '201': + description: Created + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + '/v1/organizations/{organizationId}/user/{id}': + get: + summary: 'Gets a user' + responses: + '200': + description: 'A bar' + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + id: + type: string + format: uuid + name: + type: string + '400': + description: 'Bad Request' + '403': + description: Forbidden + '404': + description: 'Not Found' + security: + - + BearerAuth: [] + parameters: + - + name: api-version + in: header + description: 'The API version' + required: false + schema: + type: string + format: date + example: '2021-05-18' + - + name: organizationId + in: path + description: 'The Organization ID' + required: true + schema: + type: string + format: uuid + - + name: id + in: path + description: "User's ID" + required: true + schema: + type: string + format: uuid From 20016f2234fee4cdc0fe1b8d766a4eeddfb766ef Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 09:26:09 +0530 Subject: [PATCH 26/32] Check --- tests/spec/PathTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 3587e699..d0a71c4e 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -240,7 +240,7 @@ public function testPathParametersAreArrays() //// $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6-windows-lf.yml"; // } - $this->assertFileEquals(dirname(__DIR__) . $expected, dirname(__DIR__) . $dirSep.'compiled.yml'); + $this->assertFileEquals(dirname(__DIR__) . $dirSep.'compiled.yml', dirname(__DIR__) . $expected); unlink(dirname(__DIR__) . '/compiled.yml'); } From f4628b09d89df4b7bbd8ae927f28374af2903781 Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 13:29:41 +0530 Subject: [PATCH 27/32] Fix line ending issue in Windows - 4 --- tests/spec/PathTest.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index d0a71c4e..e853c8d8 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -222,26 +222,29 @@ public function testPathParametersAreArrays() $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[1]); $this->assertEquals('id', $userIdPath->parameters[2]->name); $dirSep = DIRECTORY_SEPARATOR; - shell_exec('php '.dirname(__DIR__, 2) . "{$dirSep}bin{$dirSep}php-openapi inline " . $file . ' ' . dirname(__DIR__) . $dirSep.'/compiled.yml'); + $output = dirname(__DIR__) . $dirSep . 'compiled.yml'; + shell_exec('php ' . dirname(__DIR__, 2) . "{$dirSep}bin{$dirSep}php-openapi inline " . $file . ' ' . $output); - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-7.yml"; + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-7.yml"; $version = static::symfonyYamlVersion(); $majorVersion = explode('.', $version)[0]; if ($majorVersion == 6) { - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml"; + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-6.yml"; if (version_compare(PHP_VERSION, '8.1', '>=') && version_compare($version, '6.0.0', '!=')) { - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-7.yml"; + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-7.yml"; } } elseif ($majorVersion == 5) { - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6.yml"; + $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-6.yml"; + } + if (stripos(PHP_OS, 'WIN') === 0) { +// $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-6-windows-lf.yml"; + ; + file_put_contents($output, preg_replace('~\R~', "\n", file_get_contents($output))); } -// if (stripos(PHP_OS, 'WIN') === 0) { -//// $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155/compiled-symfony-6-windows-lf.yml"; -// } - $this->assertFileEquals(dirname(__DIR__) . $dirSep.'compiled.yml', dirname(__DIR__) . $expected); - unlink(dirname(__DIR__) . '/compiled.yml'); + $this->assertFileEquals($output, dirname(__DIR__) . $expected); + unlink($output); } public static function symfonyYamlVersion() From 8a41d7431b287af2f6ed18e5483aae44342bd56f Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 13:58:42 +0530 Subject: [PATCH 28/32] Fix line ending issue in Windows - 5 --- tests/spec/PathTest.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index e853c8d8..5882f5c4 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -225,25 +225,28 @@ public function testPathParametersAreArrays() $output = dirname(__DIR__) . $dirSep . 'compiled.yml'; shell_exec('php ' . dirname(__DIR__, 2) . "{$dirSep}bin{$dirSep}php-openapi inline " . $file . ' ' . $output); - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-7.yml"; + $baseExpected = dirname(__DIR__)."{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}"; + $expected = $baseExpected.'compiled-symfony-7.yml'; $version = static::symfonyYamlVersion(); $majorVersion = explode('.', $version)[0]; if ($majorVersion == 6) { - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-6.yml"; + $expected = $baseExpected."compiled-symfony-6.yml"; if (version_compare(PHP_VERSION, '8.1', '>=') && version_compare($version, '6.0.0', '!=')) { - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-7.yml"; + $expected = $baseExpected."compiled-symfony-7.yml"; } } elseif ($majorVersion == 5) { - $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-6.yml"; + $expected = $baseExpected."compiled-symfony-6.yml"; } if (stripos(PHP_OS, 'WIN') === 0) { + // $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-6-windows-lf.yml"; ; file_put_contents($output, preg_replace('~\R~', "\n", file_get_contents($output))); + file_put_contents($expected, preg_replace('~\R~', "\n", file_get_contents($expected))); } - $this->assertFileEquals($output, dirname(__DIR__) . $expected); + $this->assertFileEquals($output, $expected); unlink($output); } From ebeffc6de32ff9bede72fbc042e401ff7ed2146c Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 14:07:21 +0530 Subject: [PATCH 29/32] Cleanup --- tests/spec/PathTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 5882f5c4..cb831144 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -221,6 +221,7 @@ public function testPathParametersAreArrays() $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[0]); $this->assertInstanceOf(\cebe\openapi\spec\Parameter::class, $userIdPath->parameters[1]); $this->assertEquals('id', $userIdPath->parameters[2]->name); + $dirSep = DIRECTORY_SEPARATOR; $output = dirname(__DIR__) . $dirSep . 'compiled.yml'; shell_exec('php ' . dirname(__DIR__, 2) . "{$dirSep}bin{$dirSep}php-openapi inline " . $file . ' ' . $output); @@ -238,10 +239,7 @@ public function testPathParametersAreArrays() } elseif ($majorVersion == 5) { $expected = $baseExpected."compiled-symfony-6.yml"; } - if (stripos(PHP_OS, 'WIN') === 0) { - -// $expected = "{$dirSep}data{$dirSep}issue{$dirSep}155{$dirSep}compiled-symfony-6-windows-lf.yml"; - ; + if (stripos(PHP_OS, 'WIN') === 0) { # fixes https://github.com/cebe/php-openapi/actions/runs/14808968938/job/41581244210 file_put_contents($output, preg_replace('~\R~', "\n", file_get_contents($output))); file_put_contents($expected, preg_replace('~\R~', "\n", file_get_contents($expected))); } From 50fc31e6a62368cd34f617f7b5f042a82775169d Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 14:14:46 +0530 Subject: [PATCH 30/32] Change visibility --- tests/spec/PathTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index cb831144..196684d6 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -248,7 +248,7 @@ public function testPathParametersAreArrays() unlink($output); } - public static function symfonyYamlVersion() + protected static function symfonyYamlVersion() { $package = 'symfony/yaml'; $installed = json_decode(file_get_contents(__DIR__ . '/../../composer.lock'), true); From a38d47e1c5973978ebab8414ba0b7e0721015c1b Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 14:38:07 +0530 Subject: [PATCH 31/32] Test --- tests/spec/PathTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 196684d6..8d3dc7f8 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -240,7 +240,7 @@ public function testPathParametersAreArrays() $expected = $baseExpected."compiled-symfony-6.yml"; } if (stripos(PHP_OS, 'WIN') === 0) { # fixes https://github.com/cebe/php-openapi/actions/runs/14808968938/job/41581244210 - file_put_contents($output, preg_replace('~\R~', "\n", file_get_contents($output))); +// file_put_contents($output, preg_replace('~\R~', "\n", file_get_contents($output))); file_put_contents($expected, preg_replace('~\R~', "\n", file_get_contents($expected))); } From eeb37f0d96245a2b1dd2c8be1af43a41d43b10ca Mon Sep 17 00:00:00 2001 From: Sohel Ahmed Mesaniya Date: Sat, 3 May 2025 14:49:23 +0530 Subject: [PATCH 32/32] Cleanup --- .../155/compiled-symfony-6-windows-lf.yml | 128 ------------------ tests/spec/PathTest.php | 3 +- 2 files changed, 1 insertion(+), 130 deletions(-) delete mode 100644 tests/data/issue/155/compiled-symfony-6-windows-lf.yml diff --git a/tests/data/issue/155/compiled-symfony-6-windows-lf.yml b/tests/data/issue/155/compiled-symfony-6-windows-lf.yml deleted file mode 100644 index e1774005..00000000 --- a/tests/data/issue/155/compiled-symfony-6-windows-lf.yml +++ /dev/null @@ -1,128 +0,0 @@ -openapi: 3.0.0 -info: - title: 'Test REST API' - description: 'Specifications for the Test REST API.' - contact: - name: bplainia - email: bplainia@lhespotlight.org - version: '2021-05-18' -servers: - - - url: 'http://localhost:8000' - description: Test -paths: - '/v1/organizations/{organizationId}/user': - post: - tags: - - pets - summary: 'Creates a user' - requestBody: - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - required: true - responses: - '201': - description: Created - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - '/v1/organizations/{organizationId}/user/{id}': - get: - summary: 'Gets a user' - responses: - '200': - description: 'A bar' - content: - application/json: - schema: - type: object - properties: - data: - type: object - properties: - id: - type: string - format: uuid - name: - type: string - '400': - description: 'Bad Request' - '403': - description: Forbidden - '404': - description: 'Not Found' - security: - - - BearerAuth: [] - parameters: - - - name: api-version - in: header - description: 'The API version' - required: false - schema: - type: string - format: date - example: '2021-05-18' - - - name: organizationId - in: path - description: 'The Organization ID' - required: true - schema: - type: string - format: uuid - - - name: id - in: path - description: 'User''s ID' - required: true - schema: - type: string - format: uuid diff --git a/tests/spec/PathTest.php b/tests/spec/PathTest.php index 8d3dc7f8..2d47e3e7 100644 --- a/tests/spec/PathTest.php +++ b/tests/spec/PathTest.php @@ -240,8 +240,7 @@ public function testPathParametersAreArrays() $expected = $baseExpected."compiled-symfony-6.yml"; } if (stripos(PHP_OS, 'WIN') === 0) { # fixes https://github.com/cebe/php-openapi/actions/runs/14808968938/job/41581244210 -// file_put_contents($output, preg_replace('~\R~', "\n", file_get_contents($output))); - file_put_contents($expected, preg_replace('~\R~', "\n", file_get_contents($expected))); + file_put_contents($expected, preg_replace('~\R~', "\n", file_get_contents($expected))); # not an ideal solution, can be refactored } $this->assertFileEquals($output, $expected);