Skip to content

Commit 54ac62d

Browse files
committed
Add x-size-message annotations to OpenAPI schemas to provide custom validation error messages for required fields.
1 parent bbcff48 commit 54ac62d

File tree

6 files changed

+50
-1
lines changed

6 files changed

+50
-1
lines changed

api/src/integrationTest/kotlin/com/cosmotech/api/home/organization/OrganizationConstants.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ object OrganizationConstants {
3030

3131
object Errors {
3232
val emptyNameOrganizationCreationRequestError =
33-
"""{"type":"https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400","title":"Bad Request","status":400,"detail":"name: size must be between 1 and 2147483647","instance":"/organizations"}"""
33+
"""{"type":"https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400","title":"Bad Request","status":400,"detail":"name: cannot be empty","instance":"/organizations"}"""
3434
}
3535
}

dataset/src/main/openapi/dataset.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ components:
780780
name:
781781
type: string
782782
x-field-extra-annotation: "@com.redis.om.spring.annotations.Searchable"
783+
x-size-message: "cannot be empty"
783784
minLength: 1
784785
description:
785786
type: string
@@ -837,6 +838,7 @@ components:
837838
name:
838839
type: string
839840
minLength: 1
841+
x-size-message: "cannot be empty"
840842
description:
841843
type: string
842844
tags:
@@ -865,6 +867,7 @@ components:
865867
name:
866868
type: string
867869
minLength: 1
870+
x-size-message: "cannot be empty"
868871
description:
869872
type: string
870873
tags:
@@ -894,10 +897,12 @@ components:
894897
type: string
895898
x-field-extra-annotation: "@com.redis.om.spring.annotations.Searchable"
896899
minLength: 1
900+
x-size-message: "cannot be empty"
897901
sourceName:
898902
type: string
899903
description: the source data name (e.g. filename associated to the dataset part)
900904
minLength: 1
905+
x-size-message: "cannot be empty"
901906
description:
902907
type: string
903908
tags:
@@ -953,10 +958,12 @@ components:
953958
name:
954959
type: string
955960
minLength: 1
961+
x-size-message: "cannot be empty"
956962
sourceName:
957963
description: the source data name (e.g. filename associated to the dataset part)
958964
type: string
959965
minLength: 1
966+
x-size-message: "cannot be empty"
960967
description:
961968
type: string
962969
tags:
@@ -982,6 +989,7 @@ components:
982989
description: the source data name (e.g. filename associated to the dataset part)
983990
type: string
984991
minLength: 1
992+
x-size-message: "cannot be empty"
985993
description:
986994
type: string
987995
tags:

organization/src/main/openapi/organization.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ components:
526526
x-field-extra-annotation: "@com.redis.om.spring.annotations.Searchable"
527527
description: The Organization name
528528
minLength: 1
529+
x-size-message: "cannot be empty"
529530
security:
530531
$ref: '#/components/schemas/OrganizationSecurity'
531532
required:
@@ -539,6 +540,7 @@ components:
539540
type: string
540541
description: The Organization name
541542
minLength: 1
543+
x-size-message: "cannot be empty"
542544

543545
# Security Operation Schemas
544546
OrganizationSecurity:

runner/src/main/openapi/runner.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ components:
654654
type: string
655655
description: the Runner name
656656
minLength: 1
657+
x-size-message: "cannot be empty"
657658
description:
658659
type: string
659660
description: the Runner description
@@ -676,6 +677,7 @@ components:
676677
type: string
677678
description: the Solution Run Template Id associated with this Runner
678679
minLength: 1
680+
x-size-message: "cannot be empty"
679681
datasetList:
680682
type: array
681683
description: the list of Dataset Id associated to this Runner Run Template
@@ -699,10 +701,12 @@ components:
699701
type: string
700702
description: the Solution name
701703
minLength: 1
704+
x-size-message: "cannot be empty"
702705
runTemplateName:
703706
type: string
704707
description: the Solution Run Template name associated with this Runner
705708
minLength: 1
709+
x-size-message: "cannot be empty"
706710
security:
707711
$ref: '#/components/schemas/RunnerSecurity'
708712
required:
@@ -718,6 +722,7 @@ components:
718722
type: string
719723
description: the Runner name
720724
minLength: 1
725+
x-size-message: "cannot be empty"
721726
description:
722727
type: string
723728
description: the Runner description
@@ -730,6 +735,7 @@ components:
730735
type: string
731736
description: the Solution Run Template Id associated with this Runner
732737
minLength: 1
738+
x-size-message: "cannot be empty"
733739
datasetList:
734740
type: array
735741
description: the list of Dataset Id associated to this Runner Run Template
@@ -751,10 +757,12 @@ components:
751757
type: string
752758
description: the Solution name
753759
minLength: 1
760+
x-size-message: "cannot be empty"
754761
runTemplateName:
755762
type: string
756763
description: the Solution Run Template name associated with this Runner
757764
minLength: 1
765+
x-size-message: "cannot be empty"
758766
RunnerSecurity:
759767
type: object
760768
description: the Runner security information

solution/src/main/openapi/solution.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ components:
789789
required: true
790790
schema:
791791
type: string
792+
x-size-message: "cannot be empty"
792793
fileName:
793794
name: file_name
794795
in: query
@@ -833,12 +834,14 @@ components:
833834
type: string
834835
description: The Solution key which groups Solution versions
835836
minLength: 1
837+
x-size-message: "cannot be empty"
836838
example: "brewery-solution"
837839
name:
838840
type: string
839841
x-field-extra-annotation: "@com.redis.om.spring.annotations.Searchable"
840842
description: The Solution name
841843
minLength: 1
844+
x-size-message: "cannot be empty"
842845
example: "Brewery Solution"
843846
description:
844847
type: string
@@ -848,6 +851,7 @@ components:
848851
type: string
849852
description: The registry repository containing the image
850853
minLength: 1
854+
x-size-message: "cannot be empty"
851855
example: "cosmotech/brewery_solution"
852856
alwaysPull:
853857
type: boolean
@@ -857,6 +861,7 @@ components:
857861
type: string
858862
description: The Solution version MAJOR.MINOR.PATCH. Must be aligned with an existing repository tag
859863
minLength: 1
864+
x-size-message: "cannot be empty"
860865
example: "1.0.0"
861866
createInfo:
862867
description: The details of the Solution creation
@@ -923,11 +928,13 @@ components:
923928
type: string
924929
description: Technical key for resource name convention and version grouping. Must be unique
925930
minLength: 1
931+
x-size-message: "cannot be empty"
926932
example: "brewery-solution"
927933
name:
928934
type: string
929935
description: Solution name. This name is displayed in the sample webApp
930936
minLength: 1
937+
x-size-message: "cannot be empty"
931938
example: "Brewery Solution"
932939
description:
933940
type: string
@@ -937,11 +944,13 @@ components:
937944
type: string
938945
description: The registry repository containing the image
939946
minLength: 1
947+
x-size-message: "cannot be empty"
940948
example: "cosmotech/brewery_solution"
941949
version:
942950
type: string
943951
description: The Solution version MAJOR.MINOR.PATCH
944952
minLength: 1
953+
x-size-message: "cannot be empty"
945954
example: "1.0.0"
946955
alwaysPull:
947956
type: boolean
@@ -991,11 +1000,13 @@ components:
9911000
type: string
9921001
description: Technical key for resource name convention and version grouping. Must be unique
9931002
minLength: 1
1003+
x-size-message: "cannot be empty"
9941004
example: "brewery-solution"
9951005
name:
9961006
type: string
9971007
description: The Solution name
9981008
minLength: 1
1009+
x-size-message: "cannot be empty"
9991010
example: "Brewery Solution"
10001011
description:
10011012
type: string
@@ -1005,6 +1016,7 @@ components:
10051016
type: string
10061017
description: The registry repository containing the image
10071018
minLength: 1
1019+
x-size-message: "cannot be empty"
10081020
example: "cosmotech/brewery_solution"
10091021
alwaysPull:
10101022
type: boolean
@@ -1013,6 +1025,7 @@ components:
10131025
type: string
10141026
description: The Solution version MAJOR.MINOR.PATCH. Must be aligned with an existing repository tag
10151027
minLength: 1
1028+
x-size-message: "cannot be empty"
10161029
example: "1.0.0"
10171030
url:
10181031
type: string
@@ -1097,11 +1110,13 @@ components:
10971110
type: string
10981111
description: The Solution Run Template id
10991112
minLength: 1
1113+
x-size-message: "cannot be empty"
11001114
example: "template-123"
11011115
name:
11021116
type: string
11031117
description: The Run Template name
11041118
minLength: 1
1119+
x-size-message: "cannot be empty"
11051120
labels:
11061121
$ref: '#/components/schemas/TranslatedLabels'
11071122
description:
@@ -1138,11 +1153,13 @@ components:
11381153
type: string
11391154
description: The Solution Run Template id
11401155
minLength: 1
1156+
x-size-message: "cannot be empty"
11411157
example: "template-123"
11421158
name:
11431159
type: string
11441160
description: The Run Template name
11451161
minLength: 1
1162+
x-size-message: "cannot be empty"
11461163
labels:
11471164
$ref: '#/components/schemas/TranslatedLabels'
11481165
description:
@@ -1179,6 +1196,7 @@ components:
11791196
type: string
11801197
description: The Run Template name
11811198
minLength: 1
1199+
x-size-message: "cannot be empty"
11821200
labels:
11831201
$ref: '#/components/schemas/TranslatedLabels'
11841202
description:
@@ -1238,6 +1256,7 @@ components:
12381256
type: string
12391257
description: The Parameter Group id
12401258
minLength: 1
1259+
x-size-message: "cannot be empty"
12411260
description:
12421261
type: string
12431262
description: A description of the parameter group
@@ -1265,6 +1284,7 @@ components:
12651284
type: string
12661285
description: The Parameter Group id
12671286
minLength: 1
1287+
x-size-message: "cannot be empty"
12681288
description:
12691289
type: string
12701290
description: A description of the parameter group
@@ -1313,6 +1333,7 @@ components:
13131333
type: string
13141334
description: The Parameter id
13151335
minLength: 1
1336+
x-size-message: "cannot be empty"
13161337
description:
13171338
type: string
13181339
description: The parameter description
@@ -1322,6 +1343,7 @@ components:
13221343
type: string
13231344
description: The variable type for the parameter. Basic types or special type %DATASETID%
13241345
minLength: 1
1346+
x-size-message: "cannot be empty"
13251347
defaultValue:
13261348
type: string
13271349
description: The default value for this parameter
@@ -1347,6 +1369,7 @@ components:
13471369
type: string
13481370
description: The Parameter id
13491371
minLength: 1
1372+
x-size-message: "cannot be empty"
13501373
description:
13511374
type: string
13521375
description: The parameter description
@@ -1356,6 +1379,7 @@ components:
13561379
type: string
13571380
description: The variable type for the parameter. Basic types or special type %DATASETID%
13581381
minLength: 1
1382+
x-size-message: "cannot be empty"
13591383
defaultValue:
13601384
type: string
13611385
description: The default value for this parameter
@@ -1386,6 +1410,7 @@ components:
13861410
type: string
13871411
description: The variable type for the parameter. Basic types or special type %DATASETID%
13881412
minLength: 1
1413+
x-size-message: "cannot be empty"
13891414
defaultValue:
13901415
type: string
13911416
description: The default value for this parameter

