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

feat: shorten protobufAny text in HCP Vault API docs #2446

Merged
merged 15 commits into from
May 23, 2024

Conversation

zchsh
Copy link
Contributor

@zchsh zchsh commented May 15, 2024

πŸ”— Relevant links

πŸ—’οΈ What

Modifies the OpenAPI schema for HCP Vault Secrets to replace long descriptions in the protobufAny schema with shorter descriptions.

🀷 Why

The long descriptions for protobufAny we currently have in production feel more distracting that useful.

Ideally, we'd shorten these descriptions in the content source. However, making this adjustment isn't currently something that feels easy to reach for.

Note: once we are able to make modifications to these long descriptions at the content source, we'll plan to remove this layer of modification.

πŸ› οΈ How

  • Moves massageSchemaForClient hook to happen before the OpenAPI schema is dereferenced
    • This makes it possible to modify the properties of references in a reasonable way, since they're still in one place rather than several.
  • Builds out a set of schema modification utilities
    • Intent is to modify schema properties without mutating the incoming schema
    • Intent is also to let us compose different schema modification functions on a case-by-case basis... while also being able to easily explode those functions later into their composable parts if we go too far down the path of abstraction
  • Implements schemaModProtobufAny, which replaces the long descriptions we want to address with shorter ones
    • Uses underlying schemaModComponent, which we could use to modify other referenced component schemas, not just protobufAny
  • Abstracts out schemaModShortenHcp to replace HashiCorp Cloud Platform with HCP in OpenAPI schema titles, as this exact functionality is used across all our HCP OpenAPI docs so far

πŸ“Έ Design Screenshots

Before After
before after

πŸ§ͺ Testing

  • Visit /hcp/api-docs/vault-secrets on the preview

    • Definitions for protobufAny, which are often referenced in default error responses, should be a reasonable length, yet still provide useful information
  • Other OpenAPI docs views should be rendering as they are upstream, without changes

πŸ’­ Anything else?

Not at the moment!

Copy link

vercel bot commented May 15, 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 May 23, 2024 5:07pm

Copy link

github-actions bot commented May 15, 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 πŸ™Œ

@zchsh zchsh changed the title feat: rein in protobufAny docs in HCP Vault OpenAPI feat: rein in protobufAny text in HCP Vault OpenAPI May 15, 2024
@zchsh zchsh changed the title feat: rein in protobufAny text in HCP Vault OpenAPI feat: rein in protobufAny text in HCP Vault API docs May 15, 2024
@zchsh zchsh changed the title feat: rein in protobufAny text in HCP Vault API docs feat: shorten protobufAny text in HCP Vault API docs May 15, 2024
@zchsh zchsh marked this pull request as ready for review May 23, 2024 15:51
* This is done as we don't want to display the full descriptions of
* `protobufAny`, since they were too long in the context of the UI.
*/
function shortenProtobufAnyDescription(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main focus of this PR, the rest is mostly just refactoring to make using this function possible, and to build some consistency in schema modifications across the exist consumers of the OpenAPI docs view.

@zchsh zchsh requested review from a team and pbortnick and removed request for a team May 23, 2024 15:53
@zchsh
Copy link
Contributor Author

zchsh commented May 23, 2024

@pbortnick This PR is a somewhat temporary content modification for the HCP Vault Secrets API docs!

Apart from the content change, this also seems to fix an issue where previous versions of the docs would fail incremental static regeneration, because the page response size would be big enough that the lambda rendering the page would have trouble. It seems that shortening the description here puts the page back under the threshold needed for incremental static regeneration to function as expected.

Happy to add any other context as needed! πŸ™‡β€β™‚οΈ

Copy link
Contributor

@pbortnick pbortnick left a comment

Choose a reason for hiding this comment

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

Looks way better!

@zchsh zchsh merged commit 0713c80 into main May 23, 2024
9 checks passed
@zchsh zchsh deleted the zs.proto-open-api-revisions branch May 23, 2024 17:59
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.

None yet

2 participants