Skip to content

Commit 64a05d9

Browse files
authored
Fix & improve (#19)
1 parent 52c799e commit 64a05d9

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

features/bootstrap/DocNormalizerContext.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,15 @@ public function whenINormalizeServerDoc()
221221
$shapeNormalizer = new ShapeNormalizer();
222222
$schemaTypeNormalizer = new SchemaTypeNormalizer();
223223
$definitionRefResolver = new DefinitionRefResolver();
224+
$typeDocNormalizer = new TypeDocNormalizer(
225+
$schemaTypeNormalizer
226+
);
224227
$normalizer = new DocNormalizer(
225228
new ExternalSchemaListDocNormalizer(
226229
$definitionRefResolver,
227-
new TypeDocNormalizer(
228-
$schemaTypeNormalizer
229-
),
230+
$typeDocNormalizer,
230231
new ErrorDocNormalizer(
231-
new TypeDocNormalizer(
232-
$schemaTypeNormalizer
233-
),
232+
$typeDocNormalizer,
234233
$shapeNormalizer
235234
),
236235
$shapeNormalizer
@@ -256,7 +255,6 @@ public function whenINormalizeServerDoc()
256255
*/
257256
public function thenIShouldHaveFollowingNormalizedDoc(PyStringNode $data)
258257
{
259-
print_r(json_encode($this->lastNormalizedOutput)."\n");
260258
Assert::assertSame(
261259
$this->jsonDecode($data->getRaw()),
262260
$this->lastNormalizedOutput
@@ -281,8 +279,6 @@ public function thenNormalizedDefinitionNamedShouldBeTheFollowing($definitionNam
281279
{
282280
$this->thenIShouldHaveDefinitionNamed($definitionName);
283281

284-
print_r(json_encode($this->lastNormalizedOutput));
285-
286282
Assert::assertSame(
287283
$this->jsonDecode($data->getRaw()),
288284
$this->lastNormalizedOutput[self::DEFINITIONS_KEY][$definitionName]
@@ -341,7 +337,6 @@ public function thenIShouldHaveTheFollowingTypeDoc(PyStringNode $data, $isRequir
341337
$this->thenIShouldHaveDefinitionNamed(self::DUMMY_ERROR_KEY_FOR_TYPEDOC);
342338
$dummyError = $this->lastNormalizedOutput[self::DEFINITIONS_KEY][self::DUMMY_ERROR_KEY_FOR_TYPEDOC];
343339
$dummyErrorShape = $dummyError['allOf'][1];
344-
var_dump($dummyErrorShape);
345340

346341
if (true === $isRequired) {
347342
Assert::assertContains('data', $dummyErrorShape['required']);
@@ -405,8 +400,6 @@ public function thenIShouldHaveAPathNamedLikeFollowing($httpMethod, $pathName, P
405400
$operation = $this->extractPath($httpMethod, $pathName);
406401
$decodedExpected = $this->jsonDecode($data->getRaw());
407402

408-
print_r(json_encode($operation)."\n");
409-
410403
foreach ($decodedExpected as $expectedKey => $expectedContent) {
411404
Assert::assertArrayHasKey($expectedKey, $operation);
412405
Assert::assertSame($expectedContent, $operation[$expectedKey]);
@@ -424,8 +417,6 @@ public function thenPathNamedShouldHaveTheFollowingParameters($httpMethod, $path
424417
$operationParameters = $operation['parameters'][0]['schema']['allOf'];
425418
$decodedExpected = $this->jsonDecode($data->getRaw());
426419

427-
print_r(json_encode($operation)."\n");
428-
429420
Assert::assertContains($decodedExpected, $operationParameters);
430421
}
431422

@@ -443,8 +434,6 @@ public function thenPathNamedShouldHaveTheFollowingResponse($httpMethod, $pathNa
443434
$operationResponseSchemaList = $operation['responses']['200']['schema']['allOf'];
444435
$decodedExpected = $this->jsonDecode($data->getRaw());
445436

446-
print_r(json_encode($this->lastNormalizedOutput));
447-
448437
Assert::assertContains($decodedExpected, $operationResponseSchemaList);
449438
}
450439

features/method-doc.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ Feature: MethodDocNormalizer
328328
],
329329
"responses": {
330330
"200": {
331-
"description": "JsonRpc response",
331+
"description": "JSON-RPC response",
332332
"schema": {
333333
"allOf": [
334334
{

src/App/Normalizer/Component/OperationDocNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function normalize(MethodDoc $method) : array
6464
],
6565
'responses' => [
6666
'200' => [
67-
'description' => 'JsonRpc response',
67+
'description' => 'JSON-RPC response',
6868
'schema' => $this->responseDocNormalizer->normalize($method),
6969
]
7070
]

tests/Functional/App/Normalizer/Component/OperationDocNormalizerTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22
namespace Tests\Functional\App\Normalizer\Component;
33

44
use PHPUnit\Framework\TestCase;
5-
use Prophecy\Argument;
65
use Prophecy\Prophecy\ObjectProphecy;
76
use Yoanm\JsonRpcHttpServerSwaggerDoc\App\Normalizer\Component\OperationDocNormalizer;
87
use Yoanm\JsonRpcHttpServerSwaggerDoc\App\Normalizer\Component\RequestDocNormalizer;
98
use Yoanm\JsonRpcHttpServerSwaggerDoc\App\Normalizer\Component\ResponseDocNormalizer;
109
use Yoanm\JsonRpcHttpServerSwaggerDoc\App\Resolver\DefinitionRefResolver;
1110
use Yoanm\JsonRpcServerDoc\Domain\Model\ErrorDoc;
1211
use Yoanm\JsonRpcServerDoc\Domain\Model\MethodDoc;
13-
use Yoanm\JsonRpcServerDoc\Domain\Model\Type as TypeDocNs;
1412

1513
/**
1614
* @covers \Yoanm\JsonRpcHttpServerSwaggerDoc\App\Normalizer\Component\OperationDocNormalizer
@@ -89,7 +87,7 @@ public function provideManagedMethodDocList()
8987
],
9088
'responses' => [
9189
'200' => [
92-
'description' => 'JsonRpc response',
90+
'description' => 'JSON-RPC response',
9391
'schema' => self::DEFAULT_RESPONSE_DEFINITION
9492
]
9593
]
@@ -115,7 +113,7 @@ public function provideManagedMethodDocList()
115113
],
116114
'responses' => [
117115
'200' => [
118-
'description' => 'JsonRpc response',
116+
'description' => 'JSON-RPC response',
119117
'schema' => self::DEFAULT_RESPONSE_DEFINITION
120118
]
121119
]
@@ -140,7 +138,7 @@ public function provideManagedMethodDocList()
140138
],
141139
'responses' => [
142140
'200' => [
143-
'description' => 'JsonRpc response',
141+
'description' => 'JSON-RPC response',
144142
'schema' => self::DEFAULT_RESPONSE_DEFINITION
145143
]
146144
]
@@ -168,7 +166,7 @@ public function provideManagedMethodDocList()
168166
],
169167
'responses' => [
170168
'200' => [
171-
'description' => 'JsonRpc response',
169+
'description' => 'JSON-RPC response',
172170
'schema' => self::DEFAULT_RESPONSE_DEFINITION
173171
]
174172
]
@@ -201,7 +199,7 @@ public function provideManagedMethodDocList()
201199
],
202200
'responses' => [
203201
'200' => [
204-
'description' => 'JsonRpc response',
202+
'description' => 'JSON-RPC response',
205203
'schema' => self::DEFAULT_RESPONSE_DEFINITION
206204
]
207205
]

0 commit comments

Comments
 (0)