Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify extensions merge in mergeOpenapiSchemas #1424

Merged
merged 1 commit into from
May 18, 2024

Conversation

Juneezee
Copy link
Contributor

@Juneezee Juneezee commented Jan 12, 2024

From the Go specification 1:

"3. If the map is nil, the number of iterations is 0."

Therefore, we don't need the nil checks for merging the Extensions. Just like how we did for Properties:

https://github.com/deepmap/oapi-codegen/blob/66f9bb8d73111908bb20d30bae90e65eb49a6770/pkg/codegen/merge_schemas.go#L202-L210

Footnotes

  1. https://go.dev/ref/spec#For_range

@jamietanna
Copy link
Member

Thanks @Juneezee! Would you mind merging the latest changes into your branch, also so CI can pick it up? I'm not sure I'll be able to as you're on your master branch.

More info

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 <engzerjun@gmail.com>
@Juneezee
Copy link
Contributor Author

Juneezee commented May 5, 2024

@jamietanna I just rebased the latest changes. Please take a look again. Thanks 😃 !

@jamietanna jamietanna added this to the v2.2.0 milestone May 5, 2024
Copy link
Member

@jamietanna jamietanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jamietanna jamietanna merged commit bf8962d into oapi-codegen:master May 18, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants