-
Notifications
You must be signed in to change notification settings - Fork 58
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
Merge OAuth2 scopes #151
Merge OAuth2 scopes #151
Conversation
Makes sense! Thank you for your contribution! |
Can't we rather change the monoid instance of `SecurityScheme`?
…Sent from my iPhone
On 22 Mar 2018, at 18.26, Nickolay Kudasov ***@***.***> wrote:
@fizruk approved this pull request.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@phadej I'm fairly new to this library, I couldn't find the monoid instance of |
@phadej I noticed master does not build with stack, so I guess my PR is not going to build on CI after rebasing. I checked again that there's no instance for
What do you think? I can do everything to just get this merged 😁 |
I'm not a fan of overlapping instances. @fizruk could we rather have |
And thinking again, why it's ok to monoidally combine |
@phadej thx for pointing out the direction. I updated the implementation according to your suggestion |
@@ -1104,6 +1120,9 @@ instance ToJSON PathItem where | |||
instance ToJSON Example where | |||
toJSON = toJSON . Map.mapKeys show . getExample | |||
|
|||
instance ToJSON SecurityDefinitions where |
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.
You can derive these with GeneralizedNewtypeDeriving
.
@phadej are you happy with this change? Should I merge? |
Is there any chance this will be merged one day? |
I've just received commit authority, and I will merge this if (1) nobody objects in time; and (2) you resolve the merge conflict. Thanks! |
Thanks for the heads-up! I will resolve it before next week :) |
Only merge scopes when OAuth2Flow are same
@fisx I have resolved the merge conflict |
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.
I have (silly) remarks, but I will merge this now. Thanks!
|
||
instance Semigroup SecurityDefinitions where | ||
(SecurityDefinitions sd1) <> (SecurityDefinitions sd2) = | ||
SecurityDefinitions $ InsOrdHashMap.unionWith (<>) sd1 sd2 |
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.
(Shouldn't there be an instance Semigroup InsOrdHashMap
? Same for Monoid
?)
SecurityDefinitions $ InsOrdHashMap.unionWith (<>) sd1 sd2 | ||
|
||
instance Monoid SecurityDefinitions where | ||
mempty = SecurityDefinitions $ InsOrdHashMap.empty |
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.
mempty = SecurityDefinitions $ InsOrdHashMap.empty | |
mempty = SecurityDefinitions InsOrdHashMap.empty |
The problem was when merging two swagger doc together, the OAuth2 scopes are not merged together properly because the
Monoid InsOrdMap
has behavior of replacing the value at the same key.The tactical solution is to make a
SwaggerMonoid
overlapping instance for it. It only merges scopes whenSecurityScheme
SecuritySchemeOAuth2