ng-swagger-gen icon indicating copy to clipboard operation
ng-swagger-gen copied to clipboard

Bug generate models with numbers

Open kaiserdj opened this issue 4 years ago • 2 comments

Hi,

When generating an api in which an object has an element with a number at the beginning, it is generated wrong Example:

"Account": {
      "type": "object",
      "properties": {
        "user_id": {
          "type": "integer"
        },
        "profile": {
          "$ref": "#/definitions/UserProfile"
        },
        "email_confirmed": {
          "type": "boolean"
        },
        "2fa_enabled": {
          "type": "boolean",
          "description": "Indicates that Two Factor Authentication (2FA) is enabled for this account"
        },
      }
    },

Results:

/* tslint:disable */
import { UserProfile } from './user-profile';
export interface Account {

  /**
   * Indicates that Two Factor Authentication (2FA) is enabled for this account
   */
  2fa_enabled?: boolean;
  profile?: UserProfile;
  user_id?: number;
}

Surrounding 2fa_enabled with double quotes solves the problem: 2fa_enabled -> "2fa_enabled"

Thanks a lot

kaiserdj avatar May 17 '21 12:05 kaiserdj

image

kaiserdj avatar May 17 '21 12:05 kaiserdj

Sorry, I don't really have any more time to maintain this project. Help is appreciated.

luisfpg avatar Jul 16 '21 13:07 luisfpg