Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with @default Tag in Latest Nestia Version and Swagger Generation #1063

Open
ohjiwan-oj opened this issue Oct 10, 2024 · 0 comments
Open

Comments

@ohjiwan-oj
Copy link

ohjiwan-oj commented Oct 10, 2024

Describe the bug

In previous versions, the `@default tag was successfully converted to the default value in Swagger. However, it seems that in the latest version, this conversion is no longer working.

export interface ICreateUserRequestDto {
  /**
   * User's email address
   * 
   * @pattern [a-zA-Z0-9@.]+$
   * @maxLength 320
   * @default [email protected]
   * 
   */
  email: string;

  /**
   * Social network service type
   * 
   * @default KAKA
   */
  snsType: SnsType;

  /**
   * Social network service ID
   *
   * @default 1234567890
   */
  snsId: string;
}

After writing the code as above and generating the swagger.json file using the nestia swagger command, the default fields are no longer appearing in the latest version.

"ICreateUserRequestDto": {
    "type": "object",
    "properties": {
      "email": {
        "type": "string",
        "maxLength": 320,
        "pattern": "[a-zA-Z0-9@.]+$",
        "default": "[email protected]",
        "description": "User's email address"
      },

I spent over five hours trying to find the cause in the code. When I reverted to the previous working version, 5.3.0, the default fields like "default": "[email protected]" were correctly generated.

Has the `@default tag functionality been removed in the new version, or is this a bug?

Expected behavior

I expected the `@default tag to be converted in the Swagger documentation, with the expected default values included for each field

"ICreateUserRequestDto": {
    "type": "object",
    "properties": {
      "email": {
        "type": "string",
        "maxLength": 320,
        "pattern": "[a-zA-Z0-9@.]+$",
        "description": "User's email address"
      },
      "snsType": {
        "type": "string",
        "enum": [
          "APPLE",
          "GOOGLE",
          "KAKAO"
        ],
        "description": "Social network service type"
      },
      "snsId": {
        "type": "string",
        "description": "Social network service ID"
      }
    },
    "nullable": false,
    "required": [
      "email",
      "snsType",
      "snsId"
    ],
    "description": "User creation request DTO"
  }

Actual behavior

The `@default tag is not being converted in the Swagger documentation, and the default values are not included for any of the fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant