Skip to content

Commit

Permalink
Render the auth scheme in generated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sulaiman-fern committed Jul 29, 2024
1 parent 4d7e236 commit a7c4733
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/ui/app/src/api-page/endpoints/EndpointAuthSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ApiAuth } from "../../../../../fdr-sdk/src/client/generated/api/resources/api/resources/v1/resources/read";

export declare namespace EndpointAuthSection {
export interface Props {
auth: ApiAuth;
}
}

export const EndpointAuthSection: React.FC<EndpointAuthSection.Props> = ({ auth }) => {
return (
<div className="scroll-mt-content-padded fern-api-property">
<div className="fern-api-property-header">
<span className="fern-api-property-key">{auth.tokenName}</span>
<span className="fern-api-property-meta">
{auth.type}
<span className="t-danger">Required</span>
</span>
</div>
</div>
);
};
10 changes: 10 additions & 0 deletions packages/ui/app/src/api-page/endpoints/EndpointContentLeft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from "../../resolver/types";
import { JsonPropertyPath } from "../examples/JsonPropertyPath";
import { TypeComponentSeparator } from "../types/TypeComponentSeparator";
import { EndpointAuthSection } from "./EndpointAuthSection";
import { EndpointError } from "./EndpointError";
import { EndpointParameter } from "./EndpointParameter";
import { EndpointRequestSection } from "./EndpointRequestSection";
Expand All @@ -39,6 +40,7 @@ export declare namespace EndpointContentLeft {

const REQUEST = ["request"];
const RESPONSE = ["response"];
const AUTH = ["auth"];
const REQUEST_PATH = ["request", "path"];
const REQUEST_QUERY = ["request", "query"];
const REQUEST_HEADER = ["request", "header"];
Expand All @@ -65,6 +67,14 @@ const UnmemoizedEndpointContentLeft: React.FC<EndpointContentLeft.Props> = ({

return (
<div className="flex max-w-full flex-1 flex-col gap-12">
{endpoint.auth && (
<EndpointSection title="Authorization" anchorIdParts={AUTH} route={"/" + endpoint.slug}>
<div>
<TypeComponentSeparator />
<EndpointAuthSection auth={endpoint.auth} />
</div>
</EndpointSection>
)}
{endpoint.pathParameters.length > 0 && (
<EndpointSection title="Path parameters" anchorIdParts={REQUEST_PATH} route={"/" + endpoint.slug}>
<div>
Expand Down

0 comments on commit a7c4733

Please sign in to comment.