diff --git a/js/.openapi-generator/VERSION b/js/.openapi-generator/VERSION index 73a86b1..4bc5d61 100644 --- a/js/.openapi-generator/VERSION +++ b/js/.openapi-generator/VERSION @@ -1 +1 @@ -7.0.1 \ No newline at end of file +7.9.0 diff --git a/js/README.md b/js/README.md index c311d64..0f740c6 100644 --- a/js/README.md +++ b/js/README.md @@ -6,6 +6,7 @@ This SDK is automatically generated by the [OpenAPI Generator](https://openapi-g - API version: 0.1 - Package version: 0.1 +- Generator version: 7.9.0 - Build package: org.openapitools.codegen.languages.JavascriptClientCodegen ## Installation diff --git a/js/src/ApiClient.js b/js/src/ApiClient.js index c6c3f33..25c43ef 100644 --- a/js/src/ApiClient.js +++ b/js/src/ApiClient.js @@ -154,7 +154,7 @@ class ApiClient { url = apiBasePath + path; } - url = url.replace(/\{([\w-\.]+)\}/g, (fullMatch, key) => { + url = url.replace(/\{([\w-\.#]+)\}/g, (fullMatch, key) => { var value; if (pathParams.hasOwnProperty(key)) { value = this.paramToString(pathParams[key]); diff --git a/js/src/model/Director.js b/js/src/model/Director.js index c7857a7..828bc14 100644 --- a/js/src/model/Director.js +++ b/js/src/model/Director.js @@ -69,7 +69,7 @@ class Director { static validateJSON(data) { // check to make sure all required properties are present in the JSON string for (const property of Director.RequiredProperties) { - if (!data[property]) { + if (!data.hasOwnProperty(property)) { throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data)); } } diff --git a/js/src/model/DirectorFilmsInner.js b/js/src/model/DirectorFilmsInner.js index dca5063..81850b4 100644 --- a/js/src/model/DirectorFilmsInner.js +++ b/js/src/model/DirectorFilmsInner.js @@ -103,7 +103,7 @@ class DirectorFilmsInner { static validateJSON(data) { // check to make sure all required properties are present in the JSON string for (const property of DirectorFilmsInner.RequiredProperties) { - if (!data[property]) { + if (!data.hasOwnProperty(property)) { throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data)); } } diff --git a/js/src/model/DirectorFilmsInnerCountriesInner.js b/js/src/model/DirectorFilmsInnerCountriesInner.js index 7a7205a..bb42f81 100644 --- a/js/src/model/DirectorFilmsInnerCountriesInner.js +++ b/js/src/model/DirectorFilmsInnerCountriesInner.js @@ -67,7 +67,7 @@ class DirectorFilmsInnerCountriesInner { static validateJSON(data) { // check to make sure all required properties are present in the JSON string for (const property of DirectorFilmsInnerCountriesInner.RequiredProperties) { - if (!data[property]) { + if (!data.hasOwnProperty(property)) { throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data)); } } diff --git a/js/src/model/DirectorFilmsInnerOffersInner.js b/js/src/model/DirectorFilmsInnerOffersInner.js index d53741f..c1fca94 100644 --- a/js/src/model/DirectorFilmsInnerOffersInner.js +++ b/js/src/model/DirectorFilmsInnerOffersInner.js @@ -69,7 +69,7 @@ class DirectorFilmsInnerOffersInner { static validateJSON(data) { // check to make sure all required properties are present in the JSON string for (const property of DirectorFilmsInnerOffersInner.RequiredProperties) { - if (!data[property]) { + if (!data.hasOwnProperty(property)) { throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data)); } } diff --git a/js/src/model/DirectorInfo.js b/js/src/model/DirectorInfo.js index d907fbc..e24d744 100644 --- a/js/src/model/DirectorInfo.js +++ b/js/src/model/DirectorInfo.js @@ -72,7 +72,7 @@ class DirectorInfo { static validateJSON(data) { // check to make sure all required properties are present in the JSON string for (const property of DirectorInfo.RequiredProperties) { - if (!data[property]) { + if (!data.hasOwnProperty(property)) { throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data)); } } diff --git a/js/src/model/Film.js b/js/src/model/Film.js index 037b19b..d0a4211 100644 --- a/js/src/model/Film.js +++ b/js/src/model/Film.js @@ -103,7 +103,7 @@ class Film { static validateJSON(data) { // check to make sure all required properties are present in the JSON string for (const property of Film.RequiredProperties) { - if (!data[property]) { + if (!data.hasOwnProperty(property)) { throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data)); } } diff --git a/letsrolld-api-client/letsrolld_api_client/api/default/get_directors.py b/letsrolld-api-client/letsrolld_api_client/api/default/get_directors.py index 2c6a033..15b5e4f 100644 --- a/letsrolld-api-client/letsrolld_api_client/api/default/get_directors.py +++ b/letsrolld-api-client/letsrolld_api_client/api/default/get_directors.py @@ -31,7 +31,7 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[List["ArrayOfDirectorsItem"]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = [] _response_200 = response.json() for componentsschemas_array_of_directors_item_data in _response_200: diff --git a/letsrolld-api-client/letsrolld_api_client/api/default/get_directors_id.py b/letsrolld-api-client/letsrolld_api_client/api/default/get_directors_id.py index 2930b04..fb978f3 100644 --- a/letsrolld-api-client/letsrolld_api_client/api/default/get_directors_id.py +++ b/letsrolld-api-client/letsrolld_api_client/api/default/get_directors_id.py @@ -21,7 +21,7 @@ def _get_kwargs( def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Director]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = Director.from_dict(response.json()) return response_200 diff --git a/letsrolld-api-client/letsrolld_api_client/api/default/get_films.py b/letsrolld-api-client/letsrolld_api_client/api/default/get_films.py index 484025f..d47d589 100644 --- a/letsrolld-api-client/letsrolld_api_client/api/default/get_films.py +++ b/letsrolld-api-client/letsrolld_api_client/api/default/get_films.py @@ -40,7 +40,7 @@ def _get_kwargs( def _parse_response( *, client: Union[AuthenticatedClient, Client], response: httpx.Response ) -> Optional[List["ArrayOfFilmsItem"]]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = [] _response_200 = response.json() for componentsschemas_array_of_films_item_data in _response_200: diff --git a/letsrolld-api-client/letsrolld_api_client/api/default/get_films_id.py b/letsrolld-api-client/letsrolld_api_client/api/default/get_films_id.py index 383c679..9e16151 100644 --- a/letsrolld-api-client/letsrolld_api_client/api/default/get_films_id.py +++ b/letsrolld-api-client/letsrolld_api_client/api/default/get_films_id.py @@ -21,7 +21,7 @@ def _get_kwargs( def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Film]: - if response.status_code == HTTPStatus.OK: + if response.status_code == 200: response_200 = Film.from_dict(response.json()) return response_200 diff --git a/letsrolld-api-client/letsrolld_api_client/client.py b/letsrolld-api-client/letsrolld_api_client/client.py index 63a2493..0f6d15e 100644 --- a/letsrolld-api-client/letsrolld_api_client/client.py +++ b/letsrolld-api-client/letsrolld_api_client/client.py @@ -70,7 +70,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "Client": return evolve(self, timeout=timeout) def set_httpx_client(self, client: httpx.Client) -> "Client": - """Manually the underlying httpx.Client + """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. """ @@ -204,7 +204,7 @@ def with_timeout(self, timeout: httpx.Timeout) -> "AuthenticatedClient": return evolve(self, timeout=timeout) def set_httpx_client(self, client: httpx.Client) -> "AuthenticatedClient": - """Manually the underlying httpx.Client + """Manually set the underlying httpx.Client **NOTE**: This will override any other settings on the client, including cookies, headers, and timeout. """ diff --git a/ts/.openapi-generator/VERSION b/ts/.openapi-generator/VERSION index 73a86b1..4bc5d61 100644 --- a/ts/.openapi-generator/VERSION +++ b/ts/.openapi-generator/VERSION @@ -1 +1 @@ -7.0.1 \ No newline at end of file +7.9.0 diff --git a/ts/model/models.ts b/ts/model/models.ts index 1dc5360..ee582e9 100644 --- a/ts/model/models.ts +++ b/ts/model/models.ts @@ -57,6 +57,23 @@ let typeMap: {[index: string]: any} = { "Film": Film, } +// Check if a string starts with another string without using es6 features +function startsWith(str: string, match: string): boolean { + return str.substring(0, match.length) === match; +} + +// Check if a string ends with another string without using es6 features +function endsWith(str: string, match: string): boolean { + return str.length >= match.length && str.substring(str.length - match.length) === match; +} + +const nullableSuffix = " | null"; +const optionalSuffix = " | undefined"; +const arrayPrefix = "Array<"; +const arraySuffix = ">"; +const mapPrefix = "{ [key: string]: "; +const mapSuffix = "; }"; + export class ObjectSerializer { public static findCorrectType(data: any, expectedType: string) { if (data == undefined) { @@ -93,20 +110,35 @@ export class ObjectSerializer { } } - public static serialize(data: any, type: string) { + public static serialize(data: any, type: string): any { if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (endsWith(type, nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.serialize(data, subType); + } else if (endsWith(type, optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.serialize(data, subType); + } else if (startsWith(type, arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let index = 0; index < data.length; index++) { let datum = data[index]; transformedData.push(ObjectSerializer.serialize(datum, subType)); } return transformedData; + } else if (startsWith(type, mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.serialize( + data[key], + subType, + ); + } + return transformedData; } else if (type === "Date") { return data.toISOString(); } else { @@ -131,22 +163,37 @@ export class ObjectSerializer { } } - public static deserialize(data: any, type: string) { + public static deserialize(data: any, type: string): any { // polymorphism may change the actual type. type = ObjectSerializer.findCorrectType(data, type); if (data == undefined) { return data; } else if (primitives.indexOf(type.toLowerCase()) !== -1) { return data; - } else if (type.lastIndexOf("Array<", 0) === 0) { // string.startsWith pre es6 - let subType: string = type.replace("Array<", ""); // Array => Type> - subType = subType.substring(0, subType.length - 1); // Type> => Type + } else if (endsWith(type, nullableSuffix)) { + let subType: string = type.slice(0, -nullableSuffix.length); // Type | null => Type + return ObjectSerializer.deserialize(data, subType); + } else if (endsWith(type, optionalSuffix)) { + let subType: string = type.slice(0, -optionalSuffix.length); // Type | undefined => Type + return ObjectSerializer.deserialize(data, subType); + } else if (startsWith(type, arrayPrefix)) { + let subType: string = type.slice(arrayPrefix.length, -arraySuffix.length); // Array => Type let transformedData: any[] = []; for (let index = 0; index < data.length; index++) { let datum = data[index]; transformedData.push(ObjectSerializer.deserialize(datum, subType)); } return transformedData; + } else if (startsWith(type, mapPrefix)) { + let subType: string = type.slice(mapPrefix.length, -mapSuffix.length); // { [key: string]: Type; } => Type + let transformedData: { [key: string]: any } = {}; + for (let key in data) { + transformedData[key] = ObjectSerializer.deserialize( + data[key], + subType, + ); + } + return transformedData; } else if (type === "Date") { return new Date(data); } else {