Swagger-codegen: [Dart] Generated code does not support model of array of objects

Created on 5 Mar 2019  Â·  2Comments  Â·  Source: swagger-api/swagger-codegen

Description

I have a valid Swagger definition that contains a model that is a list of other models. Here is an example:

  ListOfMessage:
    type: array
    items:
      $ref: '#/definitions/Message'
  Message:
    properties:
      id:
        type: integer
      createdOn:
        type: integer
      updatedOn:
        type: integer
      owner:
        type: integer

The generated code creates a ListOfMessage class but this class does not reference an array of Message objects!

Swagger-codegen version

Online in Swagger Editor

All 2 comments

I thought I'd put the solution here; instead of referencing a list of objects via models reference like so:

'/api/v1/chat/{acctNum}/room/{id}/messages':
    get:
      tags:
        - chat
      summary: searches for messages by room
      operationId: messagesByRoomV1
      parameters:
        - in: path
          name: acctNum
          description: Account number of organization
          required: true
          schema:
            type: string
        - in: path
          name: id
          description: Chat room id
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: search results matching criteria
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Message'
        '400':
          description: bad input parameter
        '403':
          description: >-
            forbidden if account number does not match user organization account
            number and user is not a super-admin
        '500':
          description: internal server error

Laura, see my solution on the ticket

On Mon, May 27, 2019 at 9:05 AM Laura Rodríguez Navas <
[email protected]> wrote:

I have the same problem.

Laura.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/swagger-api/swagger-codegen/issues/9239?email_source=notifications&email_token=AADXIGEPZASDEZFG2UA5PODPXPTBPA5CNFSM4G3472VKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWJ4N4Y#issuecomment-496223987,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADXIGFZ5YFXBT3O5HSRMLDPXPTBPANCNFSM4G3472VA
.

Was this page helpful?
0 / 5 - 0 ratings