Skip to content

Wrong endpoint method generation in case of Guid[] response type #140

@llotall

Description

@llotall

Describe the bug
I have endpoint, that returns array of Guids. Instead of correct mapping generaton in service method, i got wrong generation.

To Reproduce

"/api/v1/attachment/image/list/{id}": {
      "get": {
        "tags": [
          "image"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        }
      }
    }

Expected behavior
generation like that:

 public list(id: string): Observable<Guid[]> {
        return this.get<string[]>(
            `list/${encodeURIComponent(id)}`,
        ).pipe(map((arr: string[]) => arr.map(z => (z ? new Guid(z) : Guid.empty)) ));
    }

Additional context
In fact generated this code

public list(id: string): Observable<Guid[]> {
        return this.get<string[]>(
            `list/${encodeURIComponent(id)}`,
        ).pipe(map(x => mapGuid()));
    }
    

with error:

TS2322: Type Observable<OperatorFunction<string, Guid>> is not assignable to type Observable<Guid[]>
Type OperatorFunction<string, Guid> is not assignable to type Guid[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions