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 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', + ], + ], + ], + ], + ], + ], + ], ]; }