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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Juneezee
Copy link

@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:

// We merge all properties
result.Properties = make(map[string]*openapi3.SchemaRef)
for k, v := range s1.Properties {
result.Properties[k] = v
}
for k, v := range s2.Properties {
// TODO: detect conflicts
result.Properties[k] = v
}

Footnotes

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

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

Successfully merging this pull request may close these issues.

None yet

1 participant