Search code examples
spring-bootopenapiopenapi-generatorjava-17openapi-generator-maven-plugin

Multipart don't working for ArrayObject files with Open Api 4.3.1 Version


Description Hi Everyone. I am working with open api generator and change for only use Reactor in my projects (Flux and Mono). My problem is when I generate Multipart form for object array files, the generator create @RequestPart with Mono and it's will be geerate with Flux because the object is an array.

I check the mustaches templates for form params and all it's ok.

This is part of my formParams.mustache {{#reactive}}{{#isArray}}Flux{{/isArray}}{{^isArray}}Mono{{/isArray}}{{/reactive}}{{^reactive}}{{#isArray}}List<{{/isArray}}MultipartFile{{#isArray}}>{{/isArray}}{{/reactive}}

My question is: why the generator don't validate when "isArray" because always generate with Mono in my classes.

This is an example how to generate my ApiDelegate: with single element (Ok): default Mono multipartSingle(Mono file, ServerWebExchange exchang

My Open api YAML is:

openapi: 3.0.1
info:
  title: Test multipart
  version: v1
servers:
  - url: http://localhost:9111/api-test/multipart/v1
    description: Generated server url
paths:
  /multipart/single:
    post:
      tags:
        - multipart
      description: Single MultipartFile test
      operationId: multipartSingle
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  description: "One file"
                  type: string
                  format: binary
      responses:
        '200':
          description: successful operation, name of the uploaded file
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InformationPart'  
  /multipart-array:
    post:
      tags:
        - multipart
      description: MultipartFile array test
      operationId: multipartArray
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                files:
                  type: array
                  description: "Many files"
                  items:
                    type: string
                    format: binary
      responses:
        '200':
          description: successful operation, name of the uploaded file
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/InformationPart'
components:
  schemas:
    InformationPart:
      title: Dummy info
      type: object
      properties:
        fileName:
          type: string
        additionalInformation:
          type: string

with Array Files(Don't generate with Flux): default Mono multipartArray(Mono file, ServerWebExchange exchang

openapi-generator version 4.3.1

OpenAPI declaration file content or url Command line used for generation I use mvn clean install.

Steps to reproduce When I generate with maven plugin for single part it's generating ok, problem is when it's generate for array object


Solution

  • I can resolve it changing in forms.mustache to {#isArray} to {#isListContainer} and it's works fine without changing version of plugin