File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change @@ -146,21 +146,21 @@ swagger-to-ts handles parsing of Swagger files.
146
146
147
147
An example on how to use the ` x-nullable ` property to control if a property is optional:
148
148
149
- ```
150
- const getNullable = (d: { [key: string]: any }): boolean => {
151
- const nullable = d['x-nullable'];
152
- if (typeof nullable === 'boolean') {
153
- return nullable;
154
- }
155
- return true;
156
- };
157
-
158
- const propertyMapper = (
159
- swaggerDefinition: Swagger2Definition ,
160
- property: Property
161
- ): Property => ({ ...property, optional: getNullable(swaggerDefinition) });
162
-
163
- const output = swaggerToTS(swagger, { propertyMapper });
149
+ ``` js
150
+ const getNullable = (d: { [key: string]: any }): boolean => {
151
+ const nullable = d[' x-nullable' ];
152
+ if (typeof nullable === ' boolean' ) {
153
+ return nullable;
154
+ }
155
+ return true ;
156
+ };
157
+
158
+ const propertyMapper = (swaggerDefinition : Swagger2Definition, property : Property) : Property => ({
159
+ ... property ,
160
+ optional : getNullable (swaggerDefinition),
161
+ });
162
+
163
+ const output = swaggerToTS (swagger, { propertyMapper });
164
164
```
165
165
166
166
[ glob ] : https://www.npmjs.com/package/glob
You can’t perform that action at this time.
0 commit comments