-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add flag for revised Vault Secrets API docs (#2082)
* chore: set up flag * feat: add placeholder for open-api-docs-view * feat: use the flag for vault-secrets API docs * chore: revert flags
- Loading branch information
Showing
8 changed files
with
142 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,8 @@ | |
}, | ||
"learn": { | ||
"max_static_paths": 1 | ||
}, | ||
"flags": { | ||
"enable_hcp_vault_secrets_api_docs_revision": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { OpenApiDocsViewProps } from './types' | ||
|
||
/** | ||
* Placeholder for a revised OpenAPI docs view. | ||
*/ | ||
function OpenApiDocsView(props: OpenApiDocsViewProps) { | ||
return ( | ||
<div style={{ border: '1px solid magenta' }}> | ||
<h1>OpenApiDocsView Placeholder</h1> | ||
<pre> | ||
<code>{JSON.stringify(props, null, 2)}</code> | ||
</pre> | ||
</div> | ||
) | ||
} | ||
|
||
export default OpenApiDocsView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { GetStaticPaths, GetStaticProps } from 'next' | ||
import { OpenApiDocsParams, OpenApiDocsViewProps } from './types' | ||
|
||
/** | ||
* Get static paths for the view. | ||
* | ||
* Initially, without versioning, we expect a single page. We use | ||
* `getStaticPaths` for flag-based compatibility with the previous template. | ||
* | ||
* Later, when we implement versioned API docs for the new template, | ||
* we'll likely need to retain `getStaticPaths`, using separate paths | ||
* for each version of the OpenAPI documents that we detect. | ||
*/ | ||
export const getStaticPaths: GetStaticPaths<OpenApiDocsParams> = async () => { | ||
// For the new template, regardless of whether we're in a deploy preview | ||
// or production, statically render the single view. | ||
return { | ||
paths: [{ params: { page: [] } }], | ||
fallback: false, | ||
} | ||
} | ||
|
||
/** | ||
* Get static props for the view. | ||
* | ||
* This is where we expect to fetch the OpenAPI document, and transform | ||
* the schema `.json` data into props for the view component. | ||
* | ||
* For now, we have a placeholder. We'll expand this as we build out the view. | ||
*/ | ||
export const getStaticProps: GetStaticProps< | ||
OpenApiDocsViewProps | ||
> = async () => { | ||
return { | ||
props: { | ||
placeholder: 'placeholder data for the revised API docs template', | ||
IS_REVISED_TEMPLATE: true, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import type { ParsedUrlQuery } from 'querystring' | ||
|
||
/** | ||
* Params type for `getStaticPaths` and `getStaticProps`. | ||
* Encodes our assumption that a `[[page]].tsx` file is being used. | ||
* | ||
* Note: this is only needed for compatibility with the previous API docs, | ||
* which could potentially render multiple pages, one for each service. | ||
* In this revised template, we only render a single page. | ||
* | ||
* We will still need a dynamic route for versioning, but will need a refactor. | ||
* TODO: revise this type once we've fully activated and then removed the | ||
* `enable_hcp_vault_secrets_api_docs_revision` flag. | ||
*/ | ||
export interface OpenApiDocsParams extends ParsedUrlQuery { | ||
page: string[] | ||
} | ||
|
||
/** | ||
* We'll use this type to document the shape of props for the view component. | ||
* For now, we have a placeholder. We'll expand this as we build out the view. | ||
*/ | ||
export interface OpenApiDocsViewProps { | ||
placeholder: string | ||
IS_REVISED_TEMPLATE: true | ||
} |
179118c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
dev-portal – ./
dev-portal-git-main-hashicorp.vercel.app
dev-portal-hashicorp.vercel.app
docs.hashicorp.com
developer.hashicorp.com