Skip to content

Simplify extensions merge in mergeOpenapiSchemas#1424

Merged
jamietanna merged 1 commit into
oapi-codegen:masterfrom
Juneezee:master
May 18, 2024
Merged

Simplify extensions merge in mergeOpenapiSchemas#1424
jamietanna merged 1 commit into
oapi-codegen:masterfrom
Juneezee:master

Conversation

@Juneezee

@Juneezee Juneezee commented Jan 12, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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 <[email protected]>
@Juneezee

Juneezee commented May 5, 2024

Copy link
Copy Markdown
Contributor Author

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

@jamietanna jamietanna added the chore Any maintenance tasks that are regular, not as important to call out in the changelog label May 5, 2024
@jamietanna jamietanna added this to the v2.2.0 milestone May 5, 2024

@jamietanna jamietanna left a comment

Copy link
Copy Markdown
Member

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Any maintenance tasks that are regular, not as important to call out in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants