|
| 1 | +Version Management Changes |
| 2 | +========================== |
| 3 | + |
| 4 | +This document describes the changes to version management in the vCon library, including the removal of mandatory version enforcement and the optional nature of the version field. |
| 5 | + |
| 6 | +Overview |
| 7 | +-------- |
| 8 | + |
| 9 | +Starting with version 0.7.0, the vCon library has simplified version management by making the version field optional and removing automatic version enforcement. This aligns with the latest vCon specification changes and provides more flexibility for users. |
| 10 | + |
| 11 | +Key Changes |
| 12 | +----------- |
| 13 | + |
| 14 | +### Version Field is Now Optional |
| 15 | + |
| 16 | +The ``vcon`` field in vCon objects is no longer required: |
| 17 | + |
| 18 | +- New vCon objects created with ``Vcon.build_new()`` do not include a version field by default |
| 19 | +- Existing vCon objects with version fields continue to work unchanged |
| 20 | +- The version field can be manually added if needed |
| 21 | + |
| 22 | +### Removed Version Management Parameters |
| 23 | + |
| 24 | +The following parameters have been removed from all Vcon methods: |
| 25 | + |
| 26 | +- ``strict_version`` parameter removed from: |
| 27 | + - ``Vcon.__init__()`` |
| 28 | + - ``Vcon.build_from_json()`` |
| 29 | + - ``Vcon.build_new()`` |
| 30 | + - ``Vcon.load()`` |
| 31 | + - ``Vcon.load_from_file()`` |
| 32 | + - ``Vcon.load_from_url()`` |
| 33 | + |
| 34 | +### Updated Method Signatures |
| 35 | + |
| 36 | +All method signatures have been updated to remove version management: |
| 37 | + |
| 38 | +.. code-block:: python |
| 39 | +
|
| 40 | + # Old signatures (no longer supported) |
| 41 | + Vcon(vcon_dict=None, strict_version=True) |
| 42 | + Vcon.build_new(created_at=None, strict_version=True) |
| 43 | + Vcon.build_from_json(json_str, strict_version=True) |
| 44 | + Vcon.load(source, strict_version=True) |
| 45 | +
|
| 46 | + # New signatures |
| 47 | + Vcon(vcon_dict=None, property_handling="default") |
| 48 | + Vcon.build_new(created_at=None, property_handling="default") |
| 49 | + Vcon.build_from_json(json_str, property_handling="default") |
| 50 | + Vcon.load(source, property_handling="default") |
| 51 | +
|
| 52 | +Migration Guide |
| 53 | +--------------- |
| 54 | + |
| 55 | +### For Existing Code |
| 56 | + |
| 57 | +If you were using the ``strict_version`` parameter, simply remove it: |
| 58 | + |
| 59 | +.. code-block:: python |
| 60 | +
|
| 61 | + # Old code (will cause errors) |
| 62 | + vcon = Vcon.load("file.json", strict_version=True) |
| 63 | + vcon = Vcon.build_from_json(json_str, strict_version=True) |
| 64 | + vcon = Vcon(data, strict_version=True) |
| 65 | +
|
| 66 | + # New code (remove strict_version parameter) |
| 67 | + vcon = Vcon.load("file.json") |
| 68 | + vcon = Vcon.build_from_json(json_str) |
| 69 | + vcon = Vcon(data) |
| 70 | +
|
| 71 | +### For Version Field Handling |
| 72 | + |
| 73 | +The version field is now optional. You can choose to: |
| 74 | + |
| 75 | +1. **Ignore version fields** (recommended for new code): |
| 76 | + - Simply don't set or check version fields |
| 77 | + - The library will work without them |
| 78 | + |
| 79 | +2. **Manually manage version fields** (if needed): |
| 80 | + - Add version fields manually when creating vCon objects |
| 81 | + - Check version fields in your application logic |
| 82 | + |
| 83 | +.. code-block:: python |
| 84 | +
|
| 85 | + # Option 1: Ignore version fields (recommended) |
| 86 | + vcon = Vcon.build_new() |
| 87 | + # vcon.vcon will be None |
| 88 | +
|
| 89 | + # Option 2: Manually add version field if needed |
| 90 | + vcon = Vcon.build_new() |
| 91 | + vcon.vcon_dict["vcon"] = "0.3.0" |
| 92 | + # vcon.vcon will be "0.3.0" |
| 93 | +
|
| 94 | +### Backward Compatibility |
| 95 | + |
| 96 | +All changes are backward compatible: |
| 97 | + |
| 98 | +- Existing vCon objects with version fields continue to work |
| 99 | +- The ``vcon`` property returns the version field if present, or ``None`` if not |
| 100 | +- No breaking changes to existing functionality |
| 101 | + |
| 102 | +Examples |
| 103 | +-------- |
| 104 | + |
| 105 | +### Creating Versionless vCons |
| 106 | + |
| 107 | +.. code-block:: python |
| 108 | +
|
| 109 | + from vcon import Vcon |
| 110 | +
|
| 111 | + # Create a new vCon without version field |
| 112 | + vcon = Vcon.build_new() |
| 113 | + print(vcon.vcon) # None |
| 114 | +
|
| 115 | + # Add version field manually if needed |
| 116 | + vcon.vcon_dict["vcon"] = "0.3.0" |
| 117 | + print(vcon.vcon) # "0.3.0" |
| 118 | +
|
| 119 | +### Working with Existing vCons |
| 120 | + |
| 121 | +.. code-block:: python |
| 122 | +
|
| 123 | + # Load existing vCon (with or without version field) |
| 124 | + vcon = Vcon.load("existing.vcon.json") |
| 125 | +
|
| 126 | + # Check if version field exists |
| 127 | + if vcon.vcon: |
| 128 | + print(f"Version: {vcon.vcon}") |
| 129 | + else: |
| 130 | + print("No version field") |
| 131 | +
|
| 132 | +### Validation Changes |
| 133 | + |
| 134 | +The validation logic has been updated to reflect the optional nature of the version field: |
| 135 | + |
| 136 | +.. code-block:: python |
| 137 | +
|
| 138 | + # Validation no longer requires version field |
| 139 | + is_valid, errors = vcon.is_valid() |
| 140 | + |
| 141 | + # Only uuid and created_at are required fields |
| 142 | + # Version field is optional and not validated |
| 143 | +
|
| 144 | +Benefits |
| 145 | +-------- |
| 146 | + |
| 147 | +The simplified version management provides several benefits: |
| 148 | + |
| 149 | +1. **Reduced Complexity**: No need to manage version parameters |
| 150 | +2. **More Flexibility**: Version fields are optional and can be added as needed |
| 151 | +3. **Better Interoperability**: Works with vCon objects from different sources |
| 152 | +4. **Simplified API**: Cleaner method signatures without version management |
| 153 | +5. **Future-Proof**: Aligns with evolving vCon specification |
| 154 | + |
| 155 | +Troubleshooting |
| 156 | +-------------- |
| 157 | + |
| 158 | +### Common Issues |
| 159 | + |
| 160 | +1. **"strict_version" parameter errors**: |
| 161 | + - Remove the ``strict_version`` parameter from all method calls |
| 162 | + - Update method signatures to use ``property_handling`` instead |
| 163 | + |
| 164 | +2. **Version field not found**: |
| 165 | + - Check if the vCon object has a version field: ``vcon.vcon is not None`` |
| 166 | + - Add version field manually if needed: ``vcon.vcon_dict["vcon"] = "0.3.0"`` |
| 167 | + |
| 168 | +3. **Validation errors**: |
| 169 | + - Ensure required fields (uuid, created_at) are present |
| 170 | + - Version field is no longer required for validation |
| 171 | + |
| 172 | +### Getting Help |
| 173 | + |
| 174 | +If you encounter issues with the version management changes: |
| 175 | + |
| 176 | +1. Check the migration guide above |
| 177 | +2. Review the changelog for detailed changes |
| 178 | +3. Test with the updated method signatures |
| 179 | +4. Ensure backward compatibility with existing vCon objects |
0 commit comments