Skip to content

Releases: VKCOM/api-schema-typescript-generator

v0.14.0

12 Aug 10:25
Compare
Choose a tag to compare

Features

  • Generate constants with API Errors (#41)
  • Format generated code with Prettier (#31)

v0.13.2

15 Jul 11:38
Compare
Choose a tag to compare

Fixes

  • Quotes for properties with - (dash)

v0.13.1

25 Feb 15:54
Compare
Choose a tag to compare

Fixes

  • Empty object type (#19)

v0.12.0

28 Jul 07:25
Compare
Choose a tag to compare

Fixes

  • Prefer ref instead of type (#29)

v0.11.0

20 Jul 16:05
Compare
Choose a tag to compare

Fixes

  • Method JSON parameters ref

Refactor

  • Move method normalization to pure function

v0.10.0

08 Jul 09:54
Compare
Choose a tag to compare

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

07 Apr 19:54
Compare
Choose a tag to compare

Fixes

  • Fix enum values generation inside nested arrays.

v0.8.0

07 Apr 19:53
Compare
Choose a tag to compare

Fixes

  • Import fs promises correctly

v0.7.0

15 Mar 09:55
Compare
Choose a tag to compare

Fixes

  • Fix SchemaObject creation error message.
  • Skip broken responses generation

v0.6.0

18 Feb 09:25
Compare
Choose a tag to compare

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';
}