openapi3: remove StringMap and its pre-OriginTree origin-stripping machinery#20
Open
reuvenharrison wants to merge 5 commits into
Open
openapi3: remove StringMap and its pre-OriginTree origin-stripping machinery#20reuvenharrison wants to merge 5 commits into
reuvenharrison wants to merge 5 commits into
Conversation
The OriginTree rewrite (getkin#1142) moved origin tracking to a separate pass that extracts __origin__ before JSON conversion, so no unmarshaler sees it anymore (the 'if k == originKey' blocks were removed then; TestOrigin_* asserts __origin__ never appears as a map key). Three delete(map, originKey) calls -- Encoding, Webhooks, Server.Variables -- and the StringMap doc comment were missed by that cleanup. Remove the dead deletes and the now-unused originKey const, and correct the StringMap comment: it is a generic map[string]V, and no longer filters origin from the json representation. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqJA1X6suZYtR3tRbX8sLj
The two-step decode (json -> map[string]any -> deepCast back into V, iterating sorted keys via componentNames) existed to strip __origin__ and control ordering before the OriginTree rewrite (getkin#1142). Post-rewrite there is no __origin__ in the json and the result is an (unordered) map, so it is equivalent to a plain json.Unmarshal -- verified by the full suite. The round-trip also forced every value's numbers through float64; a direct decode avoids that precision risk. Decode straight into the map and drop the now-unused deepCast. componentNames stays (still used for deterministic validation ordering). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqJA1X6suZYtR3tRbX8sLj
StringMap[V] was a map[string]V whose only custom behavior was the two-step origin-aware decode, now gone (the previous commit made it a plain json.Unmarshal). Its two fields decode identically as plain maps -- the same json.Unmarshal target -- so use map[string]MappingRef (Discriminator.Mapping) and map[string]string (OAuthFlow.Scopes) directly and drop the type. The unmarshalStringMap/P helpers stay; other map types still call them. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqJA1X6suZYtR3tRbX8sLj
… UnmarshalJSON With deepCast/componentNames gone from the decode, unmarshalStringMap and unmarshalStringMapP are plain json.Unmarshal wrappers, and the 13 named map types that called them from a custom UnmarshalJSON were pure pass-throughs. Remove those UnmarshalJSON methods so the types decode via default map unmarshalling (identical result), and delete the now-unused helpers (stringmap.go). None of the types have a MarshalJSON, so marshalling was already default -- the change stays symmetric. The existing TestOrigin_* assertions confirm __origin__ still never leaks into these maps. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqJA1X6suZYtR3tRbX8sLj
…elog Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BqJA1X6suZYtR3tRbX8sLj
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.
The OriginTree rewrite (getkin#1142) moved origin tracking to a separate pass that extracts
__origin__before JSON conversion, so no unmarshaler sees it anymore. A whole family ofStringMap/ origin-stripping machinery was left behind. This removes it end to end.Commits
delete(map, originKey)calls (Encoding,Webhooks,Server.Variables), the now-unusedoriginKeyconst, and the staleStringMapdoc comment. (TestOrigin_*already assert__origin__never appears as a map key.)json -> map[string]any -> deepCast -> V(sorted keys) existed to strip__origin__and control ordering; post-rewrite it equals a plainjson.Unmarshal. DropdeepCast— also removes afloat64round-trip precision risk on large integers.Discriminator.Mapping->map[string]MappingRef,OAuthFlow.Scopes->map[string]string.unmarshalStringMap/unmarshalStringMapPare now trivialjson.Unmarshalwrappers, and the 13 named map types that called them from a customUnmarshalJSONwere pure pass-throughs. Remove those methods so the types decode via default map unmarshalling (identical result), and delete the helpers (none of the types have aMarshalJSON, so marshalling was already default).docs.sh) and add the changelog entry.Notes
openapi3.StringMap[V]type. The one known downstream consumer (oasdiff) needs a one-line signature change (mappingToStringMap->map[string]openapi3.MappingRef), which is backward-compatible with the current release. Recorded in the README changelog.openapi3suite green, and oasdiff's full suite passes when wired to this branch via a localreplace.