Skip to content

Commit ee0b3f1

Browse files
authored
Merge pull request #107 from DoclerLabs/fix-operation-id-with-dashes
fix operation id with dashes
2 parents c526246 + 2481608 commit ee0b3f1

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [10.6.1] - 2024.02.10
8+
### Fixed
9+
- operationId containing dashes is converted to camel case
10+
711
## [10.6.0] - 2024.01.10
812
### Added
913
- Api key authentication strategy added

src/Input/Factory/OperationFactory.php

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function create(
4040
$operationId
4141
);
4242
trigger_error($warningMessage, E_USER_WARNING);
43+
} elseif (str_contains($operationId, '-')) {
44+
$operationId = CaseCaster::toCamel($operationId);
4345
}
4446

4547
$parameters = array_merge($commonParameters, $operation->parameters ?? []);

test/suite/functional/Generator/Client/petstore.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ servers:
88
paths:
99
/pets:
1010
get:
11-
operationId: findPets
11+
operationId: find-pets
1212
parameters:
1313
- name: tags
1414
in: query
@@ -110,6 +110,13 @@ paths:
110110
schema:
111111
type: integer
112112
format: int64
113+
- name: food_id
114+
in: path
115+
description: ID of food to delete
116+
required: true
117+
schema:
118+
type: integer
119+
format: int64
113120
responses:
114121
'204':
115122
description: pet food deleted

test/suite/functional/Input/ParserTest.php

+21
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,27 @@ public function validSpecificationProvider(): array
6868
],
6969
],
7070
],
71+
'operationId with dashes is supported' => [
72+
[
73+
'openapi' => '3.0.0',
74+
'info' => [
75+
'title' => 'Sample API',
76+
'version' => '1.0.0',
77+
],
78+
'paths' => [
79+
'/users' => [
80+
'get' => [
81+
'operationId' => 'get-users',
82+
'responses' => [
83+
'200' => [
84+
'description' => 'OK',
85+
],
86+
],
87+
],
88+
],
89+
],
90+
],
91+
],
7192
];
7293
}
7394

0 commit comments

Comments
 (0)