-
-
Notifications
You must be signed in to change notification settings - Fork 519
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
Question: is there a way to override the generated Blob type to be File? #1825
Comments
Shouldn't you be able to just pass any File object there, as File inherits from Blob? |
Yes, but I want to require a file because the server requires a filename and content-type. |
To pass a filename, you will need to use multipart upload, as described here: https://swagger.io/docs/specification/describing-request-body/file-upload/ |
@mbergen At the document you linked, single file uploads are described as: requestBody:
content:
multipart/form-data:
schema:
filename:
type: string
format: binary and multi file uploads as: requestBody:
content:
multipart/form-data:
schema:
type: array
items:
filename:
type: string
format: binary Both of which are described to correspond to an HTTP request like this:
Without As I need to upload file in my API, I have only three options:
|
@rossmacarthur It's been 5 months. What did you use in the end? |
These are both the versions that specify to take a additional |
@mbergen Sorry, embarrassed I missed that, you are right. My point still stands though. I've tried the example specifications and the generated client only accepts /hosted/core/files/{path}:
post:
operationId: uploadContent
parameters:
- $ref: '#/components/parameters/path'
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
filename:
type: string
format: binary || public static uploadContent(
formData: {
filename?: Blob;
},
path: string = '',
): CancelablePromise<(FileMetadata | DirectoryMetadata)> {
return __request(OpenAPI, {
method: 'POST',
url: '/hosted/core/files/{path}',
path: {
'path': path,
},
formData: formData,
mediaType: 'multipart/form-data',
errors: {
409: `Path already exists`,
},
});
} |
Check out our fork of this repository @hey-api/openapi-ts. We have updated the type to be |
I have a
{"type": "string", "format": "binary"}
in my OpenAPI spec and it is being generated like thisI'd like this to be
Is there anyway to override this, perhaps by changing something in the OpenAPI spec?
The text was updated successfully, but these errors were encountered: