Skip to content

Commit

Permalink
- Upgraded dependencies
Browse files Browse the repository at this point in the history
- Removed depricated enum model generation
- Fixed issue with "null" value inside comments for OpenAPI v2 enums
- Fixed issue with compatibility for latest version of Axios (0.27.x)
  • Loading branch information
ferdikoomen committed Apr 26, 2022
1 parent 33c1ff5 commit 59254d9
Show file tree
Hide file tree
Showing 11 changed files with 3,261 additions and 3,152 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Changelog
All notable changes to this project will be documented in this file.

## [0.22.0] - 2022-04-26
### Fixed
- Upgraded dependencies
- Fixed issue with `null` value inside comments for OpenAPI v2 enums
- Fixed issue with compatibility for latest version of Axios (0.27.x)
### Removed
- Removed deprecated enum model generation

## [0.21.0] - 2022-04-06
### Fixed
- Return `undefined` to match `noImplicitReturns` rule
Expand Down
6,091 changes: 3,195 additions & 2,896 deletions package-lock.json

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openapi-typescript-codegen",
"version": "0.21.0",
"version": "0.22.0",
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
"author": "Ferdi Koomen",
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",
Expand Down Expand Up @@ -60,63 +60,63 @@
},
"dependencies": {
"camelcase": "^6.3.0",
"commander": "^9.0.0",
"commander": "^9.2.0",
"handlebars": "^4.7.7",
"json-schema-ref-parser": "^9.0.9"
},
"devDependencies": {
"@angular-devkit/build-angular": "13.2.5",
"@angular/animations": "13.2.4",
"@angular/cli": "13.2.5",
"@angular/common": "13.2.4",
"@angular/compiler": "13.2.4",
"@angular/compiler-cli": "13.2.4",
"@angular/core": "13.2.4",
"@angular/forms": "13.2.4",
"@angular/platform-browser": "13.2.4",
"@angular/platform-browser-dynamic": "13.2.4",
"@angular/router": "13.2.4",
"@angular-devkit/build-angular": "13.3.3",
"@angular/animations": "13.3.4",
"@angular/cli": "13.3.3",
"@angular/common": "13.3.4",
"@angular/compiler": "13.3.4",
"@angular/compiler-cli": "13.3.4",
"@angular/core": "13.3.4",
"@angular/forms": "13.3.4",
"@angular/platform-browser": "13.3.4",
"@angular/platform-browser-dynamic": "13.3.4",
"@angular/router": "13.3.4",
"@babel/cli": "7.17.6",
"@babel/core": "7.17.8",
"@babel/core": "7.17.9",
"@babel/preset-env": "7.16.11",
"@babel/preset-typescript": "7.16.7",
"@rollup/plugin-commonjs": "21.0.3",
"@rollup/plugin-node-resolve": "13.1.3",
"@rollup/plugin-typescript": "8.3.1",
"@rollup/plugin-commonjs": "22.0.0",
"@rollup/plugin-node-resolve": "13.2.1",
"@rollup/plugin-typescript": "8.3.2",
"@types/cross-spawn": "6.0.2",
"@types/express": "4.17.13",
"@types/glob": "7.2.0",
"@types/jest": "27.4.1",
"@types/node": "17.0.21",
"@types/node": "17.0.27",
"@types/node-fetch": "2.6.1",
"@types/qs": "6.9.7",
"@typescript-eslint/eslint-plugin": "5.18.0",
"@typescript-eslint/parser": "5.17.0",
"@typescript-eslint/eslint-plugin": "5.21.0",
"@typescript-eslint/parser": "5.21.0",
"abort-controller": "3.0.0",
"axios": "0.26.1",
"axios": "0.27.1",
"codecov": "3.8.3",
"cross-spawn": "7.0.3",
"eslint": "8.10.0",
"eslint": "8.14.0",
"eslint-config-prettier": "8.5.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"express": "4.17.3",
"express": "4.18.0",
"form-data": "4.0.0",
"glob": "7.2.0",
"jest": "27.5.1",
"jest-cli": "27.5.1",
"glob": "8.0.1",
"jest": "28.0.1",
"jest-cli": "28.0.1",
"node-fetch": "2.6.7",
"prettier": "2.5.1",
"puppeteer": "13.5.2",
"prettier": "2.6.2",
"puppeteer": "13.6.0",
"qs": "6.10.3",
"rimraf": "3.0.2",
"rollup": "2.68.0",
"rollup": "2.70.2",
"rollup-plugin-node-externals": "4.0.0",
"rollup-plugin-terser": "7.0.2",
"rxjs": "7.5.5",
"ts-node": "10.5.0",
"tslib": "2.3.1",
"typescript": "4.5.5",
"zone.js": "0.11.4"
"ts-node": "10.7.0",
"tslib": "2.4.0",
"typescript": "4.6.3",
"zone.js": "0.11.5"
}
}
2 changes: 1 addition & 1 deletion src/openApi/v2/parser/extendEnum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const extendEnum = (enumerators: Enum[], definition: WithEnumExtension):

return enumerators.map((enumerator, index) => ({
name: names?.[index] || enumerator.name,
description: JSON.stringify(descriptions?.[index] || enumerator.description),
description: descriptions?.[index] || enumerator.description,
value: enumerator.value,
type: enumerator.type,
}));
Expand Down
39 changes: 0 additions & 39 deletions src/openApi/v2/parser/getEnumFromDescription.ts

This file was deleted.

12 changes: 0 additions & 12 deletions src/openApi/v2/parser/getModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { extendEnum } from './extendEnum';
import { getEnum } from './getEnum';
import { getEnumFromDescription } from './getEnumFromDescription';
import { getModelComposition } from './getModelComposition';
import { getModelProperties } from './getModelProperties';
import { getType } from './getType';
Expand Down Expand Up @@ -69,17 +68,6 @@ export const getModel = (
}
}

if ((definition.type === 'int' || definition.type === 'integer') && definition.description) {
const enumerators = getEnumFromDescription(definition.description);
if (enumerators.length) {
model.export = 'enum';
model.type = 'number';
model.base = 'number';
model.enum.push(...enumerators);
return model;
}
}

if (definition.type === 'array' && definition.items) {
if (definition.items.$ref) {
const arrayItems = getType(definition.items.$ref);
Expand Down
13 changes: 0 additions & 13 deletions src/openApi/v2/parser/getOperationParameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { OpenApiParameter } from '../interfaces/OpenApiParameter';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { extendEnum } from './extendEnum';
import { getEnum } from './getEnum';
import { getEnumFromDescription } from './getEnumFromDescription';
import { getModel } from './getModel';
import { getOperationParameterDefault } from './getOperationParameterDefault';
import { getOperationParameterName } from './getOperationParameterName';
Expand Down Expand Up @@ -70,18 +69,6 @@ export const getOperationParameter = (openApi: OpenApi, parameter: OpenApiParame
}
}

if ((parameter.type === 'int' || parameter.type === 'integer') && parameter.description) {
const enumerators = getEnumFromDescription(parameter.description);
if (enumerators.length) {
operationParameter.export = 'enum';
operationParameter.type = 'number';
operationParameter.base = 'number';
operationParameter.enum.push(...enumerators);
operationParameter.default = getOperationParameterDefault(parameter, operationParameter);
return operationParameter;
}
}

if (parameter.type === 'array' && parameter.items) {
const items = getType(parameter.items.type, parameter.items.format);
operationParameter.export = 'array';
Expand Down
39 changes: 0 additions & 39 deletions src/openApi/v3/parser/getEnumFromDescription.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/openApi/v3/parser/getModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { OpenApi } from '../interfaces/OpenApi';
import type { OpenApiSchema } from '../interfaces/OpenApiSchema';
import { extendEnum } from './extendEnum';
import { getEnum } from './getEnum';
import { getEnumFromDescription } from './getEnumFromDescription';
import { getModelComposition } from './getModelComposition';
import { getModelDefault } from './getModelDefault';
import { getModelProperties } from './getModelProperties';
Expand Down Expand Up @@ -72,18 +71,6 @@ export const getModel = (
}
}

if ((definition.type === 'int' || definition.type === 'integer') && definition.description) {
const enumerators = getEnumFromDescription(definition.description);
if (enumerators.length) {
model.export = 'enum';
model.type = 'number';
model.base = 'number';
model.enum.push(...enumerators);
model.default = getModelDefault(definition, model);
return model;
}
}

if (definition.type === 'array' && definition.items) {
if (definition.items.$ref) {
const arrayItems = getType(definition.items.$ref);
Expand Down
2 changes: 1 addition & 1 deletion src/templates/core/axios/sendRequest.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const sendRequest = async <T>(
try {
return await axios.request(requestConfig);
} catch (error) {
const axiosError = error as AxiosError;
const axiosError = error as AxiosError<T>;
if (axiosError.response) {
return axiosError.response;
}
Expand Down
Loading

0 comments on commit 59254d9

Please sign in to comment.