Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
llotall opened this issue Apr 17, 2024 · 0 comments
Open

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

llotall opened this issue Apr 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@llotall
Copy link
Contributor

llotall commented Apr 17, 2024

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[]

@llotall llotall added the bug Something isn't working label Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant