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
Multipart File Generation as InputStream #118
Comments
@melloware, thanks for opening this issue. Can you send a PR? This is a reasonably simple request. We can keep both options online with a codegen property. wdyt? |
Yep let me work on that. I may have a question on how to make it a switchable property. But let me submit a PR for you to review. |
OK i found
|
@melloware, I'll check in the codebase. These variables usually come from the bundle mapped by the openapi-generator library. Unfortunately, they are poorly documented, so we debug the @Orbifoldt, since you introduce this feature, can you please take a look? |
@melloware Yeah its tricky to find it out, I have never seen any documentation on which properties you are supposed to have access to... When you debug the code generation done by the openapi-generator you can let it print all information on the operations of your openapi spec. Then for each operation you have access to the parameters used by that operation. To get the form parameters of some operation As you can see the qute template consists of two parts: (1) an if expression where we set up the annotations, and (2) the declaration of the parameter. For example, this yaml (taken from here) requestBody:
content:
multipart/form-data: # Media type
schema: # Request payload
type: object
properties: # Request parts
profileImage:
type: string
format: binary gives us an entry in the {
"isFormParam": true,
"isQueryParam": false,
"isPathParam": false,
"isHeaderParam": false,
"isCookieParam": false,
"isBodyParam": false,
"isContainer": false,
"isCollectionFormatMulti": false,
"isPrimitiveType": true,
"isModel": false,
"isExplode": false,
"isDeepObject": false,
"isAllowEmptyValue": false,
"baseName": "profileImage",
"paramName": "profileImage",
"dataType": "File",
"dataFormat": "binary",
"baseType": "File",
"example": "new File(\"/path/to/file\")",
"jsonSchema": "{\r\n \"type\" : \"string\",\r\n \"format\" : \"binary\"\r\n}",
"isString": false,
"isNumeric": false,
"isInteger": false,
"isLong": false,
"isNumber": false,
"isFloat": false,
"isDouble": false,
"isDecimal": false,
"isByteArray": false,
"isBinary": true,
"isBoolean": false,
"isDate": false,
"isDateTime": false,
"isUuid": false,
"isUri": false,
"isEmail": false,
"isFreeFormObject": false,
"isAnyType": false,
"isShort": false,
"isUnboundedInteger": false,
"isArray": false,
"isMap": false,
"isFile": true,
"isEnum": false,
"additionalPropertiesIsAnyType": false,
"hasVars": false,
"vars": [],
"requiredVars": [],
"vendorExtensions": {},
"hasValidation": false,
"isNullable": false,
"isDeprecated": false,
"required": false,
"exclusiveMaximum": false,
"exclusiveMinimum": false,
"uniqueItems": false,
"isNull": false,
"hasRequired": false,
"hasDiscriminatorWithNonEmptyMapping": false,
"hasMultipleTypes": false,
"complexType": "File"
} If you analyse this you see that for this parameter the property Here you also see Hopefully this at least helps in understanding what's going on :) . I'll come back to you for the question how we can then replace the dataType of the file |
Ok, so I see a few options:
The nice thing about doing it as in option 1 (or 2) is that it can also be reused for other types, see for example this example: https://openapi-generator.tech/docs/usage/#type-mappings-and-import-mappings. However, it does require a bit more configuration for users. @ricardozanini @melloware what do you think is the way to go? |
I like either but the simpler the better so |
Thanks for the great summary, @Orbifoldt! I believe we can use the FQN, hence option 2. |
@Orbifoldt any update on this? |
I started working on this @melloware @ricardozanini , see #143 |
Closed with #143 |
tested this today and it works perfectly! |
Any chance we can get a release I would like to use this plugin not in SNAPSHOT form??? |
@melloware, we are releasing one after #158 |
@melloware https://github.com/quarkiverse/quarkus-openapi-generator/releases/tag/0.12.0 Please, next time, don't let this rest too much time; we don't have a strict release schedule. This means that we can release any time the community needs. |
Thank you !!! |
@Orbifoldt I am seeing these warnings now though is this expected? Everything is working properly. I have
|
@melloware It seems to me a false-positive warning, I checked the unit/integration tests and there I see that warning there too (e.g. io.quarkiverse.openapi.generator.it.TypeAndImportMappingTest#canMapTypesAndImportToDifferentValues). I am still not 100% on how quarkus extensions should deal with config... @ricardozanini Do you maybe know how to fix or suppress this warning? I did declare the config items in the SpecItemConfig class, and it doesn't complain about other items. Perhaps their type being Edit: Oh just as I sent this comment I changed the type to just be |
Do you mind sending a PR? If I would guess, I'd say that not using |
Yes, @ricardozanini is right. I've just tried here and Quarkus doesn't work with |
I fixed it in #165 |
Current Multipart Generation is generating the call with a File object when an InputStream would be preferred.
Current:
When ideally for more flexible client rather than requiring a File object requiring an InputStream so it can be streamed from say S3 or Azure Blob store.
Wanted:
Full current example.
The text was updated successfully, but these errors were encountered: