Repository: vazco/uniforms (ts)

Issue:
Missing `appearance` prop in the documentation for `SelectField`
Looking at the source code, there's an `appearance` property in `SelectField` which is not documented.

Pull request:
Completed SelectField documentation.
Added missing `appearance` prop to SelectField documentation.

Closes #714

Patch:
diff --git a/docs/api-fields.md b/docs/api-fields.md
index fefec9ff..e6319363 100644
--- a/docs/api-fields.md
+++ b/docs/api-fields.md
@@ -125,7 +125,7 @@ A checkbox.
 
 ##### Props:
 
-|       Name        |                                                                               Description                                                                               |                 le in                  |
+|       Name        |                                                                               Description                                                                               |              Available in              |
 | :---------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------: |
 |   `appearance`    |                 Field appearance. Set to "toggle" to appear as a Material Toggle or to "checkbox" (or leave it undefined) to use a Checkbox appearance.                 |                material                |
 |      `extra`      |                                 Extra feedback text. In the antd theme, this renders addtional help text below any validation messages.                                 |                  antd                  |
@@ -563,6 +563,7 @@ import { RadioField } from 'uniforms-unstyled';
 |       Name        |                                                                               Description                                                                               |              Available in              |
 | :---------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------: |
 |  `allowedValues`  |                                               Array of allowed values. By default, those are extracted from your schema.                                                |                  All                   |
+|   `appearance`    |                 Field appearance. Set to "toggle" to appear as a Material Toggle or to "checkbox" (or leave it undefined) to use a Checkbox appearance.                 |                material                |
 |   `checkboxes`    |                                       Turn on checkbox/radio mode. It's always true in mutltiple (i.e. fieldType === Array) mode.                                       |                  All                   |
 |      `extra`      |                                 Extra feedback text. In the antd theme, this renders addtional help text below any validation messages.                                 |                  antd                  |
 |      `help`       |                                                           Help text. _Some description would be great, huh?_                                                            |      antd, bootstrap3, bootstrap4      |
diff --git a/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts b/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts
index 2ea8cc83..0afaf63e 100644
--- a/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts
+++ b/packages/uniforms-bridge-json-schema/src/JSONSchemaBridge.ts
@@ -154,9 +154,14 @@ export default class JSONSchemaBridge extends Bridge {
           'oneOf',
         ]
           .filter(key => definition[key])
-          .map(key =>
-            definition[key].find(({ properties = {} }) => properties[next]),
-          );
+          .map(key => {
+            const localDef = definition[key].map(subSchema =>
+              subSchema.$ref
+                ? resolveRef(subSchema.$ref, this.schema)
+                : subSchema,
+            );
+            return localDef.find(({ properties = {} }) => properties[next]);
+          });
 
         definition = combinedDefinition[next];
       }


Test patch:
diff --git a/packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts b/packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts
index 21e372b3..ebae1dd3 100644
--- a/packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts
+++ b/packages/uniforms-bridge-json-schema/__tests__/JSONSchemaBridge.ts
@@ -369,6 +369,40 @@ describe('JSONSchemaBridge', () => {
         /Field not found in schema/,
       );
     });
+
+    it('throws when resolving field schema is not possible (with allOf with $ref field)', () => {
+      expect(() => bridge.getField('shippingAddress.street.invalid')).toThrow(
+        /Field not found in schema/,
+      );
+    });
+
+    it('throws when resolving field schema is not possible (with allOf with $ref field without properties prop)', () => {
+      const localBridge = new JSONSchemaBridge(
+        {
+          definitions: schema.definitions,
+          properties: {
+            container: {
+              allOf: [
+                {
+                  required: ['type'],
+                },
+              ],
+            },
+          },
+        },
+        validator,
+      );
+
+      expect(() => localBridge.getField('container.invalid')).toThrow(
+        /Field not found in schema/,
+      );
+    });
+
+    it('returns correct definition (allOf with $ref)', () => {
+      expect(bridge.getField('shippingAddress.street')).toEqual({
+        type: 'string',
+      });
+    });
   });
 
   describe('#getInitialValue', () => {