Skip to content

Commit

Permalink
Merge pull request #149 from apivideo/nodejs-default-values
Browse files Browse the repository at this point in the history
fix(nodejs) handle properties default values
  • Loading branch information
bot-api-video authored Aug 21, 2023
2 parents cb318c3 + 8dcce80 commit d0d6e6a
Show file tree
Hide file tree
Showing 8 changed files with 390 additions and 358 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All changes to this project will be documented in this file.

## [2.5.4] - 2023-08-21
- Set default values defined in the description

## [2.5.3] - 2023-07-24
- generate only CommonJS target

Expand Down
720 changes: 368 additions & 352 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@api.video/nodejs-client",
"version": "2.5.3",
"version": "2.5.4",
"description": "api.video nodejs API client",
"keywords": [
"api.video",
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class HttpClient {
this.chunkSize = params.chunkSize;
this.headers = new AxiosHeaders({
Accept: 'application/json, */*;q=0.8',
'AV-Origin-Client': 'nodejs:2.5.3',
'AV-Origin-Client': 'nodejs:2.5.4',
Authorization: this.apiKey ? `Basic ${encode(`${this.apiKey}:`)}` : '',
...(params.applicationName && params.applicationVersion
? {
Expand Down
18 changes: 14 additions & 4 deletions src/ObjectSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,19 @@ export default class ObjectSerializer {
return expectedType;
}

public static serialize(data: any, type: string, format: string): any {
public static serialize(
data: any,
type: string,
format: string,
defaultValue?: any
): any {
if (data == undefined) {
return data;
} else if (primitives.indexOf(type.toLowerCase()) !== -1) {
if (typeof defaultValue === 'undefined') {
return data;
}
data = defaultValue;
}
if (primitives.indexOf(type.toLowerCase()) !== -1) {
return data;
} else if (type.lastIndexOf('Array<', 0) === 0) {
// string.startsWith pre es6
Expand Down Expand Up @@ -250,7 +259,8 @@ export default class ObjectSerializer {
instance[attributeType.baseName] = ObjectSerializer.serialize(
data[attributeType.name],
attributeType.type,
attributeType.format
attributeType.format,
attributeType.defaultValue
);
}
return instance;
Expand Down
1 change: 1 addition & 0 deletions src/model/AccessToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class AccessToken {
baseName: 'token_type',
type: 'string',
format: '',
defaultValue: 'bearer',
},
{
name: 'refreshToken',
Expand Down
1 change: 1 addition & 0 deletions src/model/AttributeType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export default interface AttributeType {
baseName: string;
type: string;
format: string;
defaultValue?: any;
}
1 change: 1 addition & 0 deletions src/model/TokenCreationPayload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default class TokenCreationPayload {
baseName: 'ttl',
type: 'number',
format: '',
defaultValue: 0,
},
];

Expand Down

0 comments on commit d0d6e6a

Please sign in to comment.