microprofile-open-api: Properties can not be defined in @Schema

@agiertli asked on Gitter (Jun 24 15:28) following question:


Hi folks,

I am trying to annotate a parameter which holds an uploaded file in my POST request:

The final OpenAPI spec should look like this: https://swagger.io/docs/specification/describing-request-body/file-upload/

      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                fileName:
                  type: string
                  format: binary

I can’t seem to find a suitable way how to define ‘properties’., when using MicroProfile annotations for OpenAPI. So far, I have this:

public Response processInvoice(
        @RequestBody(content = @Content(mediaType = "multipart/form-data", schema = @Schema(type = SchemaType.OBJECT))) MultipartFormDataInput input)

Which generates:

      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object

So it seems I am on the right track, but not sure how to proceed further…any ideas?

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I agree with the above proposal

I think that a fairly simple solution to this (and perhaps one that is not controversial) would be to introduce properties to the @Schema annotation. So for example, an application of the @Schema annotation might look like this:

@Schema(properties={
    @Schema(name="creditCard", required=true),
    @Schema(name="departtureFlight", description="The departure flight information."),
    @Schema(name="returningFlight")
})

This would allow the developer to describe any properties at all.