Skip to content

Commit c743a24

Browse files
committed
Flesh out and hook up migration guide for v6
1 parent 38b6391 commit c743a24

5 files changed

Lines changed: 31 additions & 5 deletions

File tree

docs/.vitepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function getGuideSidebar() {
2424
{
2525
text: 'Upgrading',
2626
items: [
27+
{ text: 'Migration from 5.x to 6.x', link: '/guide/migrating-to-v6' },
2728
{ text: 'Migration from 4.x to 5.x', link: '/guide/migrating-to-v5' },
2829
{ text: 'Migration from 3.x to 4.x', link: '/guide/migrating-to-v4' },
2930
{ text: 'Migration from 2.x to 3.x', link: '/guide/migrating-to-v3' },

docs/guide/migrating-to-v6.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,33 @@
22

33
## Overview
44

5-
v6 is mostly a cleanup release with updated dependencies. The main changes are:
5+
`v6` is mostly a cleanup release, with updated dependencies. The main changes are:
66

7-
* Minimum required PHP version is now 8.2
8-
* ...
7+
* The minimum required PHP version is now 8.2
8+
* `radebatz/type-info-extras` is now a required dependency
9+
* `TypeInfoTypeResolver` now properly handles composite types (unions and intersections)
10+
* Some deprecations have been removed (see below)
11+
* The `MediaType::encoding` property now only accepts `Encoding` objects (BC break)
912

1013
For most installations upgrading should not require any changes.
1114

15+
## Type resolvers
16+
With `radebatz/type-info-extras` now being a required dependency, the `TypeInfoTypeResolver` is not the de-facto default
17+
resolver.
18+
19+
The `LegacyTypeResolver` can still be used as a drop-in replacement, but is now marked `deprecated` and will be removed
20+
in v7.
21+
1222
## Removed deprecated elements
13-
### `\Openapi\Generator::getProcessors()` and `\Openapi\Generator::setProcessors()`
23+
### Methods `\Openapi\Generator::getProcessors()` and `\Openapi\Generator::setProcessors()`
1424
Use `getProcessorPipeline()` and `setProcessorPipeline(new Pipeline(...))` methods instead
25+
26+
### Static method `\Openapi\Generator::scan()`
27+
Main entry point into the `Generator` is now the **non-static** `generate()` method:
28+
```php
29+
(new Generator())->generate(/* ... */);
30+
```
31+
32+
### `Utils` helper
33+
Most methods in the class were internal to start with and the `Util::finder()` factory methods is now replaced with
34+
the new `SourceFinder` class.

src/Annotations/AbstractAnnotation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public function jsonSerialize()
366366
if (isset($data->type) && is_array($data->type)) {
367367
if (in_array('null', $data->type)) {
368368
$data->nullable = true;
369-
$data->type = array_filter($data->type, fn ($t): bool => 'null' !== $t);
369+
$data->type = array_filter($data->type, fn ($v): bool => $v !== 'null');
370370
if (1 === count($data->type)) {
371371
$data->type = array_pop($data->type);
372372
}

src/Annotations/MediaType.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
/**
1212
* Each Media Type object provides schema and examples for the media type identified by its key.
1313
*
14+
* Parameter encodings can be set either here, or on nested `Property` annotations directly.
15+
*
1416
* @see [Media Type Object](https://spec.openapis.org/oas/v3.1.1.html#media-type-object)
1517
*
1618
* @Annotation

src/Type/LegacyTypeResolver.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
use OpenApi\Generator;
1313
use OpenApi\TypeResolverInterface;
1414

15+
/**
16+
* @deprecated use `TypeInfoTypeResolver` instead
17+
*/
1518
class LegacyTypeResolver extends AbstractTypeResolver
1619
{
1720
/** @inheritdoc */

0 commit comments

Comments
 (0)