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: plumb multipart form encoding in fdr #780

Merged
merged 12 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions fern/apis/fdr/definition/api/v1/read/endpoint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,13 @@ types:
union:
object: type.ObjectType
reference: type.TypeReference
bytes: type.BytesRequest
formData: type.FormDataRequest

# deprecated, use formData
fileUpload:
type: optional<type.FileUploadRequest>
type: optional<type.FormDataRequest>
docs: "`fileUpload` is optional only to be backwards compatible. It should be required."
bytes: type.BytesRequest

HttpResponse:
extends: commons.WithDescription
Expand Down Expand Up @@ -238,12 +241,19 @@ types:
union:
json: unknown
form: map<string, FormValue>
bytes: BytesValue

FormValue:
union:
json: unknown
filename: string
filenames: list<string>
filenameWithData: FilenameWithData
filenamesWithData: list<FilenameWithData>

BytesValue:
union:
base64: string

FilenameWithData:
properties:
Expand Down
25 changes: 19 additions & 6 deletions fern/apis/fdr/definition/api/v1/read/type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,30 @@ types:
booleanLiteral: boolean
stringLiteral: string

FileUploadRequest:
FormDataRequest:
extends:
- commons.WithDescription
- commons.WithAvailability
properties:
name: string
properties: list<FileUploadRequestProperty>
properties: list<FormDataProperty>

BytesRequest:
properties:
isOptional: boolean
contentType: optional<string>

FileUploadRequestProperty:
FormDataProperty:
union:
file: FileProperty
bodyProperty: ObjectProperty
file: FormDataFileProperty
bodyProperty: FormDataBodyProperty

FileProperty:
FormDataBodyProperty:
extends: ObjectProperty
properties:
contentType: optional<ContentType>

FormDataFileProperty:
union:
file: FilePropertySingle
fileArray: FilePropertyArray
Expand All @@ -166,6 +171,7 @@ types:
properties:
key: PropertyKey
isOptional: boolean
contentType: optional<ContentType>

FilePropertyArray:
extends:
Expand All @@ -174,3 +180,10 @@ types:
properties:
key: PropertyKey
isOptional: boolean
contentType: optional<ContentType>

ContentType:
discriminated: false
union:
- string
- list<string>
17 changes: 14 additions & 3 deletions fern/apis/fdr/definition/api/v1/register/endpoint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,21 @@ types:

HttpRequestBodyShape:
union:
json: JsonRequestBody
formData: type.FormDataRequest
bytes: type.BytesRequest

# deprecated
object:
# deprecated, the CLI will use json instead
type: type.ObjectType
reference:
# deprecated, the CLI will use json instead
type: type.TypeReference
json: JsonRequestBody
fileUpload:
type: optional<type.FileUploadRequest>
# deprecated, the CLI will use formData instead
type: optional<type.FormDataRequest>
docs: "`fileUpload` is optional only to be backwards compatible. It should be required."
bytes: type.BytesRequest

JsonRequestBody:
properties:
Expand Down Expand Up @@ -213,12 +217,19 @@ types:
union:
json: unknown
form: map<string, FormValue>
bytes: BytesValue

FormValue:
union:
json: unknown
filename: string
filenames: list<string>
filenameWithData: FilenameWithData
filenamesWithData: list<FilenameWithData>

BytesValue:
union:
base64: string

FilenameWithData:
properties:
Expand Down
31 changes: 22 additions & 9 deletions fern/apis/fdr/definition/api/v1/register/type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ types:
minimum: optional<integer>
maximum: optional<integer>
default: optional<integer>

DoubleType:
properties:
minimum: optional<double>
maximum: optional<double>
default: optional<double>
StringType:

StringType:
properties:
regex: optional<string>
minLength: optional<integer>
Expand Down Expand Up @@ -138,13 +138,13 @@ types:
booleanLiteral: boolean
stringLiteral: string

FileUploadRequest:
FormDataRequest:
extends:
- commons.WithDescription
- commons.WithAvailability
properties:
name: string
properties: list<FileUploadRequestProperty>
properties: list<FormDataProperty>

BytesRequest:
extends:
Expand All @@ -154,12 +154,17 @@ types:
isOptional: boolean
contentType: optional<string>

FileUploadRequestProperty:
FormDataProperty:
union:
file: FileProperty
bodyProperty: ObjectProperty
file: FormDataFileProperty
bodyProperty: FormDataBodyProperty

FormDataBodyProperty:
extends: ObjectProperty
properties:
contentType: optional<ContentType>

FileProperty:
FormDataFileProperty:
union:
file: FilePropertySingle
fileArray: FilePropertyArray
Expand All @@ -171,6 +176,7 @@ types:
properties:
key: PropertyKey
isOptional: boolean
contentType: optional<ContentType>

FilePropertyArray:
extends:
Expand All @@ -179,3 +185,10 @@ types:
properties:
key: PropertyKey
isOptional: boolean
contentType: optional<ContentType>

