Skip to content

Commit

Permalink
Add fail on notices and fix a notice generation
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelthole committed Aug 6, 2024
1 parent 029e754 commit eb83a42
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 4 deletions.
21 changes: 20 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="./tests/bootstrap.php" colors="true" defaultTimeLimit="5" executionOrder="random" enforceTimeLimit="true" cacheDirectory=".phpunit.cache" requireCoverageMetadata="true" beStrictAboutCoverageMetadata="true">
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./tests/bootstrap.php"
colors="true"
defaultTimeLimit="5"
executionOrder="random"
enforceTimeLimit="true"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="true"
beStrictAboutCoverageMetadata="true"
failOnNotice="true"
displayDetailsOnTestsThatTriggerNotices="true"
failOnDeprecation="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
failOnWarning="true"
displayDetailsOnTestsThatTriggerWarnings="true"
beStrictAboutOutputDuringTests="true"
displayDetailsOnTestsThatTriggerErrors="true"
>
<php>
<ini name="assert.exception" value="1"/>
</php>
Expand Down
4 changes: 3 additions & 1 deletion src/Merge/ReferenceNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,18 @@ public function normalizeInlineReferences(

/** @var array<string, Response> $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;
}
Expand Down
22 changes: 21 additions & 1 deletion tests/Merge/Fixtures/expected/openapi-normalized.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
}
}
}
}
Expand Down
23 changes: 22 additions & 1 deletion tests/Merge/Fixtures/openapi-with-reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
}
}
}
}
}
Expand Down

0 comments on commit eb83a42

Please sign in to comment.