Skip to content

Commit 335ff8c

Browse files
committed
updating openapi spec to try and improve template dto type
1 parent 6a29ab2 commit 335ff8c

File tree

2 files changed

+146
-34
lines changed

2 files changed

+146
-34
lines changed

infrastructure/terraform/modules/backend-api/spec.tmpl.json

Lines changed: 121 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -781,50 +781,143 @@
781781
"TemplateDto": {
782782
"type": "object",
783783
"oneOf": [
784-
785-
],
786-
"allOf": [
787784
{
788-
"$ref": "#/components/schemas/BaseTemplate"
785+
"allOf": [
786+
{
787+
"$ref": "#/components/schemas/BaseTemplate"
788+
},
789+
{
790+
"type": "object",
791+
"required": [
792+
"id",
793+
"templateStatus",
794+
"createdAt",
795+
"updatedAt"
796+
],
797+
"properties": {
798+
"id": {
799+
"type": "string"
800+
},
801+
"templateStatus": {
802+
"$ref": "#/components/schemas/TemplateStatus"
803+
},
804+
"createdAt": {
805+
"type": "string",
806+
"format": "date-time"
807+
},
808+
"updatedAt": {
809+
"type": "string",
810+
"format": "date-time"
811+
}
812+
}
813+
},
814+
{
815+
"$ref": "#/components/schemas/LetterProperties"
816+
}
817+
]
789818
},
790819
{
791-
"type": "object",
792-
"required": [
793-
"id",
794-
"templateStatus",
795-
"createdAt",
796-
"updatedAt"
797-
],
798-
"properties": {
799-
"id": {
800-
"type": "string"
801-
},
802-
"templateStatus": {
803-
"$ref": "#/components/schemas/TemplateStatus"
820+
"allOf": [
821+
{
822+
"$ref": "#/components/schemas/BaseTemplate"
804823
},
805-
"createdAt": {
806-
"type": "string",
807-
"format": "date-time"
824+
{
825+
"type": "object",
826+
"required": [
827+
"id",
828+
"templateStatus",
829+
"createdAt",
830+
"updatedAt"
831+
],
832+
"properties": {
833+
"id": {
834+
"type": "string"
835+
},
836+
"templateStatus": {
837+
"$ref": "#/components/schemas/TemplateStatus"
838+
},
839+
"createdAt": {
840+
"type": "string",
841+
"format": "date-time"
842+
},
843+
"updatedAt": {
844+
"type": "string",
845+
"format": "date-time"
846+
}
847+
}
808848
},
809-
"updatedAt": {
810-
"type": "string",
811-
"format": "date-time"
849+
{
850+
"$ref": "#/components/schemas/NhsAppProperties"
812851
}
813-
}
852+
]
814853
},
815854
{
816-
"oneOf": [
855+
"allOf": [
817856
{
818-
"$ref": "#/components/schemas/NhsAppProperties"
857+
"$ref": "#/components/schemas/BaseTemplate"
819858
},
820859
{
821-
"$ref": "#/components/schemas/EmailProperties"
860+
"type": "object",
861+
"required": [
862+
"id",
863+
"templateStatus",
864+
"createdAt",
865+
"updatedAt"
866+
],
867+
"properties": {
868+
"id": {
869+
"type": "string"
870+
},
871+
"templateStatus": {
872+
"$ref": "#/components/schemas/TemplateStatus"
873+
},
874+
"createdAt": {
875+
"type": "string",
876+
"format": "date-time"
877+
},
878+
"updatedAt": {
879+
"type": "string",
880+
"format": "date-time"
881+
}
882+
}
822883
},
823884
{
824885
"$ref": "#/components/schemas/SmsProperties"
886+
}
887+
]
888+
},
889+
{
890+
"allOf": [
891+
{
892+
"$ref": "#/components/schemas/BaseTemplate"
825893
},
826894
{
827-
"$ref": "#/components/schemas/LetterProperties"
895+
"type": "object",
896+
"required": [
897+
"id",
898+
"templateStatus",
899+
"createdAt",
900+
"updatedAt"
901+
],
902+
"properties": {
903+
"id": {
904+
"type": "string"
905+
},
906+
"templateStatus": {
907+
"$ref": "#/components/schemas/TemplateStatus"
908+
},
909+
"createdAt": {
910+
"type": "string",
911+
"format": "date-time"
912+
},
913+
"updatedAt": {
914+
"type": "string",
915+
"format": "date-time"
916+
}
917+
}
918+
},
919+
{
920+
"$ref": "#/components/schemas/EmailProperties"
828921
}
829922
]
830923
}

lambdas/backend-client/src/types/generated/types.gen.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,31 @@ export type CreateUpdateTemplate = BaseTemplate &
9494
| CreateUpdateLetterProperties
9595
);
9696

97-
export type TemplateDto = BaseTemplate & {
98-
id: string;
99-
templateStatus: TemplateStatus;
100-
createdAt: string;
101-
updatedAt: string;
102-
} & (NhsAppProperties | EmailProperties | SmsProperties | LetterProperties);
97+
export type TemplateDto =
98+
| (BaseTemplate & {
99+
id: string;
100+
templateStatus: TemplateStatus;
101+
createdAt: string;
102+
updatedAt: string;
103+
} & LetterProperties)
104+
| (BaseTemplate & {
105+
id: string;
106+
templateStatus: TemplateStatus;
107+
createdAt: string;
108+
updatedAt: string;
109+
} & NhsAppProperties)
110+
| (BaseTemplate & {
111+
id: string;
112+
templateStatus: TemplateStatus;
113+
createdAt: string;
114+
updatedAt: string;
115+
} & SmsProperties)
116+
| (BaseTemplate & {
117+
id: string;
118+
templateStatus: TemplateStatus;
119+
createdAt: string;
120+
updatedAt: string;
121+
} & EmailProperties);
103122

104123
export type Success = {
105124
template: TemplateDto;

0 commit comments

Comments
 (0)