Skip to content

Commit

Permalink
Refactor schema view
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-lee committed Aug 20, 2024
1 parent dd2fbd5 commit b1e88df
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 277 deletions.
6 changes: 3 additions & 3 deletions packages/zudoku/src/lib/plugins/openapi/OperationListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { groupBy } from "../../util/groupBy.js";
import { renderIf } from "../../util/renderIf.js";
import { OperationsFragment } from "./OperationList.js";
import { ParameterList } from "./ParameterList.js";
import { SchemaListView } from "./SchemaListView.js";
import { Sidecar } from "./Sidecar.js";
import { FragmentType, useFragment } from "./graphql/index.js";
import { SchemaView } from "./schema/SchemaView.js";
import { SchemaProseClasses } from "./util/prose.js";

export const PARAM_GROUPS = ["path", "query", "header", "cookie"] as const;
Expand Down Expand Up @@ -62,7 +62,7 @@ export const OperationListItem = ({
<Heading level={3} className="capitalize">
Request Body
</Heading>
<SchemaListView schema={schema} />
<SchemaView schema={schema} />
</div>
))}
{operation.responses.length > 0 && (
Expand Down Expand Up @@ -93,7 +93,7 @@ export const OperationListItem = ({
{renderIf(
response.content?.find((content) => content.schema),
(content) => {
return <SchemaListView schema={content.schema} />;
return <SchemaView schema={content.schema} />;
},
) ?? (
<Card className="font-mono text-sm p-4">
Expand Down
18 changes: 10 additions & 8 deletions packages/zudoku/src/lib/plugins/openapi/ParameterList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ export const ParameterList = ({
</Heading>
<Card>
<ul className="list-none m-0 px-0 divide-y ">
{parameters.map((parameter) => (
<ParameterListItem
key={`${parameter.name}-${parameter.in}`}
parameter={parameter}
id={id}
group={group}
/>
))}
{parameters
.sort((a, b) => (a.required === b.required ? 0 : a.required ? -1 : 1))
.map((parameter) => (
<ParameterListItem
key={`${parameter.name}-${parameter.in}`}
parameter={parameter}
id={id}
group={group}
/>
))}
</ul>
</Card>
</>
Expand Down
75 changes: 0 additions & 75 deletions packages/zudoku/src/lib/plugins/openapi/SchemaListView.tsx

This file was deleted.

125 changes: 0 additions & 125 deletions packages/zudoku/src/lib/plugins/openapi/SchemaListViewItem.tsx

This file was deleted.

This file was deleted.

7 changes: 4 additions & 3 deletions packages/zudoku/src/lib/plugins/openapi/Sidecar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ export const Sidecar = ({

const requestBodyContent = operation.requestBody?.content;

const path = operation.path.split("/").map((part) => (
<Fragment key={part}>
const path = operation.path.split("/").map((part, i, arr) => (
// eslint-disable-next-line react/no-array-index-key
<Fragment key={part + i}>
{part.startsWith("{") && part.endsWith("}") ? (
<ColorizedParam
name={part.slice(1, -1)}
Expand All @@ -119,7 +120,7 @@ export const Sidecar = ({
) : (
part
)}
/
{i < arr.length - 1 ? "/" : null}
<wbr />
</Fragment>
));
Expand Down
Loading

0 comments on commit b1e88df

Please sign in to comment.