tazatechnology / openapi_spec

Dart based OpenAPI specification generator and parser
BSD 3-Clause "New" or "Revised" License
9 stars 6 forks source link

Unable to compile code generated when a query parameter is present and the response constitutes an array of objects #68

Closed tablet0ps closed 1 month ago

tablet0ps commented 7 months ago

I am trying to generate client-side code using openapi_spec CLI. In such condition I am unable to compile the generated code. Here's the spec:

{
  "openapi": "3.0.1",
  "info": {
    "title": "Test Doc",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "http://localhost:3000",
      "description": "Test Server"
    }
  ],
  "paths": {
    "/notes": {
      "get": {
        "operationId": "getNotes",
        "parameters": [
          {
            "name": "category",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/Note"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Note": {
        "required": [
          "noteId"
        ],
        "type": "object",
        "properties": {
          "noteId": {
            "type": "string",
            "format": "uuid"
          }
        }
      }
    }
  }
}

Error received:

ERROR: ../test_sdk/lib/src/client.dart:384:29: Error: Member not found: 'List.fromJson'.
ERROR:     return GetNotesResponse.fromJson(_jsonDecode(r));
ERROR:                             ^^^^^^^^
ERROR: Target kernel_snapshot failed: Exception
walsha2 commented 7 months ago

@tablet0ps thanks for the issue, will take a look and report back.