Repository navigation
fix(spec): define network zone asns/locations as arrays instead of allOf wrappers - #601
Open
BinoyOza-okta wants to merge 1 commit into
Open
BinoyOza-okta wants to merge 1 commit into
BinoyOza-okta wants to merge 1 commit into
Conversation
…lOf wrappers Replace the `allOf: [$ref: <array schema>, description: ...]` wrappers on the network zone `asns` and `locations` fields in `openapi/api.yaml` with inline array definitions: - DynamicNetworkZone: asns, locations - EnhancedDynamicNetworkZone: asns.include, asns.exclude, locations.include, locations.exclude Root cause: OpenAPI Generator 7.7.0 treats an allOf wrapper around an array $ref as a new object type. It generated six empty, field-less models (e.g. EnhancedDynamicNetworkZoneAllOfAsnsInclude), so any list returned by the API, including an empty one, raised a pydantic ValidationError. A single DYNAMIC or DYNAMIC_V2 zone with ASNs or locations was enough to fail the whole list_network_zones() call. The inline definitions keep the original descriptions. The fields now generate as Optional[List[StrictStr]] and Optional[List[NetworkZoneLocation]]. - Regenerated the affected models and docs. - Removed the six obsolete wrapper models, their docs, and their DOC_GUIDE.md links. - Added tests/test_network_zone_arrays.py (48 tests). The on-wire JSON shape is unchanged. This is a spec-accuracy fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
ValidationErrorinlist_network_zones()for Dynamic and Enhanced Dynamic zonesSummary
Fixes a Pydantic
ValidationErrorraised byNetworkZoneApi.list_network_zones()andget_network_zone()when a response contains aDYNAMICorDYNAMIC_V2zone withasnsorlocationsvalues. This includes the empty list[]the API returns for Enhanced Dynamic zones with no ASNs configured.Problem
Because a single bad zone fails deserialization, the whole paginated list call fails.
Root cause
openapi/api.yamldeclared these fields by wrapping an array schema inallOf:OpenAPI Generator 7.7.0 treats this wrapper as a new object type, so it generated empty models with no fields instead of
List[...]. Pydantic correctly rejects a list for an object type. This isn't caused by Pydantic v2 strictness or by empty lists: populated lists fail too, and the empty models would drop the data anyway.The pattern appeared in 6 places:
DynamicNetworkZoneasnsDynamicNetworkZoneAllOfAsnsList[StrictStr]DynamicNetworkZonelocationsDynamicNetworkZoneAllOfLocationsList[NetworkZoneLocation]EnhancedDynamicNetworkZoneAllOfAsnsinclude/exclude...AsnsInclude/...AsnsExcludeList[StrictStr]EnhancedDynamicNetworkZoneAllOfLocationsinclude/exclude...LocationsInclude/...LocationsExcludeList[NetworkZoneLocation]IP zones (
gateways/proxies) are not affected.Changes
openapi/api.yaml: replaced the 6allOfwrappers with inline array definitions. Descriptions are kept, andmaximum: 75/nullable: trueare copied from the referenced components.dynamic_network_zone.py,enhanced_dynamic_network_zone_all_of_asns.py,enhanced_dynamic_network_zone_all_of_locations.py, their docs, and the lazy import maps inokta/__init__.pyandokta/models/__init__.py.okta/DOC_GUIDE.md.tests/test_network_zone_arrays.py.Breaking change note
The 6 wrapper classes are removed (
DynamicNetworkZoneAllOfAsns,DynamicNetworkZoneAllOfLocations,EnhancedDynamicNetworkZoneAllOf{Asns,Locations}{Include,Exclude}).They had no fields and could never hold data, so no working code could have depended on them. The on-wire JSON shape is unchanged.
Testing
tests/test_network_zone_arrays.py: 48 tests covering empty, populated, and null payloads, discrimination throughNetworkZone.from_dict,to_dict/ JSON round trips,_links,proxyTypevalidation, and regression guards for the removed models.elsebranches for dict-valued nested fields, which can't be reached with Pydantic v2 validation on.