antho.dev
antho.dev

Reputation: 3

Spring deserialize List<Resource>

I have a springboot project with openApi for generate specification, i try to make an endpoint which receive many files but i have a spring error.

JSON parse error: Cannot deserialize value of type `java.util.ArrayList<org.springframework.core.io.Resource>` from Object value

my openApi spec:

      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                attachedFiles:
                  type: array
                  items:
                    type: string
                    format: binary
              required:
                - attachedFiles

Do you know how to make possible the deserialization of a List

Upvotes: 0

Views: 33

Answers (1)

AndrewL
AndrewL

Reputation: 3455

It is certainly possible to deserialize a list using Jackson.

But you will need to implement your own deserializer for org.springframework.core.io.Resource. This could be a binary stream (your OpenAPI spec even says this), so how do you propose representing this in JSON? Perhaps Base64 encoded?

Upvotes: 0

Related Questions