Hey Irfan,
So yeah, you cannot use attachments like this, it should be hidden behind
binary payload. The only thing you need to do is to change type="file" to
type="string" in your @Schema. This is the OAS 3.0 approach:
https://swagger.io/docs/specification/describing-request-body/file-upload/
And you should be fine.
Thanks!
Best Regards,
Andriy Redko
On Tue, Sep 4, 2018, 9:55 PM Irfan Pasha <[email protected]> wrote:
>
> Hi Andrey,
>
> As always, thanks for responding so quickly. Please find below the code
> snippet of my service
>
> @PUT
> @Path("/{WebAppName}")
> @Consumes(MediaType.MULTIPART_FORM_DATA)
> @Produces("application/json")
> @Tag(name = "Update")
> @Operation(
> summary = "Update Services",
> description = "Update Services",
> responses = {
> @ApiResponse(responseCode = "500", description
> = "Could not update service"),
> @ApiResponse(responseCode = "200", description
> = "Successfully updated service")}
> )
> public Response updateService(@Parameter(schema = @Schema(type =
> "file", format = "binary", description = "descriptor") ) Attachment
> descriptor,
> @Parameter(description = "service name ", required = true)
> @PathParam("servicename) String servicename,
> @Parameter(description = "service id", required = true)
> @PathParam("serviceid") String serviceid) {
>
> Regards,
> Irfan
>
> On Tue, Sep 4, 2018 at 7:39 PM Andriy Redko <[email protected]> wrote:
>
>> Hi Irfan,
>>
>> Thanks a lot for the feedback.
>>
>> 1) Would you mind providing a short snippet of endpoint definition +
>> OpenAPI annotations? (beside just @Schema)
>> 2) I think the only way to have an example through Java annotations is to
>> use formatted JSON as plain old String. It would be a good question to
>> Swagger guys (https://swagger.io/forum/) actually.
>>
>> Thank you.
>>
>> Best Regards,
>> Andriy Redko
>>
>> IP> Hi,
>>
>> IP> I have been CXF Framework for OpenAPI and its been very easy to use
>> so far.
>> IP> I have few questions where I am not finding proper
>> documentation/examples
>> IP> on how to do it. It would be great, if you can help me figuring out
>> what
>> IP> seems to be happening.
>>
>>
>> IP> 1. To perform a file upload for the type
>> org.apache.cxf.jaxrs.ext.multipart
>> IP> *.Attachment, *I added the following schema and the content-type is
>> IP> "MULTIPART_FORM_DATA", but I am still seeing the $ref in my
>> open-api.json
>> IP> as "*#/components/schemas/Attachment*" which is a JSONObject.
>> IP> @Schema(type = "file", format = "binary", description =
>> "descriptor") )
>>
>> IP> Is there a valid schema for Attachment type ?
>>
>> IP> 2. Is there a way to provide a formatted JSONObject as an example
>> instead
>> IP> of defining a string in the @Schema object ? I see lot of examples
>> with
>> IP> Swagger where they show the example as valid JSONObject, but not sure
>> how
>> IP> they would do that with constants.
>>
>> IP> Thank you in advance !
>>
>> IP> Regards,
>> IP> Irfan
>>
>>
>
> --
> irfan..........................
>