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

Codegen: better handling of duplicate param names #3780

Merged
merged 4 commits into from
Oct 10, 2023

Conversation

kahirokunn
Copy link
Contributor

@kahirokunn kahirokunn commented Oct 6, 2023

When we generated this swagger, the names of the path parameter and query parameter were covered and broken, so we fixed it.

"/api/v1/namespaces/{namespace}/pods/{name}/proxy/{path}": {
  "get": {
    "tags": ["core_v1"],
    "description": "connect GET requests to proxy of Pod",
    "operationId": "connectCoreV1GetNamespacedPodProxyWithPath",
    "responses": {
      "200": {
        "description": "OK",
        "content": { "*/*": { "schema": { "type": "string" } } }
      },
      "401": { "description": "Unauthorized" }
    },
    "x-kubernetes-action": "connect",
    "x-kubernetes-group-version-kind": {
      "group": "",
      "version": "v1",
      "kind": "PodProxyOptions"
    }
  },
  "put": {
    "tags": ["core_v1"],
    "description": "connect PUT requests to proxy of Pod",
    "operationId": "connectCoreV1PutNamespacedPodProxyWithPath",
    "responses": {
      "200": {
        "description": "OK",
        "content": { "*/*": { "schema": { "type": "string" } } }
      },
      "401": { "description": "Unauthorized" }
    },
    "x-kubernetes-action": "connect",
    "x-kubernetes-group-version-kind": {
      "group": "",
      "version": "v1",
      "kind": "PodProxyOptions"
    }
  },
  "post": {
    "tags": ["core_v1"],
    "description": "connect POST requests to proxy of Pod",
    "operationId": "connectCoreV1PostNamespacedPodProxyWithPath",
    "responses": {
      "200": {
        "description": "OK",
        "content": { "*/*": { "schema": { "type": "string" } } }
      },
      "401": { "description": "Unauthorized" }
    },
    "x-kubernetes-action": "connect",
    "x-kubernetes-group-version-kind": {
      "group": "",
      "version": "v1",
      "kind": "PodProxyOptions"
    }
  },
  "delete": {
    "tags": ["core_v1"],
    "description": "connect DELETE requests to proxy of Pod",
    "operationId": "connectCoreV1DeleteNamespacedPodProxyWithPath",
    "responses": {
      "200": {
        "description": "OK",
        "content": { "*/*": { "schema": { "type": "string" } } }
      },
      "401": { "description": "Unauthorized" }
    },
    "x-kubernetes-action": "connect",
    "x-kubernetes-group-version-kind": {
      "group": "",
      "version": "v1",
      "kind": "PodProxyOptions"
    }
  },
  "options": {
    "tags": ["core_v1"],
    "description": "connect OPTIONS requests to proxy of Pod",
    "operationId": "connectCoreV1OptionsNamespacedPodProxyWithPath",
    "responses": {
      "200": {
        "description": "OK",
        "content": { "*/*": { "schema": { "type": "string" } } }
      },
      "401": { "description": "Unauthorized" }
    },
    "x-kubernetes-action": "connect",
    "x-kubernetes-group-version-kind": {
      "group": "",
      "version": "v1",
      "kind": "PodProxyOptions"
    }
  },
  "head": {
    "tags": ["core_v1"],
    "description": "connect HEAD requests to proxy of Pod",
    "operationId": "connectCoreV1HeadNamespacedPodProxyWithPath",
    "responses": {
      "200": {
        "description": "OK",
        "content": { "*/*": { "schema": { "type": "string" } } }
      },
      "401": { "description": "Unauthorized" }
    },
    "x-kubernetes-action": "connect",
    "x-kubernetes-group-version-kind": {
      "group": "",
      "version": "v1",
      "kind": "PodProxyOptions"
    }
  },
  "patch": {
    "tags": ["core_v1"],
    "description": "connect PATCH requests to proxy of Pod",
    "operationId": "connectCoreV1PatchNamespacedPodProxyWithPath",
    "responses": {
      "200": {
        "description": "OK",
        "content": { "*/*": { "schema": { "type": "string" } } }
      },
      "401": { "description": "Unauthorized" }
    },
    "x-kubernetes-action": "connect",
    "x-kubernetes-group-version-kind": {
      "group": "",
      "version": "v1",
      "kind": "PodProxyOptions"
    }
  },
  "parameters": [
    {
      "name": "name",
      "in": "path",
      "description": "name of the PodProxyOptions",
      "required": true,
      "schema": { "type": "string", "uniqueItems": true }
    },
    {
      "name": "namespace",
      "in": "path",
      "description": "object name and auth scope, such as for teams and projects",
      "required": true,
      "schema": { "type": "string", "uniqueItems": true }
    },
    {
      "name": "path",
      "in": "path",
      "description": "path to the resource",
      "required": true,
      "schema": { "type": "string", "uniqueItems": true }
    },
    {
      "name": "path",
      "in": "query",
      "description": "Path is the URL path to use for the current proxy request to pod.",
      "schema": { "type": "string", "uniqueItems": true }
    }
  ]
},

@codesandbox
Copy link

codesandbox bot commented Oct 6, 2023

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@netlify
Copy link

netlify bot commented Oct 6, 2023

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 48883be
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/6525962a57e9210008d48d83
😎 Deploy Preview https://deploy-preview-3780--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Oct 6, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 48883be:

Sandbox Source
Vanilla Configuration
Vanilla Typescript Configuration
rsk-github-issues-example Configuration
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration

@kahirokunn kahirokunn changed the title bugfix: Fixed a bug that if a path parameter and a query parameter were overlapped, the one defined first would disappear. Fixed a bug in RTK Query Codegen. Oct 6, 2023
@kahirokunn
Copy link
Contributor Author

$ yarn test
 PASS  test/cli.test.ts (13.486 s)
 PASS  test/generateEndpoints.test.ts

Test Suites: 2 passed, 2 total
Tests:       28 passed, 28 total
Snapshots:   16 passed, 16 total
Time:        14.81 s, estimated 18 s
Ran all test suites.

@kahirokunn
Copy link
Contributor Author

@phryneas Hello! Can you give me a review?

@kahirokunn
Copy link
Contributor Author

kahirokunn commented Oct 6, 2023

Oh, this is no good.
The generation has been buggy.
I will fix it again.

export type ConnectCoreV1GetNamespacedPodProxyWithPathApiArg = {
  /** name of the PodProxyOptions */
  name: string
  /** object name and auth scope, such as for teams and projects */
  namespace: string
  /** path to the resource */
  path: string
  /** Path is the URL path to use for the current proxy request to pod. */
  path?: string
}

@kahirokunn kahirokunn force-pushed the bugfix2 branch 2 times, most recently from 02f5340 to 0f4efdc Compare October 6, 2023 08:26
@kahirokunn
Copy link
Contributor Author

@phryneas Added test.
Now it works perfectly.

The reason we didn't just prefix it with _ is that it depends on the order of loading.

If for some reason the _ at the beginning of a path is attached to a query, it will cause a huge bug.
Such a bug is difficult to find the cause.
Therefore, we have taken the safe way out.

@phryneas
Copy link
Member

phryneas commented Oct 8, 2023

Hey @kahirokunn, thanks for the PR!
I've abstacted your changes a bit so we have less code duplication. Could you test this version if it works for you and report back?

@kahirokunn
Copy link
Contributor Author

@phryneas thanks!
I have replied, please check if you like!

@kahirokunn
Copy link
Contributor Author

kahirokunn commented Oct 10, 2023

@phryneas
Sorry, when I dropped the prettier changes in rebase, I also deleted the commit you gave me by mistake.
I don't know the commit message and commit hash.
Could you cherry-pick it again?

@phryneas
Copy link
Member

Ugh... I'll try and find it 🤣

@phryneas phryneas changed the title Fixed a bug in RTK Query Codegen. Codegen: better handling of duplicate param names Oct 10, 2023
@phryneas phryneas merged commit 2fea0ce into reduxjs:master Oct 10, 2023
@phryneas
Copy link
Member

Found it... merged :)

@phryneas
Copy link
Member

Released in v1.1.0

@kahirokunn
Copy link
Contributor Author

Thx!

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

Successfully merging this pull request may close these issues.

2 participants