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

[WAYP-2783] Add support for a "hidden" tag for api-docs #2565

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

jgwhite
Copy link
Contributor

@jgwhite jgwhite commented Sep 10, 2024

πŸ”— Relevant links

πŸ—’οΈ What

This allows us to tag RPCs as hidden to prevent them appearing in API docs.

Looks like this in practice:

rpc UI_LoadProductBanner(UI.LoadProductBannerRequest) returns (UI.LoadProductBannerResponse) {
  option (google.api.http) = {
    get: "/waypoint/2023-08-18/namespace/{namespace.id}/ui/product-banner"
  };
  option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
    tags: ["WaypointService", "hidden"]
  };
}

🀷 Why

We have a set of specialized RPCs in cloud-waypoint-service that are designed only to be used by the UI. We were hoping we could mark these as internal but we realized that means they don’t end up in the generated Swagger at all, and thus don’t make it to our generated API client. At Emily Persson’s wise suggestion, we are opting to tag these APIs with hidden instead, and add some special handling here to ignore methods with that tag.

πŸ› οΈ How

As you’ll see from the diff, this is a small patch to getOperationProps that skips over methods with the hidden tag.

πŸ“Έ Design Screenshots

N/A

πŸ§ͺ Testing

  1. Visit the api-doc preview page
  2. Paste the contents of Waypoint’s Swagger 1 into the Schema source field
  3. Verify that none of the UI_-prefixed methods show up

πŸ““ Docs

Question to the reviewer: I’d like to document this tag somewhere. Where’s the best place to do so?

Footnotes

  1. This is the Swagger from https://github.com/hashicorp/cloud-waypoint-service/pull/1390 ↩

Copy link

vercel bot commented Sep 10, 2024

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
dev-portal βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Sep 12, 2024 0:28am

Copy link

github-actions bot commented Sep 10, 2024

πŸ“¦ Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action πŸ€–

This PR introduced no changes to the javascript bundle πŸ™Œ

This allows us to tag RPCs as `hidden` to prevent them appearing in
API docs.

Looks like this in practice:

    rpc UI_LoadProductBanner(UI.LoadProductBannerRequest) returns (UI.LoadProductBannerResponse) {
      option (google.api.http) = {
        get: "/waypoint/2023-08-18/namespace/{namespace.id}/ui/product-banner"
      };
      option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
        tags: ["WaypointService", "hidden"]
      };
    }
Copy link
Contributor

@zchsh zchsh left a comment

Choose a reason for hiding this comment

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

πŸ’― This looks great to me, thank you so much! πŸ™Œ

Re: documenting the tag somewhere, that's a great question... on the web presence side we recently started up an internal docs site. I'll start some documentation on our API docs there, with a note that we need to come up with author-facing documentation as well. Maybe that could be as straightforward as another section in our internal docs site... it does required Vercel auth to view though... will think on this, and very open to suggestions!

@jgwhite jgwhite merged commit 18b7c28 into main Sep 12, 2024
9 checks passed
@jgwhite jgwhite deleted the WAYP-2783-hidden-tag branch September 12, 2024 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants