diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 98d7ff3..ce1cce0 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,24 @@ - + diff --git a/src/Merge/ReferenceNormalizer.php b/src/Merge/ReferenceNormalizer.php index cf8221e..a25f311 100644 --- a/src/Merge/ReferenceNormalizer.php +++ b/src/Merge/ReferenceNormalizer.php @@ -149,16 +149,18 @@ public function normalizeInlineReferences( /** @var array $allSchemas */ $allSchemas = $openApiDefinition->components->responses; + $allContents = $allSchemas[$key]->content; foreach ($response->content as $contentKey => $content) { if (! $content->schema instanceof Schema) { continue; } - $allSchemas[$key]->content[$contentKey]->schema = $this->normalizeProperties( + $allContents[$contentKey]->schema = $this->normalizeProperties( $content->schema, $refFileCollection, ); } + $allSchemas[$key]->content = $allContents; $openApiDefinition->components->responses = $allSchemas; } diff --git a/tests/Merge/Fixtures/expected/openapi-normalized.json b/tests/Merge/Fixtures/expected/openapi-normalized.json index 2fcf606..bf97d1d 100644 --- a/tests/Merge/Fixtures/expected/openapi-normalized.json +++ b/tests/Merge/Fixtures/expected/openapi-normalized.json @@ -158,7 +158,27 @@ "components": { "responses": { "reference-101": { - "description": "OK" + "description": "OK", + "content": { + "text\/json": { + "schema": { + "properties": { + "dummyJSON": { + "$ref": "#\/components\/schemas\/requestBody" + } + } + } + }, + "application\/json": { + "schema": { + "properties": { + "dummyApplicationJSON": { + "$ref": "#\/components\/schemas\/requestBody" + } + } + } + } + } } } } diff --git a/tests/Merge/Fixtures/openapi-with-reference.json b/tests/Merge/Fixtures/openapi-with-reference.json index 25f5a95..a5a1f02 100644 --- a/tests/Merge/Fixtures/openapi-with-reference.json +++ b/tests/Merge/Fixtures/openapi-with-reference.json @@ -161,7 +161,28 @@ "components": { "responses": { "reference-101": { - "description": "OK" + "description": "OK", + "content": { + "text/json": { + "schema": { + "properties": { + "dummyJSON": { + "$ref": "./requestBody.json#/components/schemas/requestBody" + } + } + } + }, + "application/json": { + "schema": { + "properties": { + + "dummyApplicationJSON": { + "$ref": "./requestBody.json#/components/schemas/requestBody" + } + } + } + } + } } } }