Skip to content

Commit 9184b2e

Browse files
committed
Small formatting change, small documentation change, rest seems good!
1 parent 7163a52 commit 9184b2e

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,11 @@ enum EnumWithStrings {
328328
}
329329
```
330330

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.
333336

334337
```json
335338
{
@@ -346,7 +349,7 @@ You can use the unofficial `x-nullable` backport in your specification to genera
346349
"requiredProp": {
347350
"description": "This is a simple string property",
348351
"type": "string",
349-
"x-nullable": true,
352+
"x-nullable": true
350353
}
351354
}
352355
}
@@ -355,9 +358,9 @@ You can use the unofficial `x-nullable` backport in your specification to genera
355358

356359
Generated code:
357360
```typescript
358-
enum ModelWithNullableString {
361+
interface ModelWithNullableString {
359362
prop?: string | null,
360-
requiredProp: string | null
363+
requiredProp: string | null,
361364
}
362365
```
363366

src/openApi/v2/interfaces/Extensions/WithEnumExtension.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/**
2-
* Supported extension for enums
3-
*/
41
export interface WithEnumExtension {
52
'x-enum-varnames'?: string[];
63
'x-enum-descriptions'?: string[];
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/**
2-
* Supported extension for enums
3-
*/
41
export interface WithNullableExtension {
52
'x-nullable'?: boolean;
63
}

src/openApi/v3/interfaces/Extensions/WithEnumExtension.d.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/**
2-
* Supported extension for enums
3-
*/
41
export interface WithEnumExtension {
52
'x-enum-varnames'?: string[];
63
'x-enum-descriptions'?: string[];

test/spec/v2.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,9 @@
861861
"ModelWithNullableString": {
862862
"description": "This is a model with one string property",
863863
"type": "object",
864-
"required": ["nullableRequiredProp"],
864+
"required": [
865+
"nullableRequiredProp"
866+
],
865867
"properties": {
866868
"nullableProp": {
867869
"description": "This is a simple string property",

0 commit comments

Comments
 (0)