Comments (6)
I am experiencing a similar problem.
Here is the generated code:
public static uploadFile(data: $OpenApiTs['/file/upload']['post']['req']): CancelablePromise<$OpenApiTs['/file/upload']['post']['res'][200]> {
return __request(OpenAPI, {
method: 'POST',
url: '/file/upload',
query: {
table_name: data.tableName
},
formData: data.formData,
mediaType: 'multipart/form-data',
errors: {
400: 'Bad Request',
422: 'Validation Error',
500: 'Internal Server Error'
}
});
}
Error:
src/client/services.gen.ts:726:13 - error TS2322: Type 'BodyUploadFileFileUploadPost' is not assignable to type 'Record<string, unknown>'.
Index signature for type 'string' is missing in type 'BodyUploadFileFileUploadPost'.
726 formData: data.formData,
~~~~~~~~
src/client/core/ApiRequestOptions.ts:8:11
8 readonly formData?: Record<string, unknown>;
~~~~~~~~
The expected type comes from property 'formData' which is declared here on type 'ApiRequestOptions'
Found 1 error in src/client/services.gen.ts:726
OpenAPI
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/Body_upload_file_file_upload_post"
}
}
}
},
"Body_upload_file_file_upload_post": {
"properties": {
"file": {
"type": "string",
"format": "binary",
"title": "File"
}
},
"type": "object",
"required": [
"file"
],
"title": "Body_upload_file_file_upload_post"
},
from openapi-ts.
@jegork I am getting this as well using the fetch client. I have a FastAPI like this async def zip(file: UploadFile = File(...)):
.
Type 'Body_upload_zip' is not assignable to type 'Record<string, unknown>'.
Index signature for type 'string' is missing in type 'Body_upload_zip'.ts(2322)
ApiRequestOptions.ts(15, 12): The expected type comes from property 'formData' which is declared here on type 'ApiRequestOptions'
export type Body_upload_zip = {
file: (Blob | File);
};
export type UploadZipData = {
formData: Body_upload_zip;
};
from openapi-ts.
Thanks again @m-rieke, will test this API and see what other issues there are with creating a build!
from openapi-ts.
@m-rieke I see there spec looks something like this:
"requestBody": {
"content": {
"*/*": {
"schema": {
"items": {
"type": "string"
},
"type": "array"
}
},
"multipart/form-data": {
"schema": {
"items": {
"type": "string"
},
"type": "array"
}
}
},
"description": "The IDs of the fields to set as columns. In the form data, specify each field as `columns=id`, where `id` is the *id* of a field (as seen in the response for [Get fields](#api-rest-api-<ver>-field-get)). For example, `columns=summary`."
},
I wonder how we should know that this formData array has a key of columns
(see description in spec) the spec doesnt really provide that information to us from what I can see.
from openapi-ts.
I am not sure if this is changing anything, but I read the following in the Spec:
"requestBody": {
"content": {
"multipart/form-data": {
"schema": {
"items": {
"$ref": "#/components/schemas/MultipartFile"
},
"type": "array"
}
}
},
"required": true
},
and MultipartFile is defined as follows:
"MultipartFile": {
"additionalProperties": false,
"properties": {
"bytes": {
"items": {
"format": "byte",
"type": "string"
},
"type": "array"
},
"contentType": {
"type": "string"
},
"empty": {
"type": "boolean"
},
"inputStream": {
"type": "object"
},
"name": {
"type": "string"
},
"originalFilename": {
"type": "string"
},
"resource": {
"$ref": "#/components/schemas/Resource"
},
"size": {
"format": "int64",
"type": "integer"
}
},
"type": "object"
}
from openapi-ts.
@m-rieke thanks for providing that. I will need to see what other code generators do. That still doesn't seem like a proper definition because it doesn't provide the key to use for the form data array.
from openapi-ts.
Related Issues (20)
- OpenAPI parameters with the same name and different "in" types cause "Duplicate identifier" error in types.gen.ts HOT 2
- Empty JSON request body spec is created as an "unknown" type HOT 1
- Wasn't able to send a correctly formatted payload using application/x-www-form-urlencoded HOT 1
- Default export of the module has or is using private name 'ClientConfig'. HOT 2
- Types for the methods conflict when the same operation name is defined in multiple routes HOT 15
- Proper Angular support HOT 2
- External reference not resolved correctly HOT 1
- Why is accept hard coded? Can it be changed to */* until a better solution is created? HOT 5
- How to create my own client? HOT 14
- client-fetch: array of string in body unsupported
- Handle different http status like 200 or 204 HOT 5
- Support microsoft office Content-Type as binary HOT 3
- CancelablePromise type does not work with react suspense HOT 5
- Default content-type of application/json applied to requests even when no body HOT 2
- @hey-api/client-fetch does not really `throw` where it should HOT 3
- Object is possibly undefined this.httpRequest HOT 2
- @hey-api/client-fetch: Error is unknown when using default HOT 2
- @hey-api/client-fetch: TS type RequestResult is not exported
- Option for config filename
- Using the raw operationId with the methodNameGenarator HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-ts.