Skip to content

Commit 927cb61

Browse files
authored
Merge pull request #396 from mattpolzin/migration-guide-beginnings
Add a migration guide
2 parents 893c138 + 122cddf commit 927cb61

File tree

2 files changed

+79
-4
lines changed

2 files changed

+79
-4
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![sswg:sandbox|94x20](https://img.shields.io/badge/sswg-sandbox-lightgrey.svg)](https://github.com/swift-server/sswg/blob/master/process/incubation.md#sandbox-level) [![Swift 5.1+](http://img.shields.io/badge/Swift-5.1+-blue.svg)](https://swift.org)
1+
[![sswg:sandbox|94x20](https://img.shields.io/badge/sswg-sandbox-lightgrey.svg)](https://github.com/swift-server/sswg/blob/master/process/incubation.md#sandbox-level) [![Swift 5.8+](http://img.shields.io/badge/Swift-5.8+-blue.svg)](https://swift.org)
22

33
[![MIT license](http://img.shields.io/badge/license-MIT-lightgrey.svg)](http://opensource.org/licenses/MIT) ![Tests](https://github.com/mattpolzin/OpenAPIKit/workflows/Tests/badge.svg)
44

@@ -10,8 +10,8 @@ OpenAPIKit follows semantic versioning despite the fact that the OpenAPI specifi
1010

1111
| OpenAPIKit | Swift | OpenAPI v3.0 | OpenAPI v3.1 | External Dereferencing |
1212
|------------|-------|--------------|--------------|------------------------|
13-
| v2.x | 5.1+ || | |
14-
| v3.x | 5.1+ ||| |
13+
| v2.x | 5.1+ || | |
14+
| v3.x | 5.1+ ||| |
1515
| v4.x | 5.8+ ||||
1616

1717
- [Usage](#usage)
@@ -76,7 +76,7 @@ import OpenAPIKit
7676
It is recommended that you build your project against the `OpenAPIKit` module and only use `OpenAPIKit30` to support reading OpenAPI 3.0.x documents in and then [converting them](#supporting-openapi-30x-documents) to OpenAPI 3.1.x documents. The situation not supported yet by this strategy is where you need to write out an OpenAPI 3.0.x document (as opposed to 3.1.x). That is a planned feature but it has not yet been implemented. If your use-case benefits from reading in an OpenAPI 3.0.x document and also writing out an OpenAPI 3.0.x document then you can operate entirely against the `OpenAPIKit30` module.
7777

7878
#### 3.x to 4.x
79-
This section has not been written yet. Stay tuned!
79+
If you are migrating from OpenAPIKit 3.x to OpenAPIKit 4.x, check out the [v4 migration guide](./documentation/v4_migration_guide.md).
8080

8181
### Decoding OpenAPI Documents
8282

documentation/v4_migration_guide.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
## OpenAPIKit v4 Migration Guide
2+
For general information on the v4 release, see the release notes on GitHub. The
3+
rest of this guide will be formatted as a series of changes and what options you
4+
have to migrate code from v3 to v4. You can also refer back to the release notes
5+
for each of the v4 pre-releases for the most thorough look at what changed.
6+
7+
This guide will not spend time on strictly additive features of version 4. See
8+
the release notes, README, and documentation for information on new features.
9+
10+
### Swift version support
11+
OpenAPIKit v4.0 drops support for Swift versions prior to 5.8 (i.e. it supports
12+
v5.8 and greater).
13+
14+
### Yams version support
15+
Yams is only a test dependency of OpenAPIKit, but since it is still a dependency
16+
it will still impact dependency resolution of downstream projects. Yams 5.1.0+
17+
is now required.
18+
19+
### MacOS version support
20+
Only relevant when compiling OpenAPIKit on macOS: Now v10_15+ is required.
21+
22+
### OpenAPI Specification Versions
23+
The `OpenAPIKit.Document.Version` enum gained `v3_1_1` and the
24+
`OpenAPIKit30.Document.Version` enum gained `v3_0_4`. If you have exhaustive
25+
switches over values of those types then your switch statements will need to be
26+
updated.
27+
28+
### Typo corrections
29+
The following typo corrections were made to OpenAPIKit code. These amount to
30+
breaking changes only in so far as you need to correct the same names if they
31+
appear in your codebase.
32+
33+
- `public static Validation.serverVarialbeEnumIsValid` -> `.serverVariableEnumIsValid`
34+
- `spublic static Validation.erverVarialbeDefaultExistsInEnum` -> `.serverVariableDefaultExistsInEnum`
35+
36+
### `AnyCodable`
37+
**NOTE** that the `AnyCodable` type is used extensively for OpenAPIKit examples
38+
and vendor extensions so that is likely where this note will be relevant to you.
39+
40+
1. The constructor for `AnyCodable` now requires knowledge at compile time that
41+
the value it is initialized with is `Sendable`.
42+
2. Array and Dictionary literal protocol conformances had to be dropped.
43+
Anywhere you were relying on implicit conversion from e.g. `["hello": 1]` to
44+
an `AnyCodable`, wrap the literal with an explicit call to init:
45+
`.init(["hello": 1])`.
46+
47+
### Vendor Extensions
48+
1. The `vendorExtensions` property of any `VendorExtendable` type must now
49+
implement a setter as well as a getter. This is not likely to impact
50+
downstream projects, but technically possible.
51+
2. If you are disabling `vendorExtensions` support via the
52+
`VendorExtensionsConfiguration.isEnabled` property, you need to switch to
53+
using encoder/decoder `userInfo` to disable vendor extensions. The
54+
`isEnabled` property has been removed. See the example below.
55+
56+
To set an encoder or decoder up to disable vendor extensions use code like the
57+
following before using the encoder or decoder with an OpenAPIKit type:
58+
```swift
59+
let userInfo = [VendorExtensionsConfiguration.enabledKey: false]
60+
let encoder = JSONEncoder()
61+
encoder.userInfo = userInfo
62+
63+
let decoder = JSONDecoder()
64+
decoder.userInfo = userInfo
65+
```
66+
67+
### `OpenAPI.Content.Encoding`
68+
The `contentType` property has been removed in favor of the newer `contentTypes`
69+
property (plural).
70+
71+
### `JSONSchemaContext`
72+
The default (fallback) implementations of `inferred`, `anchor`, and
73+
`dynamicAnchor` have been removed. Almost no downstream code will break because
74+
of this, but if you've implemented the `JSONSchemaContext` protocol yourself
75+
then this note is for you.

0 commit comments

Comments
 (0)