Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Parameter order fix#136

Merged
tangiel merged 4 commits intomasterfrom
parameter-order-fix
Feb 16, 2018
Merged

Parameter order fix#136
tangiel merged 4 commits intomasterfrom
parameter-order-fix

Conversation

@tangiel
Copy link
Contributor

@tangiel tangiel commented Feb 16, 2018

No description provided.

@tangiel tangiel requested a review from inklesspen February 16, 2018 19:04
private List<String> computeParameterOrder(ApiMethodConfig methodConfig) {
ImmutableSortedSet.Builder<String> queryParamBuilder = ImmutableSortedSet.naturalOrder();
Collection<String> pathParameters = methodConfig.getPathParameters();
List<String> order = new ArrayList<>(pathParameters);

Choose a reason for hiding this comment

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

Why not use an ImmutableList here too?

Choose a reason for hiding this comment

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

Also, since order is not used in the loop, consider moving it below the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not used because we have to clone the whole discovery doc at times, and immutable structures are not cloneable. And done.

@tangiel tangiel force-pushed the parameter-order-fix branch from b485a03 to 220465e Compare February 16, 2018 19:30
To match the legacy parameterOrder, this change does the following:

* optional query parameters are removed from parameterOrder
* required query parameters are appended, sorted alphabetically, to
  the path parameters

There is also a small optimization to call
methodConfig.getPathParameters less frequently, as it is a relatively
expensive call.
@tangiel tangiel force-pushed the parameter-order-fix branch from 3f125c8 to 182d104 Compare February 16, 2018 19:38
getPathParameter was using a HashSet, when a LinkedHashSet preserves
the path ordering of the returned parameters.
@codecov-io
Copy link

codecov-io commented Feb 16, 2018

Codecov Report

Merging #136 into master will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #136      +/-   ##
============================================
+ Coverage     79.84%   79.91%   +0.06%     
- Complexity     1661     1668       +7     
============================================
  Files           156      156              
  Lines          5568     5580      +12     
  Branches        716      719       +3     
============================================
+ Hits           4446     4459      +13     
  Misses          843      843              
+ Partials        279      278       -1
Impacted Files Coverage Δ Complexity Δ
...e/api/server/spi/discovery/DiscoveryGenerator.java 88.42% <100%> (+0.68%) 58 <5> (+6) ⬆️
...e/api/server/spi/config/model/ApiMethodConfig.java 87.93% <100%> (ø) 70 <0> (ø) ⬇️
.../server/spi/discovery/CommonPathPrefixBuilder.java 100% <0%> (+5.55%) 9% <0%> (+1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecc216f...f0f7648. Read the comment docs.

@tangiel tangiel merged commit 968f420 into master Feb 16, 2018
@tangiel tangiel deleted the parameter-order-fix branch February 16, 2018 20:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants