Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
composer-deps: lowest
- php-version: "8.0"
composer-deps: latest
- php-version: "8.1"
composer-deps: lowest
- php-version: "8.1"
composer-deps: latest
steps:
- name: "Checkout"
uses: "actions/checkout@v2"
Expand Down
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
}
],
"require": {
"php": "^7.4 || ~8.0.0",
"php": "^7.4 || ~8.0.0 || ~8.1.0",
"cebe/php-openapi": "^1.5.2",
"symfony/console": "^v5.1.9"
"symfony/console": "^5.1.9 || ^6.0"
},
"require-dev": {
"doctrine/coding-standard": "^9.0.0",
Expand Down Expand Up @@ -59,7 +59,11 @@
"infection": "infection --threads=4 --coverage=build/coverage"
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"infection/extension-installer": true
}
},
"bin": [
"bin/openapi-merge"
Expand Down
272 changes: 183 additions & 89 deletions tests/Acceptance/ApplicationAcceptanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
use function implode;
use function shell_exec;
use function sprintf;
use function version_compare;

use const PHP_VERSION;

/**
* @coversNothing
Expand All @@ -28,97 +31,188 @@ public function testApplicationRuns(): void
])
));

self::assertSame(
<<<'EXPECTED_YAML'
openapi: 3.0.2
info:
title: 'Example OpenAPI Definition'
description: 'This is the example Description'
contact:
name: 'Base Author'
url: base.example.org
email: base-file@example.org
license:
name: MIT
url: 'https://tldrlegal.com/license/mit-license'
version: '1.0'
servers:
-
url: 'https://api.base.example.org'
description: 'Main Base URL'
paths:
/ping:
get:
tags:
- 'Base Route'
summary: 'Your GET endpoint'
description: 'Description of Ping'
operationId: get-ping
parameters:
-
name: responseWith
in: query
description: 'response with this message'
schema:
maxLength: 20
minLength: 0
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
required:
- response
type: object
properties:
response:
type: string
'400':
description: 'Bad Request'
content:
application/problem+json:
if (version_compare(PHP_VERSION, '8.1.0', '>=')) {
$expected = <<<'EXPECTED_YAML'
openapi: 3.0.2
info:
title: 'Example OpenAPI Definition'
description: 'This is the example Description'
contact:
name: 'Base Author'
url: base.example.org
email: base-file@example.org
license:
name: MIT
url: 'https://tldrlegal.com/license/mit-license'
version: '1.0'
servers:
-
url: 'https://api.base.example.org'
description: 'Main Base URL'
paths:
/ping:
get:
tags:
- 'Base Route'
summary: 'Your GET endpoint'
description: 'Description of Ping'
operationId: get-ping
parameters:
-
name: responseWith
in: query
description: 'response with this message'
schema:
title: ProblemResponse
required:
- type
- title
type: object
properties:
type:
type: string
description: 'type of the problem'
example: ValidationError
title:
type: string
example: 'Your request parameters didn''t validate.'
description: 'Default Problem Response'
post:
summary: 'Your POST endpoint'
description: 'Description of post Ping'
operationId: post-ping
responses:
'200':
description: OK
content:
application/json:
maxLength: 20
minLength: 0
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
required:
- response
type: object
properties:
response:
type: string
'400':
description: 'Bad Request'
content:
application/problem+json:
schema:
title: ProblemResponse
required:
- type
- title
type: object
properties:
type:
type: string
description: 'type of the problem'
example: ValidationError
title:
type: string
example: "Your request parameters didn't validate."
description: 'Default Problem Response'
post:
summary: 'Your POST endpoint'
description: 'Description of post Ping'
operationId: post-ping
responses:
'200':
description: OK
content:
application/json:
schema:
required:
- response
type: object
properties:
response:
type: string
components:
schemas: { }
security: []
tags:
-
name: Base

EXPECTED_YAML;
} else {
$expected = <<<'EXPECTED_YAML'
openapi: 3.0.2
info:
title: 'Example OpenAPI Definition'
description: 'This is the example Description'
contact:
name: 'Base Author'
url: base.example.org
email: base-file@example.org
license:
name: MIT
url: 'https://tldrlegal.com/license/mit-license'
version: '1.0'
servers:
-
url: 'https://api.base.example.org'
description: 'Main Base URL'
paths:
/ping:
get:
tags:
- 'Base Route'
summary: 'Your GET endpoint'
description: 'Description of Ping'
operationId: get-ping
parameters:
-
name: responseWith
in: query
description: 'response with this message'
schema:
required:
- response
type: object
properties:
response:
type: string
components:
schemas: []
security: []
tags:
-
name: Base
maxLength: 20
minLength: 0
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
required:
- response
type: object
properties:
response:
type: string
'400':
description: 'Bad Request'
content:
application/problem+json:
schema:
title: ProblemResponse
required:
- type
- title
type: object
properties:
type:
type: string
description: 'type of the problem'
example: ValidationError
title:
type: string
example: 'Your request parameters didn''t validate.'
description: 'Default Problem Response'
post:
summary: 'Your POST endpoint'
description: 'Description of post Ping'
operationId: post-ping
responses:
'200':
description: OK
content:
application/json:
schema:
required:
- response
type: object
properties:
response:
type: string
components:
schemas: { }
security: []
tags:
-
name: Base

EXPECTED_YAML;
}

EXPECTED_YAML,
$output
);
self::assertSame($expected, $output);
}
}