0

I need to describe a multipart query that has an array of strings. But I ran into a problem, in the query, the array elements are combined into one string instead of being separate string items. I am using OpenApi 3.0.3)

requestBody: {
          content: {
            'multipart/form-data': {
              schema: {
                type: 'object',
                properties: {
                  email: {
                    type: 'string',
                  },
                  password: {
                    type: 'string',
                  },
                  confirmPassword: {
                    type: 'string',
                  },
                  fullName: {
                    type: 'string',
                  },
                  avatar: {
                    type: 'string',
                    format: 'binary',
                  },
                  'genreIds[]': {
                    type: 'array',
                    items: {
                      oneOf: {
                        type: 'string',
                      },
                    },
                  },
                  'languageIds[]': {
                    type: 'array',
                    items: {
                      type: 'string',
                      default: '',
                    },
                  },
                },
              },
            },
          },
        },

What I received: genreIds: [ '1234,55466,2455' ] What I expect: genreIds: [ '1234','55466','2455' ]

1

1 Answer 1

0

Try adding style: 'form' and explode: true for parameters of type: 'array':

  'genreIds[]': {
    type: 'array',
    items: {
      oneOf: {
        type: 'string',
      },
    },
    style: 'form',
    explode: true
  }

For more details please read the OpenAPI 3.0.3 documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.