Skip to content

Commit 91a480b

Browse files
kusiewiczibex088
andauthored
fix: managed user api playground (time format transform) (calcom#24255)
* fix: managed user time format transform * feat: add transform decorator to handle null/undefined timeFormat values in UpdateManagedUserInput --------- Co-authored-by: chauhan_s <somaychauhan98@gmail.com>
1 parent db19bb3 commit 91a480b

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

apps/api/v2/src/modules/users/inputs/create-managed-user.input.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Locales } from "@/lib/enums/locales";
22
import { CapitalizeTimeZone } from "@/lib/inputs/capitalize-timezone";
33
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
4-
import { Transform } from "class-transformer";
5-
import { IsOptional, IsTimeZone, IsString, IsEnum, IsIn, IsUrl, IsObject } from "class-validator";
4+
import { Transform, Type } from "class-transformer";
5+
import { IsOptional, IsTimeZone, IsString, IsEnum, IsIn, IsUrl, IsObject, IsNumber } from "class-validator";
66

77
import { ValidateMetadata } from "@calcom/platform-types";
88

@@ -17,6 +17,8 @@ export class CreateManagedUserInput {
1717
@ApiProperty({ example: "Alice Smith", description: "Managed user's name is used in emails" })
1818
name!: string;
1919

20+
@Type(() => Number)
21+
@IsNumber()
2022
@IsOptional()
2123
@IsIn([12, 24], { message: "timeFormat must be a number either 12 or 24" })
2224
@ApiPropertyOptional({ example: 12, enum: [12, 24], description: "Must be a number 12 or 24" })

apps/api/v2/src/modules/users/inputs/update-managed-user.input.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Locales } from "@/lib/enums/locales";
22
import { CapitalizeTimeZone } from "@/lib/inputs/capitalize-timezone";
33
import { TimeFormat, WeekDay } from "@/modules/users/inputs/create-managed-user.input";
44
import { ApiPropertyOptional } from "@nestjs/swagger";
5+
import { Transform, Type } from "class-transformer";
56
import { IsEnum, IsIn, IsNumber, IsObject, IsOptional, IsString, IsTimeZone, IsUrl } from "class-validator";
67

78
import { ValidateMetadata } from "@calcom/platform-types";
@@ -17,6 +18,8 @@ export class UpdateManagedUserInput {
1718
@ApiPropertyOptional()
1819
name?: string;
1920

21+
@Type(() => Number)
22+
@IsNumber()
2023
@IsOptional()
2124
@IsIn([12, 24])
2225
@ApiPropertyOptional({ example: 12, enum: [12, 24], description: "Must be 12 or 24" })

docs/api-reference/v2/openapi.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17241,6 +17241,20 @@
1724117241
},
1724217242
"required": ["type", "slug", "label", "required", "placeholder", "hidden", "isDefault"]
1724317243
},
17244+
"BookerActiveBookingsLimitOutput_2024_06_14": {
17245+
"type": "object",
17246+
"properties": {
17247+
"maximumActiveBookings": {
17248+
"type": "number",
17249+
"description": "The maximum number of active bookings a booker can have for this event type.",
17250+
"example": 3
17251+
},
17252+
"offerReschedule": {
17253+
"type": "boolean",
17254+
"description": "Whether to offer rescheduling the last active booking to the chosen time slot when limit is reached."
17255+
}
17256+
}
17257+
},
1724417258
"EventTypeOutput_2024_06_14": {
1724517259
"type": "object",
1724617260
"properties": {
@@ -17428,7 +17442,7 @@
1742817442
"type": "object"
1742917443
},
1743017444
"bookerActiveBookingsLimit": {
17431-
"$ref": "#/components/schemas/BookerActiveBookingsLimit_2024_06_14"
17445+
"$ref": "#/components/schemas/BookerActiveBookingsLimitOutput_2024_06_14"
1743217446
},
1743317447
"onlyShowFirstAvailableSlot": {
1743417448
"type": "boolean"
@@ -19729,7 +19743,7 @@
1972919743
"type": "object"
1973019744
},
1973119745
"bookerActiveBookingsLimit": {
19732-
"$ref": "#/components/schemas/BookerActiveBookingsLimit_2024_06_14"
19746+
"$ref": "#/components/schemas/BookerActiveBookingsLimitOutput_2024_06_14"
1973319747
},
1973419748
"onlyShowFirstAvailableSlot": {
1973519749
"type": "boolean"

0 commit comments

Comments
 (0)