From 288ebe985bef5cb07eff65acb0462c75cd204bd7 Mon Sep 17 00:00:00 2001 From: Vitor de Souza Date: Sat, 10 Feb 2024 07:13:56 -0300 Subject: [PATCH 1/2] fix operation id with dashes --- CHANGELOG.md | 4 ++++ src/Input/Factory/OperationFactory.php | 2 ++ test/suite/functional/Generator/Client/petstore.yaml | 9 ++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be7ac12..cbb61e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [10.6.1] - 2024.02.10 +### Fixed +- operationId containing dashes is converted to camel case + ## [10.6.0] - 2024.01.10 ### Added - Api key authentication strategy added diff --git a/src/Input/Factory/OperationFactory.php b/src/Input/Factory/OperationFactory.php index 1b30d3c..dd1c696 100644 --- a/src/Input/Factory/OperationFactory.php +++ b/src/Input/Factory/OperationFactory.php @@ -40,6 +40,8 @@ public function create( $operationId ); trigger_error($warningMessage, E_USER_WARNING); + } elseif (str_contains($operationId, '-')) { + $operationId = CaseCaster::toCamel($operationId); } $parameters = array_merge($commonParameters, $operation->parameters ?? []); diff --git a/test/suite/functional/Generator/Client/petstore.yaml b/test/suite/functional/Generator/Client/petstore.yaml index 7bbaf2b..ef678bc 100644 --- a/test/suite/functional/Generator/Client/petstore.yaml +++ b/test/suite/functional/Generator/Client/petstore.yaml @@ -8,7 +8,7 @@ servers: paths: /pets: get: - operationId: findPets + operationId: find-pets parameters: - name: tags in: query @@ -110,6 +110,13 @@ paths: schema: type: integer format: int64 + - name: food_id + in: path + description: ID of food to delete + required: true + schema: + type: integer + format: int64 responses: '204': description: pet food deleted From 2481608b06449c5223729854c4e0cfb3fd64a792 Mon Sep 17 00:00:00 2001 From: Vitor de Souza Date: Sat, 10 Feb 2024 11:13:54 -0300 Subject: [PATCH 2/2] add explicit test case for operationId with dashes --- test/suite/functional/Input/ParserTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/suite/functional/Input/ParserTest.php b/test/suite/functional/Input/ParserTest.php index f8ee7c9..382cd7d 100644 --- a/test/suite/functional/Input/ParserTest.php +++ b/test/suite/functional/Input/ParserTest.php @@ -68,6 +68,27 @@ public function validSpecificationProvider(): array ], ], ], + 'operationId with dashes is supported' => [ + [ + 'openapi' => '3.0.0', + 'info' => [ + 'title' => 'Sample API', + 'version' => '1.0.0', + ], + 'paths' => [ + '/users' => [ + 'get' => [ + 'operationId' => 'get-users', + 'responses' => [ + '200' => [ + 'description' => 'OK', + ], + ], + ], + ], + ], + ], + ], ]; }