File tree Expand file tree Collapse file tree 2 files changed +13
-10
lines changed
airbyte-webapp/src/core/jsonSchema Expand file tree Collapse file tree 2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -138,9 +138,10 @@ test("should build schema for conditional case with inner schema and selected ui
138
138
} ,
139
139
} ,
140
140
} ,
141
- { "key .credentials" : { selectedItem : "oauth" } } ,
141
+ { "topKey.subKey .credentials" : { selectedItem : "oauth" } } ,
142
142
undefined ,
143
- "key"
143
+ "topKey" ,
144
+ "topKey.subKey"
144
145
) ;
145
146
146
147
const expectedSchema = yup . object ( ) . shape ( {
Original file line number Diff line number Diff line change @@ -34,20 +34,22 @@ export const buildYupFormForJsonSchema = (
34
34
| null = null ;
35
35
36
36
if ( jsonSchema . oneOf && uiConfig && propertyPath ) {
37
- const selectedSchema =
38
- jsonSchema . oneOf . find ( ( condition ) => {
39
- if ( typeof condition !== "boolean" ) {
40
- return uiConfig [ propertyPath ] ?. selectedItem === condition . title ;
41
- }
42
- return false ;
43
- } ) ?? jsonSchema . oneOf [ 0 ] ;
37
+ let selectedSchema = jsonSchema . oneOf . find (
38
+ ( condition ) =>
39
+ typeof condition !== "boolean" &&
40
+ uiConfig [ propertyPath ] ?. selectedItem === condition . title
41
+ ) ;
42
+
43
+ // Select first oneOf path if no item selected
44
+ selectedSchema = selectedSchema ?? jsonSchema . oneOf [ 0 ] ;
45
+
44
46
if ( selectedSchema && typeof selectedSchema !== "boolean" ) {
45
47
return buildYupFormForJsonSchema (
46
48
{ type : jsonSchema . type , ...selectedSchema } ,
47
49
uiConfig ,
48
50
jsonSchema ,
49
51
propertyKey ,
50
- propertyPath ? ` ${ propertyPath } . ${ propertyKey } ` : propertyKey
52
+ propertyPath
51
53
) ;
52
54
}
53
55
}
You can’t perform that action at this time.
0 commit comments