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

Allow setting example paths and queries for DocService #2546

Merged
merged 12 commits into from Mar 10, 2020

Conversation

ikhoon
Copy link
Contributor

@ikhoon ikhoon commented Mar 2, 2020

Motivation:

Currently, a user cannot set example paths and queries. #2195
The endpoint path or queries are only set automatically when
opening a URL that contains endpoint_path or queries as params.

Modifications:

  • Add examplePaths to DocService and DocServiceBuilder
  • Add exampleQueries to DocService and DocServiceBuilder
  • Show examplePath if the endpoint_path is null and the examplePath is not null
  • Show exampleQuery if the queries is null and the exampleQuery is not null
  • Make ENDPOINT PATH input visible with read-only if a path is exact type

Result:
You can now set an example path and queries for DocService
Fixes #2195

Motivation:

Currently, a user cannot set example paths and queries. line#2195
The endpoint path or queries are only set automatically when
sharing a URL that contains `endpoint_path` or `queries` as params.

Modifications:

- Add `examplePaths` to `DocService` and `DocServiceBuilder`
- Add `exampleQueries` to `DocService` and `DocServiceBuilder`
- Show `examplePath` if the `endpoint_path` is null and the `examplePath` is not null
- Show `exampleQuery` if the `queries` is null and the `exampleQuery` is not null
- Make `ENDPOINT PATH` input visible with readonlyif path type is exact

Result:
You can now set an example path and queries for `DocService`
@ikhoon ikhoon added this to the 0.99.0 milestone Mar 2, 2020
@ikhoon
Copy link
Contributor Author

ikhoon commented Mar 2, 2020

/cc @julnamoo

@ikhoon
Copy link
Contributor Author

ikhoon commented Mar 3, 2020

A screenshot of example paths and queries
image

Copy link
Member

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

💯 Thanks, @ikhoon!

@codecov
Copy link

codecov bot commented Mar 4, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@48f4132). Click here to learn what that means.
The diff coverage is 85.52%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #2546   +/-   ##
========================================
  Coverage          ?   73.6%           
  Complexity        ?   10947           
========================================
  Files             ?     956           
  Lines             ?   41917           
  Branches          ?    5248           
========================================
  Hits              ?   30851           
  Misses            ?    8370           
  Partials          ?    2696
Impacted Files Coverage Δ Complexity Δ
...a/com/linecorp/armeria/server/docs/MethodInfo.java 73.61% <100%> (ø) 20 <3> (?)
...ria/internal/server/grpc/GrpcDocServicePlugin.java 88.88% <100%> (ø) 53 <0> (?)
.../com/linecorp/armeria/server/docs/ServiceInfo.java 80.7% <100%> (ø) 21 <0> (?)
...inecorp/armeria/server/docs/DocServiceBuilder.java 75.81% <76.47%> (ø) 46 <9> (?)
...a/com/linecorp/armeria/server/docs/DocService.java 94.21% <76.92%> (ø) 41 <0> (?)

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 48f4132...45826bb. Read the comment docs.

Comment on lines 117 to 118
this.examplePaths = ImmutableList.copyOf(requireNonNull(examplePaths, "examplePaths"));
this.exampleQueries = ImmutableList.copyOf(requireNonNull(exampleQueries, "exampleQueries"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about validating all paths and query strings, using PathAndQuery and QueryParams.fromQueryString()?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not addressed yet.

/**
* Adds the specified example query strings for the method with the specified service and method name.
*/
public DocServiceBuilder exampleQueries(Class<?> serviceType, String methodName, Iterable<String> queries) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

queries -> queryStrings

Comment on lines 117 to 118
this.examplePaths = ImmutableList.copyOf(requireNonNull(examplePaths, "examplePaths"));
this.exampleQueries = ImmutableList.copyOf(requireNonNull(exampleQueries, "exampleQueries"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not addressed yet.

Copy link
Collaborator

@trustin trustin left a comment

Choose a reason for hiding this comment

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

👍 Thanks for your patience!

@trustin trustin changed the title Provide a way to set example paths and queries when building DocService Allow setting example paths and queries for DocService Mar 10, 2020
@trustin trustin merged commit 721f185 into line:master Mar 10, 2020
@ikhoon ikhoon deleted the example-query-n-path branch April 4, 2020 07:59
fmguerreiro pushed a commit to fmguerreiro/armeria that referenced this pull request Sep 19, 2020
Motivation:

Currently, a user cannot set example paths and queries. line#2195
The endpoint path or queries are only set automatically when
opening a URL that contains `endpoint_path` or `queries` as params.

Modifications:

- Add `examplePaths` to `DocService` and `DocServiceBuilder`
- Add `exampleQueries` to `DocService` and `DocServiceBuilder`
- Show `examplePath` if the `endpoint_path` is null and the `examplePath` is not null
- Show `exampleQuery` if the `queries` is null and the `exampleQuery` is not null
- Make `ENDPOINT PATH` input visible with read-only if a path is exact type 

Result:
You can now set an example path and queries for `DocService`
Fixes line#2195
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a way to set example query string
5 participants