ContentType:
discriminated: false
union:
- string
- list<string>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as FernRegistry from "../../../../../../../../..";

export type BytesValue = FernRegistry.api.v1.read.BytesValue.Base64;

export declare namespace BytesValue {
interface Base64 {
type: "base64";
value: string;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import * as FernRegistry from "../../../../../../../../..";

export type ExampleEndpointRequest =
| FernRegistry.api.v1.read.ExampleEndpointRequest.Json
| FernRegistry.api.v1.read.ExampleEndpointRequest.Form;
| FernRegistry.api.v1.read.ExampleEndpointRequest.Form
| FernRegistry.api.v1.read.ExampleEndpointRequest.Bytes;

export declare namespace ExampleEndpointRequest {
interface Json {
Expand All @@ -18,4 +19,9 @@ export declare namespace ExampleEndpointRequest {
type: "form";
value: Record<string, FernRegistry.api.v1.read.FormValue>;
}

interface Bytes {
type: "bytes";
value: FernRegistry.api.v1.read.BytesValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import * as FernRegistry from "../../../../../../../../..";
export type FormValue =
| FernRegistry.api.v1.read.FormValue.Json
| FernRegistry.api.v1.read.FormValue.Filename
| FernRegistry.api.v1.read.FormValue.FilenameWithData;
| FernRegistry.api.v1.read.FormValue.Filenames
| FernRegistry.api.v1.read.FormValue.FilenameWithData
| FernRegistry.api.v1.read.FormValue.FilenamesWithData;

export declare namespace FormValue {
interface Json {
Expand All @@ -20,7 +22,17 @@ export declare namespace FormValue {
value: string;
}

interface Filenames {
type: "filenames";
value: string[];
}

interface FilenameWithData extends FernRegistry.api.v1.read.FilenameWithData {
type: "filenameWithData";
}

interface FilenamesWithData {
type: "filenamesWithData";
value: FernRegistry.api.v1.read.FilenameWithData[];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import * as FernRegistry from "../../../../../../../../..";
export type HttpRequestBodyShape =
| FernRegistry.api.v1.read.HttpRequestBodyShape.Object_
| FernRegistry.api.v1.read.HttpRequestBodyShape.Reference
| FernRegistry.api.v1.read.HttpRequestBodyShape.Bytes
| FernRegistry.api.v1.read.HttpRequestBodyShape.FormData
/**
* `fileUpload` is optional only to be backwards compatible. It should be required. */
| FernRegistry.api.v1.read.HttpRequestBodyShape.FileUpload
| FernRegistry.api.v1.read.HttpRequestBodyShape.Bytes;
| FernRegistry.api.v1.read.HttpRequestBodyShape.FileUpload;

export declare namespace HttpRequestBodyShape {
interface Object_ extends FernRegistry.api.v1.read.ObjectType {
Expand All @@ -22,12 +23,16 @@ export declare namespace HttpRequestBodyShape {
value: FernRegistry.api.v1.read.TypeReference;
}

interface FileUpload {
type: "fileUpload";
value?: FernRegistry.api.v1.read.FileUploadRequest;
}

interface Bytes extends FernRegistry.api.v1.read.BytesRequest {
type: "bytes";
}

interface FormData extends FernRegistry.api.v1.read.FormDataRequest {
type: "formData";
}

interface FileUpload {
type: "fileUpload";
value?: FernRegistry.api.v1.read.FormDataRequest;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export * from "./Language";
export * from "./SupportedLanguage";
export * from "./ExampleEndpointRequest";
export * from "./FormValue";
export * from "./BytesValue";
export * from "./FilenameWithData";
export * from "./FileId";
export * from "./ExampleEndpointResponse";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

export type ContentType = string | string[];
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface FilePropertyArray
FernRegistry.api.v1.read.WithAvailability {
key: FernRegistry.api.v1.read.PropertyKey;
isOptional: boolean;
contentType?: FernRegistry.api.v1.read.ContentType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface FilePropertySingle
FernRegistry.api.v1.read.WithAvailability {
key: FernRegistry.api.v1.read.PropertyKey;
isOptional: boolean;
contentType?: FernRegistry.api.v1.read.ContentType;
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/

import * as FernRegistry from "../../../../../../../../..";

export interface FormDataBodyProperty extends FernRegistry.api.v1.read.ObjectProperty {
contentType?: FernRegistry.api.v1.read.ContentType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

import * as FernRegistry from "../../../../../../../../..";

export type FileProperty =
| FernRegistry.api.v1.read.FileProperty.File_
| FernRegistry.api.v1.read.FileProperty.FileArray;
export type FormDataFileProperty =
| FernRegistry.api.v1.read.FormDataFileProperty.File_
| FernRegistry.api.v1.read.FormDataFileProperty.FileArray;

export declare namespace FileProperty {
export declare namespace FormDataFileProperty {
interface File_ extends FernRegistry.api.v1.read.FilePropertySingle {
type: "file";
}
Expand Down
Loading
Loading