Skip to content

Commit 5ed951f

Browse files
committed
yaml: null != 'null'
1 parent 86cff2f commit 5ed951f

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

Sources/swift-openapi-generator/Documentation.docc/Development/Handling-nullable-schemas.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For example:
3737

3838
```yaml
3939
MyOptionalString:
40-
type: [string, null]
40+
type: [string, 'null']
4141
```
4242

4343
> The rule can be summarized as: `schema is optional := schema is nullable`, where being `nullable` is represented slightly differently between the two JSON Schema versions.
@@ -75,7 +75,7 @@ MyPerson:
7575
name:
7676
type: string
7777
age:
78-
type: [integer, null]
78+
type: [integer, 'null']
7979
required:
8080
- name
8181
- age # even though required, the nullability of the schema "wins"

Tests/OpenAPIGeneratorReferenceTests/Resources/Docs/petstore.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ components:
403403
type: object
404404
properties:
405405
foo:
406-
type: [array, null]
406+
type: [array, 'null']
407407
items:
408-
type: [string, null]
408+
type: [string, 'null']
409409
CodeError:
410410
type: object
411411
properties:

Tests/OpenAPIGeneratorReferenceTests/SnippetBasedReferenceTests.swift

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
192192
StringArrayNullableItems:
193193
type: array
194194
items:
195-
type: [string, null]
195+
type: [string, 'null']
196196
""",
197197
"""
198198
public enum Schemas {
@@ -213,7 +213,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
213213
items:
214214
$ref: '#/components/schemas/NullableString'
215215
NullableString:
216-
type: [string, null]
216+
type: [string, 'null']
217217
""",
218218
"""
219219
public enum Schemas {
@@ -255,9 +255,9 @@ final class SnippetBasedReferenceTests: XCTestCase {
255255
fooRequired:
256256
type: string
257257
fooOptionalNullable:
258-
type: [string, null]
258+
type: [string, 'null']
259259
fooRequiredNullable:
260-
type: [string, null]
260+
type: [string, 'null']
261261
262262
fooOptionalArray:
263263
type: array
@@ -268,30 +268,30 @@ final class SnippetBasedReferenceTests: XCTestCase {
268268
items:
269269
type: string
270270
fooOptionalNullableArray:
271-
type: [array, null]
271+
type: [array, 'null']
272272
items:
273273
type: string
274274
fooRequiredNullableArray:
275-
type: [array, null]
275+
type: [array, 'null']
276276
items:
277277
type: string
278278
279279
fooOptionalArrayOfNullableItems:
280280
type: array
281281
items:
282-
type: [string, null]
282+
type: [string, 'null']
283283
fooRequiredArrayOfNullableItems:
284284
type: array
285285
items:
286-
type: [string, null]
286+
type: [string, 'null']
287287
fooOptionalNullableArrayOfNullableItems:
288-
type: [array, null]
288+
type: [array, 'null']
289289
items:
290-
type: [string, null]
290+
type: [string, 'null']
291291
fooRequiredNullableArrayOfNullableItems:
292-
type: [array, null]
292+
type: [array, 'null']
293293
items:
294-
type: [string, null]
294+
type: [string, 'null']
295295
required:
296296
- fooRequired
297297
- fooRequiredNullable
@@ -499,7 +499,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
499499
MyRequiredString:
500500
type: string
501501
MyNullableString:
502-
type: [string, null]
502+
type: [string, 'null']
503503
MyObject:
504504
type: object
505505
properties:
@@ -2692,7 +2692,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
26922692
content:
26932693
application/json:
26942694
schema:
2695-
type: [string, null]
2695+
type: [string, 'null']
26962696
responses:
26972697
default:
26982698
description: Response
@@ -2848,7 +2848,7 @@ final class SnippetBasedReferenceTests: XCTestCase {
28482848
content:
28492849
application/json:
28502850
schema:
2851-
type: [string, null]
2851+
type: [string, 'null']
28522852
responses:
28532853
default:
28542854
description: Response

0 commit comments

Comments
 (0)