map openapi array (globally) to a java collection type

By default, the OpenAPI array maps to a simple java array. That is probably the first thing you want to change.

To change that default mapping for example to java.util.Collection a simple global type mapping is necessary in the mapping.yaml.

Given the following openapi.yaml fragment:

paths:

  /array:
    get:
      responses:
        '200':
          description:
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string

the processor will create the following endpoint interface using the default array mapping:

@GetMapping(path = "/array", produces = {"application/json"});
ResponseEntity<String[]> getArray();

To globally change the mapping of array to another collection type we just need to add a simple global type mapping to the mapping.yaml:

map:
  types:
    # map array to java.util.Collection
    - from: array
      to: java.util.Collection

This will change the generated endpoint to:

@GetMapping(path = "/array", produces = {"application/json"});
ResponseEntity<Collection<String>> getArray();

the processor assumes that the given java type has a single generic parameter and will automatically use the array's item property type as the generic parameter.