This commit is contained in:
Ferdi Koomen 2021-11-26 15:51:14 -05:00
parent 6d822eb802
commit e263cb27f6
4 changed files with 55 additions and 4 deletions

View File

@ -185,7 +185,7 @@ export function getModel(
model.type = definitionType.type;
model.base = definitionType.base;
model.template = definitionType.template;
model.isNullable = definitionType.isNullable;
model.isNullable = definitionType.isNullable || model.isNullable;
model.imports.push(...definitionType.imports);
model.default = getModelDefault(definition, model);
return model;

View File

@ -2100,6 +2100,8 @@ export class DefaultsService {
* @param parameterOptionalStringWithNoDefault This is a optional string with no default
* @param parameterStringWithDefault This is a string with default
* @param parameterStringWithEmptyDefault This is a string with empty default
* @param parameterStringNullableWithNoDefault This is a string that can be null with no default
* @param parameterStringNullableWithDefault This is a string that can be null with default
* @throws ApiError
*/
public static callToTestOrderOfParams(
@ -2109,6 +2111,8 @@ export class DefaultsService {
parameterOptionalStringWithNoDefault?: string,
parameterStringWithDefault: string = 'Hello World!',
parameterStringWithEmptyDefault: string = '',
parameterStringNullableWithNoDefault?: string | null,
parameterStringNullableWithDefault: string | null = null,
): CancelablePromise<void> {
return __request({
method: 'PUT',
@ -2120,6 +2124,8 @@ export class DefaultsService {
'parameterStringWithDefault': parameterStringWithDefault,
'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault,
'parameterStringWithNoDefault': parameterStringWithNoDefault,
'parameterStringNullableWithNoDefault': parameterStringNullableWithNoDefault,
'parameterStringNullableWithDefault': parameterStringNullableWithDefault,
},
});
}
@ -4095,7 +4101,7 @@ exports[`v3 should generate: ./test/generated/v3/models/SimpleStringWithPattern.
/**
* This is a simple string
*/
export type SimpleStringWithPattern = string;"
export type SimpleStringWithPattern = string | null;"
`;
exports[`v3 should generate: ./test/generated/v3/schemas/$ArrayWithArray.ts 1`] = `
@ -4984,6 +4990,7 @@ exports[`v3 should generate: ./test/generated/v3/schemas/$SimpleStringWithPatter
/* eslint-disable */
export const $SimpleStringWithPattern = {
type: 'string',
isNullable: true,
maxLength: 64,
pattern: '^[a-zA-Z0-9_]*$',
} as const;"
@ -5185,6 +5192,8 @@ export class DefaultsService {
* @param parameterOptionalStringWithNoDefault This is a optional string with no default
* @param parameterStringWithDefault This is a string with default
* @param parameterStringWithEmptyDefault This is a string with empty default
* @param parameterStringNullableWithNoDefault This is a string that can be null with no default
* @param parameterStringNullableWithDefault This is a string that can be null with default
* @throws ApiError
*/
public static callToTestOrderOfParams(
@ -5194,6 +5203,8 @@ export class DefaultsService {
parameterOptionalStringWithNoDefault?: string,
parameterStringWithDefault: string = 'Hello World!',
parameterStringWithEmptyDefault: string = '',
parameterStringNullableWithNoDefault?: string | null,
parameterStringNullableWithDefault: string | null = null,
): CancelablePromise<void> {
return __request({
method: 'PUT',
@ -5205,6 +5216,8 @@ export class DefaultsService {
'parameterStringWithDefault': parameterStringWithDefault,
'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault,
'parameterStringWithNoDefault': parameterStringWithNoDefault,
'parameterStringNullableWithNoDefault': parameterStringNullableWithNoDefault,
'parameterStringNullableWithDefault': parameterStringNullableWithDefault,
},
});
}
@ -5879,8 +5892,8 @@ export class TypesService {
parameterDictionary: any,
parameterEnum: 'Success' | 'Warning' | 'Error' | null,
parameterNumber: number = 123,
parameterString: string = 'default',
parameterBoolean: boolean = true,
parameterString: string | null = 'default',
parameterBoolean: boolean | null = true,
parameterObject: any = null,
id?: number,
): CancelablePromise<number | string | boolean | any> {

View File

@ -340,6 +340,23 @@
"in": "query",
"required": true,
"type": "string"
},
{
"x-nullable": true,
"description": "This is a string that can be null with no default",
"name": "parameterStringNullableWithNoDefault",
"in": "query",
"required": false,
"type": "string"
},
{
"x-nullable": true,
"description": "This is a string that can be null with default",
"name": "parameterStringNullableWithDefault",
"in": "query",
"required": false,
"type": "string",
"default": null
}
]
}

View File

@ -525,6 +525,27 @@
"schema": {
"type": "string"
}
},
{
"description": "This is a string that can be null with no default",
"name": "parameterStringNullableWithNoDefault",
"in": "query",
"required": false,
"schema": {
"type": "string",
"nullable": true
}
},
{
"description": "This is a string that can be null with default",
"name": "parameterStringNullableWithDefault",
"in": "query",
"required": false,
"schema": {
"type": "string",
"nullable": true,
"default": null
}
}
]
}