Skip to content

Commit

Permalink
feat: show file descriptions in multipart form (#618)
Browse files Browse the repository at this point in the history
  • Loading branch information
abvthecity authored Apr 5, 2024
1 parent d41029f commit d986da3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
6 changes: 6 additions & 0 deletions fern/apis/fdr/definition/api/v1/read/type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,17 @@ types:
fileArray: FilePropertyArray

FilePropertySingle:
extends:
- commons.WithDescription
- commons.WithAvailability
properties:
key: PropertyKey
isOptional: boolean

FilePropertyArray:
extends:
- commons.WithDescription
- commons.WithAvailability
properties:
key: PropertyKey
isOptional: boolean
6 changes: 6 additions & 0 deletions fern/apis/fdr/definition/api/v1/register/type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,17 @@ types:
fileArray: FilePropertyArray

FilePropertySingle:
extends:
- commons.WithDescription
- commons.WithAvailability
properties:
key: PropertyKey
isOptional: boolean

FilePropertyArray:
extends:
- commons.WithDescription
- commons.WithAvailability
properties:
key: PropertyKey
isOptional: boolean
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,29 @@ export const EndpointRequestSection: React.FC<EndpointRequestSection.Props> = ({
file: (file) => (
<EndpointParameterContent
name={file.key}
description={undefined}
description={file.description}
typeShorthand={
<span className="t-muted inline-flex items-baseline gap-2 text-xs">
{file.isOptional ? "optional file" : "file"}
</span>
}
anchorIdParts={[...anchorIdParts, file.key]}
route={route}
availability={undefined}
availability={file.availability}
/>
),
fileArray: (fileArray) => (
<EndpointParameterContent
name={fileArray.key}
description={undefined}
description={fileArray.description}
typeShorthand={
<span className="t-muted inline-flex items-baseline gap-2 text-xs">
{fileArray.isOptional ? "optional list of files" : "list of files"}
</span>
}
anchorIdParts={[...anchorIdParts, fileArray.key]}
route={route}
availability={undefined}
availability={fileArray.availability}
/>
),
bodyProperty: (bodyProperty) => (
Expand Down
24 changes: 20 additions & 4 deletions packages/ui/app/src/util/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,14 @@ function resolveRequestBodyShape(
async (property): Promise<ResolvedFileUploadRequestProperty> => {
switch (property.type) {
case "file": {
const description = await maybeSerializeMdxContent(
property.value.description,
);
return {
type: property.value.type,
key: property.value.key,
// TODO: support description and availability
description: undefined,
availability: undefined,
description,
availability: property.value.availability,
isOptional: property.value.isOptional,
};
}
Expand Down Expand Up @@ -1498,12 +1500,26 @@ export interface ResolvedReferenceShape extends WithMetadata {
}

export declare namespace ResolvedFileUploadRequestProperty {
interface FileProperty extends WithMetadata {
type: "file";
key: string;
isOptional: boolean;
}
interface FileArrayProperty extends WithMetadata {
type: "fileArray";
key: string;
isOptional: boolean;
}

interface BodyProperty extends ResolvedObjectProperty {
type: "bodyProperty";
}
}

export type ResolvedFileUploadRequestProperty = APIV1Read.FileProperty | ResolvedFileUploadRequestProperty.BodyProperty;
export type ResolvedFileUploadRequestProperty =
| ResolvedFileUploadRequestProperty.FileProperty
| ResolvedFileUploadRequestProperty.FileArrayProperty
| ResolvedFileUploadRequestProperty.BodyProperty;

export interface ResolvedFileUploadRequest extends WithMetadata {
name: string;
Expand Down

0 comments on commit d986da3

Please sign in to comment.