openapi-typescript-codegen icon indicating copy to clipboard operation
openapi-typescript-codegen copied to clipboard

Parameter names without camelCase transformation

Open mireq opened this issue 2 years ago • 2 comments

My API uses snake case names. I want API calls in this form:

public objectList({
    page,
    filter_id,
    filter_status,
}: {
    page?: (string | null),
    filter_id?: (number | null),
    filter_status?: (ObjectStatusChoices | null),
}): CancelablePromise<CursorPaginated_ObjectListItem_> {

because filter attributes are defined as model:

export type ObjectFilter = {
    filter_id?: (number | null);
    filter_status?: (ObjectStatusChoices | null);
};

Later in code i am extracting filter functionality to separate functions using ObjectFilter model, but this is not possible because API parameters are modified to camelCase.

Possible solution

I would like to have new parameters, something like:

export enum CaseTransform {
    CAMEL = 'camel',
    NONE = 'none',
}

// ...
parameterNameTransform?: CaseTransform;

Problem, which remains is how to pass additional parameter to getOperationParameterName? There is no global options object and option - pass chain is too deep. Possible solution would be globally available options object. I don't know if this is acceptable.

mireq avatar Oct 18 '23 06:10 mireq

+1 to this. Any plans on implementing this?

vaidik avatar Apr 20 '24 04:04 vaidik

Yes @vaidik. We will remove parameter transformation altogether in https://github.com/hey-api/openapi-ts, it's just faster that way

mrlubos avatar Apr 20 '24 04:04 mrlubos