-
Notifications
You must be signed in to change notification settings - Fork 125
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
Retain operation level parameters over path level ones #183
Retain operation level parameters over path level ones #183
Conversation
Sources/_OpenAPIGeneratorCore/Translator/Operations/OperationDescription.swift
Outdated
Show resolved
Hide resolved
Sources/_OpenAPIGeneratorCore/Translator/Operations/OperationDescription.swift
Outdated
Show resolved
Hide resolved
Sources/_OpenAPIGeneratorCore/Translator/Operations/OperationDescription.swift
Outdated
Show resolved
Hide resolved
The change looks good, just a few minor style suggestions. For testing, you can create a new unit test file |
Co-authored-by: Honza Dvorsky <[email protected]>
Thank you for the nice review, I applied all suggestions! 🙂 |
Tests/OpenAPIGeneratorCoreTests/Translator/Operations/Test_OperationDescription.swift
Show resolved
Hide resolved
@swift-server-bot add to allowlist |
2b36abd
to
3a5b182
Compare
Tests/OpenAPIGeneratorCoreTests/Translator/Operations/Test_OperationDescription.swift
Outdated
Show resolved
Hide resolved
Tests/OpenAPIGeneratorCoreTests/Translator/Operations/Test_OperationDescription.swift
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just two more comments about the tests, otherwise looks great!
87c823d
to
a0d04b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
Motivation
Fixes #168.
Modifications
Previously, an operation's parameters were returned as a concatenation of the parameters from the path item level with those at operation level.
However, this is incorrect according to https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#fixed-fields-7.
With this change, we are merging the two arrays of parameters using a unique identifier of the location + name of parameters. If duplicate parameters exist, only the parameters from the operation level are preserved.
Result
After this change, an operation's parameters won't contain any duplicate.
Test Plan
Add tests for
OperationDescription.allParameters
atTests/OpenAPIGeneratorCoreTests/Translator/Operations/Test_OperationDescription.swift
.