- Aligned sorter with 0.2.7, to prevent to many issues with exsiting users

This commit is contained in:
Ferdi Koomen 2020-05-23 19:40:21 +02:00
parent aebb8b8947
commit b437eeb0dc
3 changed files with 83 additions and 119 deletions

View File

@ -1,27 +1,9 @@
import { OperationParameter } from '../../../client/interfaces/OperationParameter';
/**
* Sort by required and default values creating the following order:
* 1. Parameters that are required and have no default value
* 2. Parameters that are optional and have no default value
* 3. Parameters that are required and have a default value
* 4. Parameters that are optional and have a default value
*
* Resulting in the following order:
*
* function myFunction(param1: string, param2?: string, param3: string = 'hello') {
* ...
* }
*
* @param a
* @param b
*/
export function sortByRequired(a: OperationParameter, b: OperationParameter): number {
const aHasDefaultValue = a.default !== undefined;
const bHasDefaultValue = b.default !== undefined;
if (aHasDefaultValue && !bHasDefaultValue) return 1;
if (!aHasDefaultValue && bHasDefaultValue) return -1;
if (a.isRequired && !b.isRequired) return -1;
if (!a.isRequired && b.isRequired) return 1;
const aNeedsValue = a.isRequired && a.default === undefined;
const bNeedsValue = a.isRequired && a.default === undefined;
if (aNeedsValue && !bNeedsValue) return -1;
if (!aNeedsValue && bNeedsValue) return 1;
return 0;
}

View File

@ -1,27 +1,9 @@
import { OperationParameter } from '../../../client/interfaces/OperationParameter';
/**
* Sort by required and default values creating the following order:
* 1. Parameters that are required and have no default value
* 2. Parameters that are optional and have no default value
* 3. Parameters that are required and have a default value
* 4. Parameters that are optional and have a default value
*
* Resulting in the following order:
*
* function myFunction(param1: string, param2?: string, param3: string = 'hello') {
* ...
* }
*
* @param a
* @param b
*/
export function sortByRequired(a: OperationParameter, b: OperationParameter): number {
const aHasDefaultValue = a.default !== undefined;
const bHasDefaultValue = b.default !== undefined;
if (aHasDefaultValue && !bHasDefaultValue) return 1;
if (!aHasDefaultValue && bHasDefaultValue) return -1;
if (a.isRequired && !b.isRequired) return -1;
if (!a.isRequired && b.isRequired) return 1;
const aNeedsValue = a.isRequired && a.default === undefined;
const bNeedsValue = a.isRequired && a.default === undefined;
if (aNeedsValue && !bNeedsValue) return -1;
if (!aNeedsValue && bNeedsValue) return 1;
return 0;
}

View File

@ -2100,40 +2100,40 @@ export class DefaultsService {
}
/**
* @param parameterStringWithNoDefault This is a string with no default
* @param parameterOptionalStringWithDefault This is a optional string with default
* @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default
* @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 parameterOptionalStringWithDefault This is a optional string with default
* @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default
* @param parameterStringWithNoDefault This is a string with no default
* @throws ApiError
*/
public static async callToTestOrderOfParams({
parameterStringWithNoDefault,
parameterOptionalStringWithDefault = 'Hello World!',
parameterOptionalStringWithEmptyDefault = '',
parameterOptionalStringWithNoDefault,
parameterStringWithDefault = 'hello',
parameterStringWithEmptyDefault = '',
parameterOptionalStringWithDefault = 'Hello World!',
parameterOptionalStringWithEmptyDefault = '',
parameterStringWithNoDefault,
}: {
parameterStringWithNoDefault: string,
parameterOptionalStringWithDefault?: string,
parameterOptionalStringWithEmptyDefault?: string,
parameterOptionalStringWithNoDefault?: string,
parameterStringWithDefault?: string,
parameterStringWithEmptyDefault?: string,
parameterOptionalStringWithDefault?: string,
parameterOptionalStringWithEmptyDefault?: string,
parameterStringWithNoDefault: string,
}): Promise<void> {
const result = await __request({
method: 'put',
path: \`/api/v\${OpenAPI.VERSION}/defaults\`,
query: {
'parameterStringWithNoDefault': parameterStringWithNoDefault,
'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault,
'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault,
'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault,
'parameterStringWithDefault': parameterStringWithDefault,
'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault,
'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault,
'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault,
'parameterStringWithNoDefault': parameterStringWithNoDefault,
},
});
@ -2311,31 +2311,31 @@ export class ParametersService {
}
/**
* @param parameterPath1 This is the parameter that goes into the path
* @param parameterPath2 This is the parameter that goes into the path
* @param parameterPath3 This is the parameter that goes into the path
* @param parameterHeader This is the parameter that goes into the request header
* @param parameterQuery This is the parameter that goes into the request query params
* @param parameterForm This is the parameter that goes into the request form data
* @param parameterBody This is the parameter that is send as request body
* @param parameterPath1 This is the parameter that goes into the path
* @param parameterPath2 This is the parameter that goes into the path
* @param parameterPath3 This is the parameter that goes into the path
* @throws ApiError
*/
public static async callWithWeirdParameterNames({
parameterPath1,
parameterPath2,
parameterPath3,
parameterHeader,
parameterQuery,
parameterForm,
parameterBody,
parameterPath1,
parameterPath2,
parameterPath3,
}: {
parameterPath1?: string,
parameterPath2?: string,
parameterPath3?: string,
parameterHeader: string,
parameterQuery: string,
parameterForm: string,
parameterBody: string,
parameterPath1?: string,
parameterPath2?: string,
parameterPath3?: string,
}): Promise<void> {
const result = await __request({
@ -2579,14 +2579,14 @@ import { OpenAPI } from '../core/OpenAPI';
export class TypesService {
/**
* @param parameterArray This is an array parameter
* @param parameterDictionary This is a dictionary parameter
* @param parameterEnum This is an enum parameter
* @param id This is a number parameter
* @param parameterNumber This is a number parameter
* @param parameterString This is a string parameter
* @param parameterBoolean This is a boolean parameter
* @param parameterObject This is an object parameter
* @param parameterArray This is an array parameter
* @param parameterDictionary This is a dictionary parameter
* @param parameterEnum This is an enum parameter
* @param id This is a number parameter
* @result number Response is a simple number
* @result string Response is a simple string
* @result boolean Response is a simple boolean
@ -2594,36 +2594,36 @@ export class TypesService {
* @throws ApiError
*/
public static async types({
parameterArray,
parameterDictionary,
parameterEnum,
id,
parameterNumber = 123,
parameterString = 'default',
parameterBoolean = true,
parameterObject = null,
parameterArray,
parameterDictionary,
parameterEnum,
id,
}: {
parameterArray: Array<string>,
parameterDictionary: Dictionary<string>,
parameterEnum: ('Success' | 'Warning' | 'Error'),
id?: number,
parameterNumber?: number,
parameterString?: string,
parameterBoolean?: boolean,
parameterObject?: any,
parameterArray: Array<string>,
parameterDictionary: Dictionary<string>,
parameterEnum: ('Success' | 'Warning' | 'Error'),
id?: number,
}): Promise<number | string | boolean | any> {
const result = await __request({
method: 'get',
path: \`/api/v\${OpenAPI.VERSION}/types\`,
query: {
'parameterArray': parameterArray,
'parameterDictionary': parameterDictionary,
'parameterEnum': parameterEnum,
'parameterNumber': parameterNumber,
'parameterString': parameterString,
'parameterBoolean': parameterBoolean,
'parameterObject': parameterObject,
'parameterArray': parameterArray,
'parameterDictionary': parameterDictionary,
'parameterEnum': parameterEnum,
},
});
@ -4864,40 +4864,40 @@ export class DefaultsService {
}
/**
* @param parameterStringWithNoDefault This is a string with no default
* @param parameterOptionalStringWithDefault This is a optional string with default
* @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default
* @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 parameterOptionalStringWithDefault This is a optional string with default
* @param parameterOptionalStringWithEmptyDefault This is a optional string with empty default
* @param parameterStringWithNoDefault This is a string with no default
* @throws ApiError
*/
public static async callToTestOrderOfParams({
parameterStringWithNoDefault,
parameterOptionalStringWithDefault = 'hello',
parameterOptionalStringWithEmptyDefault = '',
parameterOptionalStringWithNoDefault,
parameterStringWithDefault = 'hello',
parameterStringWithEmptyDefault = '',
parameterOptionalStringWithDefault = 'hello',
parameterOptionalStringWithEmptyDefault = '',
parameterStringWithNoDefault,
}: {
parameterStringWithNoDefault: string,
parameterOptionalStringWithDefault?: string,
parameterOptionalStringWithEmptyDefault?: string,
parameterOptionalStringWithNoDefault?: string,
parameterStringWithDefault?: string,
parameterStringWithEmptyDefault?: string,
parameterOptionalStringWithDefault?: string,
parameterOptionalStringWithEmptyDefault?: string,
parameterStringWithNoDefault: string,
}): Promise<void> {
const result = await __request({
method: 'put',
path: \`/api/v\${OpenAPI.VERSION}/defaults\`,
query: {
'parameterStringWithNoDefault': parameterStringWithNoDefault,
'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault,
'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault,
'parameterOptionalStringWithNoDefault': parameterOptionalStringWithNoDefault,
'parameterStringWithDefault': parameterStringWithDefault,
'parameterStringWithEmptyDefault': parameterStringWithEmptyDefault,
'parameterOptionalStringWithDefault': parameterOptionalStringWithDefault,
'parameterOptionalStringWithEmptyDefault': parameterOptionalStringWithEmptyDefault,
'parameterStringWithNoDefault': parameterStringWithNoDefault,
},
});
@ -5121,34 +5121,34 @@ export class ParametersService {
}
/**
* @param parameterPath1 This is the parameter that goes into the path
* @param parameterPath2 This is the parameter that goes into the path
* @param parameterPath3 This is the parameter that goes into the path
* @param parameterHeader This is the parameter that goes into the request header
* @param parameterQuery This is the parameter that goes into the request query params
* @param parameterForm This is the parameter that goes into the request form data
* @param parameterCookie This is the parameter that goes into the cookie
* @param requestBody This is the parameter that goes into the body
* @param parameterPath1 This is the parameter that goes into the path
* @param parameterPath2 This is the parameter that goes into the path
* @param parameterPath3 This is the parameter that goes into the path
* @throws ApiError
*/
public static async callWithWeirdParameterNames({
parameterPath1,
parameterPath2,
parameterPath3,
parameterHeader,
parameterQuery,
parameterForm,
parameterCookie,
requestBody,
parameterPath1,
parameterPath2,
parameterPath3,
}: {
parameterPath1?: string,
parameterPath2?: string,
parameterPath3?: string,
parameterHeader: string | null,
parameterQuery: string | null,
parameterForm: string | null,
parameterCookie: string | null,
requestBody: ModelThatExtends | ModelThatExtendsExtends | ModelWithString | null,
parameterPath1?: string,
parameterPath2?: string,
parameterPath3?: string,
}): Promise<void> {
const result = await __request({
@ -5175,16 +5175,16 @@ export class ParametersService {
}
/**
* @param requestBody This is a required parameter
* @param parameter This is an optional parameter
* @param requestBody This is a required parameter
* @throws ApiError
*/
public static async getCallWithOptionalParam({
requestBody,
parameter,
requestBody,
}: {
requestBody: ModelThatExtends | ModelThatExtendsExtends | ModelWithString,
parameter?: string,
requestBody: ModelThatExtends | ModelThatExtendsExtends | ModelWithString,
}): Promise<void> {
const result = await __request({
@ -5448,14 +5448,14 @@ import { OpenAPI } from '../core/OpenAPI';
export class TypesService {
/**
* @param parameterArray This is an array parameter
* @param parameterDictionary This is a dictionary parameter
* @param parameterEnum This is an enum parameter
* @param id This is a number parameter
* @param parameterNumber This is a number parameter
* @param parameterString This is a string parameter
* @param parameterBoolean This is a boolean parameter
* @param parameterObject This is an object parameter
* @param parameterArray This is an array parameter
* @param parameterDictionary This is a dictionary parameter
* @param parameterEnum This is an enum parameter
* @param id This is a number parameter
* @result number Response is a simple number
* @result string Response is a simple string
* @result boolean Response is a simple boolean
@ -5463,36 +5463,36 @@ export class TypesService {
* @throws ApiError
*/
public static async types({
parameterArray,
parameterDictionary,
parameterEnum,
id,
parameterNumber = 123,
parameterString = 'default',
parameterBoolean = true,
parameterObject = null,
parameterArray,
parameterDictionary,
parameterEnum,
id,
}: {
parameterArray: Array<string> | null,
parameterDictionary: any,
parameterEnum: ('Success' | 'Warning' | 'Error') | null,
id?: number,
parameterNumber?: number,
parameterString?: string | null,
parameterBoolean?: boolean | null,
parameterObject?: any,
parameterArray: Array<string> | null,
parameterDictionary: any,
parameterEnum: ('Success' | 'Warning' | 'Error') | null,
id?: number,
}): Promise<number | string | boolean | any> {
const result = await __request({
method: 'get',
path: \`/api/v\${OpenAPI.VERSION}/types\`,
query: {
'parameterArray': parameterArray,
'parameterDictionary': parameterDictionary,
'parameterEnum': parameterEnum,
'parameterNumber': parameterNumber,
'parameterString': parameterString,
'parameterBoolean': parameterBoolean,
'parameterObject': parameterObject,
'parameterArray': parameterArray,
'parameterDictionary': parameterDictionary,
'parameterEnum': parameterEnum,
},
});