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

Extend path parameter support #661

Open
2 of 6 tasks
diego-aquino opened this issue Mar 19, 2025 · 0 comments
Open
2 of 6 tasks

Extend path parameter support #661

diego-aquino opened this issue Mar 19, 2025 · 0 comments
Labels
feature New feature or request @zimic/fetch @zimic/fetch @zimic/http Related to @zimic/http @zimic/interceptor Related to @zimic/interceptor

Comments

@diego-aquino
Copy link
Member

Scope

@zimic/http

Prerequisites

  • I confirm that none of the open issues match my proposal
  • I confirm that my proposal is not yet available in the latest version of Zimic (see the documentation and the releases)

Type

Adds a new behavior

Compatibility

  • This is a breaking change

Context

Currently in @zimic/http, path parameters are fully inferred from the pathname. As an additional feature, we could support custom path parameter declarations, similarly to searchParams.

import { type HttpSchema } from '@zimic/http';

interface User {
  id: number
  username: string;
}

interface RequestError {
  code: string;
  message: string;
}

type Schema = HttpSchema<{
  '/users/:userId': {
    PATCH: {
      request: {
        pathParams: { userId: User['id'] };
        headers: { authorization: string };
        body: Partial<User>;
      };
      response: {
        204: {};
        400: { body: RequestError };
      };
    };
  };
}>;

Notes

  • Path params should continue to be inferred as before. Declaring a custom pathParams should only override the default params.

Feature description

  • Support pathParams in request schema declarations
  • [interceptor] Handle custom pathParams in HTTP request handlers
  • [fetch] Handle custom pathParams in fetch clients
@diego-aquino diego-aquino added feature New feature or request needs triage Needs to a triage by the Zimic team labels Mar 19, 2025
@diego-aquino diego-aquino marked this as a duplicate of #238 Mar 19, 2025
@diego-aquino diego-aquino added @zimic/interceptor Related to @zimic/interceptor @zimic/http Related to @zimic/http @zimic/fetch @zimic/fetch and removed needs triage Needs to a triage by the Zimic team labels Mar 19, 2025
@diego-aquino diego-aquino moved this to Backlog in Zimic Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request @zimic/fetch @zimic/fetch @zimic/http Related to @zimic/http @zimic/interceptor Related to @zimic/interceptor
Projects
Status: Backlog
Development

No branches or pull requests

1 participant