Skip to content
This repository has been archived by the owner on Nov 11, 2023. It is now read-only.

Delete request with two path parameters only generates with the first parameter #372

Open
meinfretr opened this issue Aug 27, 2021 · 1 comment

Comments

@meinfretr
Copy link

Have a delete request with two path params but when we generate, only one of them makes it through the process. We have a get request that does not have this issue.

Preview of the json is trimmed a bit but should give a general enough idea. Not shown is here is the get.

 "/api/v1/ratelimits/{project_id}/{endpoint}": {
      "delete": {
        "summary": "Delete a rate limiter definition from the database",
        "operationId": "Delete",
        "responses": {
          "200": {
            "description": "A successful response.",
            "content": {
              "application/json": {
                "schema": {
                  "properties": {}
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "project_id",
            "description": "project ID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "endpoint",
            "description": "endpoint",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },

When generated, this is the output:

export interface RatelimitsDeletePathParams {
  /**
   * project ID
   */
  project_id: string
}

Not sure where endpoint decided to go, but it shows up fine for the get:

export interface RatelimitsReadPathParams {
  /**
   * project ID
   */
  project_id: string;
  /**
   * endpoint
   */
  endpoint: string
}

There's no errors, it just goes MIA. Probably related to #259, if I were to make a guess.

@fabien0102
Copy link
Contributor

Hi @meinfretr ,
This is because the generated restful-react component will be useDelete (because your operationId is call Delete)and will take the last param as input:

const myComp = () => {
  const { mutate, loading } = useDelete({ project_id: "my-id" });

  return (
    <button onClick={() => mutate("endpoint")} disabled={loading}>
      {loading ? "⏳" : "delete endpoint"}
    </button>
  );
};

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants