Skip to content

API Explorer ignores where filter #2804

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

Closed
dhmlau opened this issue Apr 26, 2019 · 2 comments
Closed

API Explorer ignores where filter #2804

dhmlau opened this issue Apr 26, 2019 · 2 comments

Comments

@dhmlau
Copy link
Member

dhmlau commented Apr 26, 2019

Description

In the API Explorer, the where filter is being ignored.

Steps to reproduce

Using todo-list example,

  1. create todolist with ids 1, 2, and 3.
  2. create 3 todo's, one for each todolist:
[
  {
    "id": 10,
    "title": "todo 1",
    "desc": "string",
    "isComplete": false,
    "todoListId": 1
  },
  {
    "id": 20,
    "title": "todo 2",
    "desc": "string",
    "isComplete": false,
    "todoListId": 2
  },
  {
    "id": 30,
    "title": "todo 3",
    "desc": "string",
    "isComplete": false,
    "todoListId": 3
  }
]
  1. in the API explorer, call GET /todos with the following filter:
{
  "where": {"todoListId": 1}
}

It returns all the todo instances regardless of the todoListId.

However, if I call http://localhost:3000/todos?filter[where][todoListId]=1 from a browser, it's returning the right response.

Investigation

From @nabdelgadir.
Printing out what get passed into filter

async findTodos(
    @param.query.object('filter', getFilterSchemaFor(Todo)) filter?: Filter,
  ): Promise<Todo[]> {
    console.log(filter);
    return await this.todoRepo.find(filter);
  }

it returns undefined from the explorer but { where: { todoListId: '1' } } from the link

Current Behavior

API Explorer ignores the where filter.

@bajtos
Copy link
Member

bajtos commented Apr 29, 2019

See #2208 (comment).

I am afraid this is a known bug/limitation of swagger-ui and swagger-js, see the discussion in #1679 and the tracking issue swagger-api/swagger-js#1385.

You can see this yourself in API Explorer UI. When you send the request, the UI shows the full URL, request headers and response headers. There you can see that the request URL created by API Explorer (swagger-js) does not contain the filter properties.

Unfortunately swagger-ui does not warn the user about this problem, which makes the entire experience less than ideal.

@dhmlau
Copy link
Member Author

dhmlau commented May 1, 2019

Thanks @bajtos. Closing as duplicate of #2208.

@dhmlau dhmlau closed this as completed May 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants