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

Cookie parameter support #46

Open
folklorelabs opened this issue Aug 12, 2024 · 1 comment
Open

Cookie parameter support #46

folklorelabs opened this issue Aug 12, 2024 · 1 comment

Comments

@folklorelabs
Copy link

Hi -- it appears that this library currently only supports the following parameter types: query, path, header, and body based on what I'm seeing in the source code. Was it an intentional decision to not include cookie parameters? If not would it be possible to add support?

Here's an example for reference.

Swagger doc OpenAPI example endpoint:

{
  ...
  "/v1/testUserData/{locale}": {
    "get": {
      "tags": [
        "test-controller"
      ],
      "summary": "A summary of the test user endpoint",
      "description": "A description of the test user endpoint.",
      "operationId": "getTestUserData",
      "parameters": [
        {
          "name": "AUTH_TOKEN",
          "in": "cookie",
          "description": "Auth Cookie",
          "content": {
            "*/*": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        {
          "name": "locale",
          "in": "path",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "responses": {
        "200": {
          "description": "Success",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TestResponse"
              }
            }
          }
        }
      }
    }
  },
  ...
}
...

typed-openapi output based on the Swagger doc OpenAPI example above:

...
export type get_GetTestUserData = typeof get_GetTestUserData;
export const get_GetTestUserData = {
  method: z.literal("GET"),
  path: z.literal("/v1/testUserData/{locale}"),
  parameters: z.object({
    path: z.object({
      locale: z.string(),
    }),
  }),
  response: TestResponse,
};
...

As you can see it is stripping out the AUTH_TOKEN parameter.

@astahmer
Copy link
Owner

I didnt need it when I made this lib, I think it makes sense to add it, feel free to make a PR

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

No branches or pull requests

2 participants