File tree Expand file tree Collapse file tree 5 files changed +11
-15
lines changed Expand file tree Collapse file tree 5 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -328,8 +328,11 @@ enum EnumWithStrings {
328
328
}
329
329
```
330
330
331
- ### Nullable in OpenApi v2
332
- You can use the unofficial ` x-nullable ` backport in your specification to generate nullable properties in OpenApi v2.
331
+
332
+ ### Nullable in OpenAPI v2
333
+ In the OpenAPI v3 spec you can create properties that can be NULL, by providing a ` nullable: true ` in your schema.
334
+ However, the v2 spec does not allow you to do this. You can use the unofficial ` x-nullable ` in your specification
335
+ to generate nullable properties in OpenApi v2.
333
336
334
337
``` json
335
338
{
@@ -346,7 +349,7 @@ You can use the unofficial `x-nullable` backport in your specification to genera
346
349
"requiredProp" : {
347
350
"description" : " This is a simple string property" ,
348
351
"type" : " string" ,
349
- "x-nullable" : true ,
352
+ "x-nullable" : true
350
353
}
351
354
}
352
355
}
@@ -355,9 +358,9 @@ You can use the unofficial `x-nullable` backport in your specification to genera
355
358
356
359
Generated code:
357
360
``` typescript
358
- enum ModelWithNullableString {
361
+ interface ModelWithNullableString {
359
362
prop? : string | null ,
360
- requiredProp : string | null
363
+ requiredProp: string | null ,
361
364
}
362
365
```
363
366
Original file line number Diff line number Diff line change 1
- /**
2
- * Supported extension for enums
3
- */
4
1
export interface WithEnumExtension {
5
2
'x-enum-varnames' ?: string [ ] ;
6
3
'x-enum-descriptions' ?: string [ ] ;
Original file line number Diff line number Diff line change 1
- /**
2
- * Supported extension for enums
3
- */
4
1
export interface WithNullableExtension {
5
2
'x-nullable' ?: boolean ;
6
3
}
Original file line number Diff line number Diff line change 1
- /**
2
- * Supported extension for enums
3
- */
4
1
export interface WithEnumExtension {
5
2
'x-enum-varnames' ?: string [ ] ;
6
3
'x-enum-descriptions' ?: string [ ] ;
Original file line number Diff line number Diff line change 861
861
"ModelWithNullableString" : {
862
862
"description" : " This is a model with one string property" ,
863
863
"type" : " object" ,
864
- "required" : [" nullableRequiredProp" ],
864
+ "required" : [
865
+ " nullableRequiredProp"
866
+ ],
865
867
"properties" : {
866
868
"nullableProp" : {
867
869
"description" : " This is a simple string property" ,
You can’t perform that action at this time.
0 commit comments