Simplify extensions merge in mergeOpenapiSchemas#1424
Merged
jamietanna merged 1 commit intooapi-codegen:masterfrom May 18, 2024
Juneezee:master
Merged
Simplify extensions merge in mergeOpenapiSchemas#1424jamietanna merged 1 commit intooapi-codegen:masterfrom Juneezee:master
mergeOpenapiSchemas#1424jamietanna merged 1 commit intooapi-codegen:masterfrom
Juneezee:master
Conversation
Member
From the Go specification [1]: "3. If the map is nil, the number of iterations is 0." Therefore, an additional nil check for before the loop is unnecessary. Signed-off-by: Eng Zer Jun <[email protected]>
Contributor
Author
|
@jamietanna I just rebased the latest changes. Please take a look again. Thanks 😃 ! |
jamietanna
approved these changes
May 18, 2024
Member
jamietanna
left a comment
There was a problem hiding this comment.
OK, so it looks like we don't have as good unit test coverage of this as I'd hoped - if I delete this whole block of code, nothing seems to change in generated code, nor do tests fail 😅
I'm happy saying that yes, from review of the changes, this looks good - but in the future (#1617) we should improve this
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.
From the Go specification 1:
Therefore, we don't need the
nilchecks for merging theExtensions. Just like how we did forProperties:https://github.com/deepmap/oapi-codegen/blob/66f9bb8d73111908bb20d30bae90e65eb49a6770/pkg/codegen/merge_schemas.go#L202-L210
Footnotes
https://go.dev/ref/spec#For_range ↩