[api_generator] API path builder update #913
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Handling of more complex sets of URLs.
Previously, the api_generator assumed that all URL paths of the same
x-operation-group
shared the same static components (i.e. if you remove all{path_param}
components in each path, the paths are identical):For example these 4 paths of the
nodes.stats
group have an identical set of static components of_nodes
andstats
And the generator would build the path as
However this assumption not true for some operation groups like
cluster.stats
:Notice that the first 3 paths have
_cluster
,stats
andnodes
as their static components while the last one only has_cluster
andstats
. Therefore the following path that the generator use to make is incorrect:because when none of the path params are provided, we would end up with
const path = '/_cluster/states/nodes'
, which is not a valid path. With this PR, the generator will be able to detect this edge case and generate a more complex path building strategy forcluster.stats
:Streamlined path building code
The generated path building logic for operation groups with uniform static path components is now simpler and more performant. Here are a few examples of old vs new code:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.