@@ -3,23 +3,40 @@ import { DesignDefinitionV1Beta1OpenApiSchema } from '@meshery/schemas';
33// eslint-disable-next-line @typescript-eslint/no-explicit-any
44const DesignSchema = ( DesignDefinitionV1Beta1OpenApiSchema as any ) . components . schemas ;
55
6+ // In @meshery /schemas >= 1.1.0, MesheryPatternImportRequestBody is a
7+ // `oneOf` union of a File-import variant and a URL-import variant rather than
8+ // a flat properties object. Resolve the individual field shapes from the
9+ // dedicated payload components so the form schema remains driven by the
10+ // upstream API contract.
11+ // See meshery/schemas commit b08a4f62 "fix(design): tighten
12+ // MesheryPatternImportRequestBody to oneOf[File|URL]".
13+ const ImportBody = DesignSchema . MesheryPatternImportRequestBody ;
14+ const FilePayload = DesignSchema . MesheryPatternImportFilePayload ;
15+ const URLPayload = DesignSchema . MesheryPatternImportURLPayload ;
16+
17+ // `name` is a common field present on both variants; File is used as the
18+ // canonical source.
19+ const nameField = FilePayload . properties . name ;
20+ const fileField = FilePayload . properties . file ;
21+ const urlField = URLPayload . properties . url ;
22+
623const importDesignSchema = {
724 type : 'object' ,
825 properties : {
926 name : {
10- type : DesignSchema . MesheryPatternImportRequestBody . properties . name . type ,
27+ type : nameField . type ,
1128 title : 'Design file name' ,
12- default : DesignSchema . MesheryPatternImportRequestBody . properties . name . default ,
29+ default : nameField . default ,
1330 'x-rjsf-grid-area' : '12' ,
14- description : DesignSchema . MesheryPatternImportRequestBody . properties . name . description
31+ description : nameField . description
1532 } ,
1633
1734 uploadType : {
1835 title : 'Upload method' ,
1936 enum : [ 'File Upload' , 'URL Import' ] ,
2037 default : 'URL Import' ,
2138 'x-rjsf-grid-area' : '12' ,
22- description : DesignSchema . MesheryPatternImportRequestBody . description
39+ description : ImportBody . description
2340 }
2441 } ,
2542
@@ -35,9 +52,9 @@ const importDesignSchema = {
3552 then : {
3653 properties : {
3754 file : {
38- type : DesignSchema . MesheryPatternImportRequestBody . properties . file . type ,
39- format : DesignSchema . MesheryPatternImportRequestBody . properties . file . format ,
40- description : DesignSchema . MesheryPatternImportRequestBody . properties . file . description ,
55+ type : fileField . type ,
56+ format : fileField . format ,
57+ description : fileField . description ,
4158 'x-rjsf-grid-area' : '12'
4259 }
4360 } ,
@@ -55,10 +72,10 @@ const importDesignSchema = {
5572 then : {
5673 properties : {
5774 url : {
58- type : DesignSchema . MesheryPatternImportRequestBody . properties . url . type ,
59- format : DesignSchema . MesheryPatternImportRequestBody . properties . url . format ,
75+ type : urlField . type ,
76+ format : urlField . format ,
6077 title : 'URL' ,
61- description : DesignSchema . MesheryPatternImportRequestBody . properties . url . description ,
78+ description : urlField . description ,
6279 'x-rjsf-grid-area' : '12'
6380 }
6481 } ,
0 commit comments