workspace/src/main/openapi/workspace.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,12 +623,14 @@ components:
623623
type: string
624624
description: Technical key for resource name convention and version grouping. Must be unique
625625
minLength: 1
626+
x-size-message: "cannot be empty"
626627
example: "MyKey"
627628
name:
628629
type: string
629630
x-field-extra-annotation: "@com.redis.om.spring.annotations.Searchable"
630631
description: Workspace name. This name is display in the sample webApp
631632
minLength: 1
633+
x-size-message: "cannot be empty"
632634
example: "FranceOffice"
633635
description:
634636
type: string
@@ -684,11 +686,13 @@ components:
684686
type: string
685687
description: Technical key for resource name convention and version grouping. Must be unique
686688
minLength: 1
689+
x-size-message: "cannot be empty"
687690
name:
688691
type: string
689692
description: Workspace name. This name is displayed in the sample webApp
690693
example: "FranceOffice"
691694
minLength: 1
695+
x-size-message: "cannot be empty"
692696
description:
693697
type: string
694698
description: The Workspace description
@@ -726,10 +730,12 @@ components:
726730
type: string
727731
description: Technical key for resource name convention and version grouping. Must be unique
728732
minLength: 1
733+
x-size-message: "cannot be empty"
729734
name:
730735
type: string
731736
description: Workspace name
732737
minLength: 1
738+
x-size-message: "cannot be empty"
733739
description:
734740
type: string
735741
description: The Workspace description

0 commit comments

Comments
 (0)