medly / apifi

Open API spec driven HTTP APIs
https://jitpack.io/#com.medly/apifi
4 stars 5 forks source link

Use List instead of Array #16

Open ashwini-desai opened 4 years ago

ashwini-desai commented 4 years ago

Problem:

The class generated for Request and Response models with type array should use List instead of Array

paths:
  /pets:
    get:
      responses:
        '200':
        description: pet response
        application/json:
          schema:
          type: array
          items:
            $ref: '#/components/schemas/Pet'

components:
  schemas:
    Pet:
      type: object
      required:
        - name
      properties:
        id:
          type: integer
          format: int64
        name:
          type: string

For example, the above responses block and Pet schema would generate

override fun findPets(tags: Array<String>?, limit: Int?): Array<Pet> {
  return tags?.let { tagList -> petStore.filter { pet -> tagList.contains(pet.tag) } }?.toTypedArray() ?: arrayOf()
}

We should update codegen to use List<*> as the return type instead