Skip to content

Commit

Permalink
fix: Fix schedule rule naming conflict
Browse files Browse the repository at this point in the history
Having same nested objects naming caused a naming conflict in swagger.
  • Loading branch information
LuukvH committed Sep 8, 2024
1 parent d02aba6 commit 6d2c95f
Show file tree
Hide file tree
Showing 18 changed files with 731 additions and 306 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using MediatR;
using System.Collections.Generic;

namespace KDVManager.Services.Scheduling.Application.Features.Schedules.Commands.AddSchedule;

public class AddScheduleCommand : IRequest<Guid>
Expand All @@ -15,9 +14,9 @@ public class AddScheduleCommand : IRequest<Guid>
public DateTime? EndDate { get; set; }

// Collection of nested schedules
public ICollection<ScheduleRule> ScheduleRules { get; set; } = new List<ScheduleRule>();
public ICollection<AddScheduleCommandScheduleRule> ScheduleRules { get; set; } = new List<AddScheduleCommandScheduleRule>();

public class ScheduleRule
public class AddScheduleCommandScheduleRule
{
public DayOfWeek Day { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class ChildScheduleListVM
public DateTime? EndDate { get; set; }

// Collection of nested schedules
public ICollection<ScheduleRule> ScheduleRules { get; set; } = new List<ScheduleRule>();
public ICollection<ChildScheduleListVMScheduleRule> ScheduleRules { get; set; } = new List<ChildScheduleListVMScheduleRule>();

public class ScheduleRule
public class ChildScheduleListVMScheduleRule
{
public DayOfWeek Day { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public MappingProfile()
// Schedule Mappings
CreateMap<AddScheduleCommand, Schedule>()
.ForMember(dest => dest.ScheduleRules, opt => opt.MapFrom(src => src.ScheduleRules));
CreateMap<AddScheduleCommand.ScheduleRule, ScheduleRule>();
CreateMap<AddScheduleCommand.AddScheduleCommandScheduleRule, ScheduleRule>();

CreateMap<Schedule, ChildScheduleListVM>()
.ForMember(dest => dest.ScheduleRules, opt => opt.MapFrom(src => src.ScheduleRules));
CreateMap<ScheduleRule, ChildScheduleListVM.ScheduleRule>();
CreateMap<ScheduleRule, ChildScheduleListVM.ChildScheduleListVMScheduleRule>();
}
}

1 change: 1 addition & 0 deletions src/web/orval.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const queryPaginated = {
mutator: useMutatorFetchPaginated,
query: {
useQuery: true,
useInfiniteQueryParam: "PageNumber",
},
};

Expand Down
116 changes: 70 additions & 46 deletions src/web/output.openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,10 @@
}
}
},
"/scheduling/v1/scheduleitems": {
"/scheduling/v1/schedules": {
"get": {
"tags": ["ScheduleItems"],
"operationId": "ListScheduleItems",
"tags": ["Schedules"],
"operationId": "GetChildSchedules",
"parameters": [
{
"name": "ChildId",
Expand All @@ -507,23 +507,23 @@
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ScheduleItemListVM"
"$ref": "#/components/schemas/ChildScheduleListVM"
}
}
},
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ScheduleItemListVM"
"$ref": "#/components/schemas/ChildScheduleListVM"
}
}
},
"text/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ScheduleItemListVM"
"$ref": "#/components/schemas/ChildScheduleListVM"
}
}
}
Expand All @@ -532,23 +532,23 @@
}
},
"post": {
"tags": ["ScheduleItems"],
"operationId": "AddScheduleItem",
"tags": ["Schedules"],
"operationId": "AddSchedule",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AddScheduleItemCommand"
"$ref": "#/components/schemas/AddScheduleCommand"
}
},
"text/json": {
"schema": {
"$ref": "#/components/schemas/AddScheduleItemCommand"
"$ref": "#/components/schemas/AddScheduleCommand"
}
},
"application/*+json": {
"schema": {
"$ref": "#/components/schemas/AddScheduleItemCommand"
"$ref": "#/components/schemas/AddScheduleCommand"
}
}
}
Expand Down Expand Up @@ -912,7 +912,7 @@
},
"additionalProperties": false
},
"AddScheduleItemCommand": {
"AddScheduleCommand": {
"type": "object",
"properties": {
"childId": {
Expand All @@ -932,16 +932,29 @@
"format": "date-time",
"nullable": true
},
"schedules": {
"scheduleRules": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Schedule"
"$ref": "#/components/schemas/AddScheduleCommandScheduleRule"
},
"nullable": true
}
},
"additionalProperties": false
},
"AddScheduleCommandScheduleRule": {
"type": "object",
"properties": {
"day": {
"$ref": "#/components/schemas/DayOfWeek"
},
"timeSlotId": {
"type": "string",
"format": "uuid"
}
},
"additionalProperties": false
},
"AddTimeSlotCommand": {
"type": "object",
"properties": {
Expand All @@ -960,6 +973,49 @@
},
"additionalProperties": false
},
"ChildScheduleListVM": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"childId": {
"type": "string",
"format": "uuid"
},
"startDate": {
"type": "string",
"format": "date-time"
},
"endDate": {
"type": "string",
"format": "date-time",
"nullable": true
},
"scheduleRules": {
"type": "array",
"items": {
"$ref": "#/components/schemas/ChildScheduleListVMScheduleRule"
},
"nullable": true
}
},
"additionalProperties": false
},
"ChildScheduleListVMScheduleRule": {
"type": "object",
"properties": {
"day": {
"$ref": "#/components/schemas/DayOfWeek"
},
"timeSlotId": {
"type": "string",
"format": "uuid"
}
},
"additionalProperties": false
},
"DayOfWeek": {
"enum": [0, 1, 2, 3, 4, 5, 6],
"type": "integer",
Expand Down Expand Up @@ -1006,38 +1062,6 @@
},
"additionalProperties": {}
},
"Schedule": {
"type": "object",
"properties": {
"day": {
"$ref": "#/components/schemas/DayOfWeek"
}
},
"additionalProperties": false
},
"ScheduleItemListVM": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"childId": {
"type": "string",
"format": "uuid"
},
"startDate": {
"type": "string",
"format": "date-time"
},
"endDate": {
"type": "string",
"format": "date-time",
"nullable": true
}
},
"additionalProperties": false
},
"TimeSlotListVM": {
"type": "object",
"properties": {
Expand Down
2 changes: 1 addition & 1 deletion src/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"api:generate": "orval --clean",
"api:merge": "openapi-merge-cli --config ./openapi-merge.json",
"start": "vite",
"build": "tsc -b && vite build",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint",
"lint:fix": "eslint --fix",
Expand Down
Loading

0 comments on commit 6d2c95f

Please sign in to comment.