Skip to content

Endpoint parsing error when the parameter is an empty string. #2376

@pstachula-dev

Description

@pstachula-dev

openapi-fetch version

0.14.0

Description

When there is an endpoint with ID parm - /actions/{id}
and it accepts params.path.id: string - in that case ID equal to '' (empty string)

Then openapi-fetch implicitly parses endpoint to /actions and for types connected with ActionDto I get implicitly ActionDto[]

Reproduction

export const getAction = async ({  params }: ActionParams) => {
  const { data, error, response } = await fetchClient.GET('/actions/{id}', { params });
  return data;
}

getAction({ params: { path: { id: '' } } })  // => [ActionObj, ActionObj]

Expected result

export const getAction = async ({  params }: ActionParams) => {
  const { data, error, response } = await fetchClient.GET('/actions/{id}', { params });
  return data;
}

getAction({ params: { path: { id: '' } } })  // => Error404 or whatever the API returns

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-fetchRelevant to the openapi-fetch library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions