Skip to content

API Explorer ignores where filter #2804

Closed

Description

@dhmlau

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.

Activity

  1. bajtos commented on Apr 29, 2019

    @bajtos
    Member

    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-client#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.

  2. dhmlau commented on May 1, 2019

    @dhmlau
    MemberAuthor

    Thanks @bajtos. Closing as duplicate of #2208.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions