Releases: VKCOM/api-schema-typescript-generator
Releases · VKCOM/api-schema-typescript-generator
v0.14.0
v0.13.2
Fixes
- Quotes for properties with
-
(dash)
v0.13.1
v0.12.0
v0.11.0
Fixes
- Method JSON parameters ref
Refactor
- Move method normalization to pure function
v0.10.0
Breaking Changes
The library no longer generates TypeScript enums in favor of union types.
Before:
export enum UsersUserRelation {
NOT_SPECIFIED = 0,
SINGLE = 1,
IN_A_RELATIONSHIP = 2,
ENGAGED = 3,
MARRIED = 4,
COMPLICATED = 5,
ACTIVELY_SEARCHING = 6,
IN_LOVE = 7,
IN_A_CIVIL_UNION = 8,
}
After:
export const UsersUserRelationEnumNames = {
NOT_SPECIFIED: 0,
SINGLE: 1,
IN_A_RELATIONSHIP: 2,
ENGAGED: 3,
MARRIED: 4,
COMPLICATED: 5,
ACTIVELY_SEARCHING: 6,
IN_LOVE: 7,
IN_A_CIVIL_UNION: 8,
} as const;
/**
* @note This enum have auto-generated constant with keys and values
* @see UsersUserRelationEnumNames
*
* `0` — not specified
* `1` — single
* `2` — in a relationship
* `3` — engaged
* `4` — married
* `5` — complicated
* `6` — actively searching
* `7` — in love
* `8` — in a civil union
*/
export type UsersUserRelation = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;
All numeric JSON Schema enums have auto-generated constants with keys and values. This constants allows to use not magic numbers in code, but some understandable values.
/* What `5` means? */
if (relation === 5) {}
/* Looks better */
if (relation === UsersUserRelation.COMPLICATED) {}
v0.9.0
Fixes
- Fix enum values generation inside nested arrays.
v0.8.0
Fixes
- Import fs promises correctly
v0.7.0
Fixes
- Fix SchemaObject creation error message.
- Skip broken responses generation
v0.6.0
Features
- Export
API_VERSION
constant.
Fixes
- Trim cli methods array arg.
Breaking changes
Before now the generator created TypeScript enum
types for properties with inline-descriptive enum values. Now it will be generated as union type with the constant, which can be imported to project.
JSON Schema:
{
"users_online_info": {
"type": "object",
"properties": {
"status": {
"type": "string",
"description": "In case user online is not visible, it indicates approximate timeframe of user online",
"enum": [
"recently",
"last_week",
"last_month",
"long_ago",
"not_show"
]
}
},
"required": [
"visible"
]
}
}
Before:
// users_online_info status enum
export enum UsersOnlineInfoStatusEnum {
RECENTLY = 'recently',
LAST_WEEK = 'last_week',
LAST_MONTH = 'last_month',
LONG_AGO = 'long_ago',
NOT_SHOW = 'not_show',
}
// users_online_info
export interface UsersOnlineInfo {
/**
* In case user online is not visible, it indicates approximate timeframe of user online
*/
status?: UsersOnlineInfoStatusEnum;
}
After:
// users_online_info status enumNames
export const UsersOnlineInfoStatusEnumNames = {
RECENTLY: 'recently',
LAST_WEEK: 'last_week',
LAST_MONTH: 'last_month',
LONG_AGO: 'long_ago',
NOT_SHOW: 'not_show',
} as const;
// users_online_info
export interface UsersOnlineInfo {
/**
* In case user online is not visible, it indicates approximate timeframe of user online
*/
status?: 'recently' | 'last_week' | 'last_month' | 'long_ago' | 'not_show';
}