Skip to content

Commit 14c04d2

Browse files
committed
docs: adds information regarding collections types
Signed-off-by: Vincent Biret <[email protected]>
1 parent d6a5fe4 commit 14c04d2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/upgrade-guide-2.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,19 @@ var document = new OpenApiDocument
237237
var componentA = document.Components["A"];
238238
```
239239

240+
### Collections are implementations
241+
242+
Any collection used by the model now documents using the implementation type instead of the interface. This facilitates the usage of new language features such as collections initialization.
243+
244+
```csharp
245+
var schema = new OpenApiSchema();
246+
247+
// 1.X: does not compile due to the lack of implementation type
248+
// 2.X: compiles successfully
249+
schema.AnyOf = [];
250+
// now a List<OpenApiSchema> instead of IList<OpenApiSchema>
251+
```
252+
240253
### Updates to OpenApiSchema
241254

242255
The OpenAPI 3.1 specification changes significantly how it leverages JSON Schema. In 3.0 and earlier, OpenAPI used a "subset, superset" of JSON Schema draft-4. This caused many problems for developers trying to use JSON Schema validation libraries with the JSON Schema in their OpenAPI descriptions. In OpenAPI 3.1, the 2020-12 draft version of JSON Schema was adopted and a new JSON Schema vocabulary was adopted to support OpenAPI specific keywords. All attempts to constrain what JSON Schema keywords could be used in OpenAPI were removed.

0 commit comments

Comments
 (0)