Return a mapping for the schema of a single field.
(field_instance)
| 69 | } |
| 70 | |
| 71 | def jsonschema_for_single_field(field_instance): |
| 72 | """ |
| 73 | Return a mapping for the schema of a single field. |
| 74 | """ |
| 75 | field_schema = {} |
| 76 | |
| 77 | field_schema["type"] = SCHEMATIC_TYPE_TO_JSON_TYPE.get( |
| 78 | field_instance.__class__.__name__, "string" |
| 79 | ) |
| 80 | |
| 81 | if hasattr(field_instance, "metadata"): |
| 82 | field_schema["title"] = field_instance.metadata.get("label", "") |
| 83 | field_schema["description"] = field_instance.metadata.get("description", "") |
| 84 | |
| 85 | for js_key, schematic_key in schema_kwargs_to_schematics.items(): |
| 86 | value = getattr(field_instance, schematic_key, None) |
| 87 | if value is not None: |
| 88 | field_schema[js_key] = value |
| 89 | |
| 90 | return field_schema |
| 91 | |
| 92 | def jsonschema_for_fields(model): |
| 93 | """ |
no test coverage detected