Skip to content

Commit 347d062

Browse files
committed
Fixing bug where servers would be added and set to an empty string in OpenAPI
1 parent 0de0b75 commit 347d062

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/Swagger/Serializer/DocumentationNormalizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ private function computeDoc(bool $v3, Documentation $documentation, \ArrayObject
698698

699699
if ($v3) {
700700
$docs = ['openapi' => self::OPENAPI_VERSION];
701-
if ('/' !== $baseUrl) {
701+
if ('/' !== $baseUrl && '' !== $baseUrl) {
702702
$docs['servers'] = [['url' => $context[self::BASE_URL] ?? $this->defaultContext[self::BASE_URL]]];
703703
}
704704
} else {

tests/Swagger/Serializer/DocumentationNormalizerV3Test.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,8 @@ public function testNormalize()
350350
];
351351

352352
$this->assertEquals($expected, $normalizer->normalize($documentation, DocumentationNormalizer::FORMAT, ['base_url' => '/app_dev.php/']));
353+
$this->assertArrayNotHasKey('servers', (array) $normalizer->normalize($documentation, DocumentationNormalizer::FORMAT, ['base_url' => '/']));
354+
$this->assertArrayNotHasKey('servers', (array) $normalizer->normalize($documentation, DocumentationNormalizer::FORMAT, ['base_url' => '']));
353355
}
354356

355357
public function testNormalizeWithNameConverter()

0 commit comments

Comments
 (0)