|
14 | 14 | use Membrane\OpenAPIReader\Factory\V30\FromCebe; |
15 | 15 | use Membrane\OpenAPIReader\MembraneReader; |
16 | 16 | use Membrane\OpenAPIReader\Tests\Fixtures\Helper\OpenAPIProvider; |
17 | | -use Membrane\OpenAPIReader\Tests\Fixtures\Helper\PartialHelper; |
18 | 17 | use Membrane\OpenAPIReader\ValueObject\Partial; |
19 | 18 | use Membrane\OpenAPIReader\ValueObject\Valid; |
20 | 19 | use Membrane\OpenAPIReader\ValueObject\Valid\Enum\Method; |
@@ -271,8 +270,10 @@ public function itResolvesExternalReferencesFromAbsoluteFilePath( |
271 | 270 |
|
272 | 271 | #[Test] |
273 | 272 | #[DataProvider('provideOpenAPIWithExternalReference')] |
274 | | - public function itCannotResolveExternalReferenceFromString(string $openAPIString): void |
275 | | - { |
| 273 | + public function itCannotResolveExternalReferenceFromString( |
| 274 | + string $openAPIString, |
| 275 | + string $_, |
| 276 | + ): void { |
276 | 277 | self::expectExceptionObject(CannotRead::cannotResolveExternalReferencesFromString()); |
277 | 278 |
|
278 | 279 | (new MembraneReader([OpenAPIVersion::Version_3_0])) |
@@ -373,6 +374,62 @@ public function itReadsRealExamples( |
373 | 374 | self::assertEquals($expected, $actual); |
374 | 375 | } |
375 | 376 |
|
| 377 | + #[Test] |
| 378 | + public function itReadsStringNumericKeysAsStrings(): void |
| 379 | + { |
| 380 | + $sut = new MembraneReader([ |
| 381 | + OpenAPIVersion::Version_3_0, |
| 382 | + OpenAPIVersion::Version_3_1, |
| 383 | + ]); |
| 384 | + |
| 385 | + $api = json_encode([ |
| 386 | + 'openapi' => '3.0.3', |
| 387 | + 'info' => [ |
| 388 | + 'title' => 'Numeric Property Keys', |
| 389 | + 'version' => '1.0.0', |
| 390 | + ], |
| 391 | + 'paths' => ['/foo' => ['parameters' => [[ |
| 392 | + 'name' => 'object-with-numeric-keys', |
| 393 | + 'in' => 'query', |
| 394 | + 'schema' => [ |
| 395 | + 'type' => 'object', |
| 396 | + 'properties' => [ |
| 397 | + '1' => ['type' => 'string'], |
| 398 | + ] |
| 399 | + ] |
| 400 | + ]]]] |
| 401 | + ]); |
| 402 | + |
| 403 | + $expected = OpenAPI::fromPartial(new Partial\OpenAPI( |
| 404 | + openAPI: '3.0.3', |
| 405 | + title: 'Numeric Property Keys', |
| 406 | + version: '1.0.0', |
| 407 | + paths: [ |
| 408 | + new Partial\PathItem( |
| 409 | + path: '/foo', |
| 410 | + parameters: [ |
| 411 | + new Partial\Parameter( |
| 412 | + name: 'object-with-numeric-keys', |
| 413 | + in: 'query', |
| 414 | + schema: new Partial\Schema( |
| 415 | + type: 'object', |
| 416 | + properties: [ |
| 417 | + '1' => new Partial\Schema(type: 'string'), |
| 418 | + ], |
| 419 | + ) |
| 420 | + ), |
| 421 | + ] |
| 422 | + ) |
| 423 | + ] |
| 424 | + )); |
| 425 | + |
| 426 | + $actual = $sut->readFromString($api, FileFormat::Json); |
| 427 | + |
| 428 | + |
| 429 | + |
| 430 | + self::assertEquals($expected, $actual); |
| 431 | + } |
| 432 | + |
376 | 433 | public static function provideInvalidFormatting(): Generator |
377 | 434 | { |
378 | 435 | yield 'Empty string to be interpreted as json' => ['', FileFormat::Json]; |
|
0 commit comments