Skip to content

Generate request params as particular type #233

@indapublic

Description

@indapublic

Hello!

I'm using this command for generate npx swagger-typescript-api -p public/swagger/v2.json -o ./assets/v2/src/api -n apiClient.ts --type-prefix=T

and I have this route in generated output.

      data: {
        firstName?: string;
        middleName?: string | null;
        lastName?: string;
        birthday?: string;
        gender?: TGender;
        phones?: string[];
        addresses?: TAddress[];
        contacts?: TContact[];
        avatar?: string | null;
        timezone?: string;
      },
      params: RequestParams = {},
    ) =>
      this.request<void, void>({
        path: `/user/profile`,
        method: "PUT",
        body: data,
        secure: true,
        type: ContentType.Json,
        ...params,
      }),

Is it possible to have particular interface with request type, e.g.

        middleName?: string | null;
        lastName?: string;
        birthday?: string;
        gender?: TGender;
        phones?: string[];
        addresses?: TAddress[];
        contacts?: TContact[];
        avatar?: string | null;
        timezone?: string;

Tried --extract-request-params and --route-types but no luck

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions