swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

Add an option to disable converting path params into camelCase

Open Quatters opened this issue 1 year ago • 3 comments

If I have a snake_case path param in original schema like

/some/{path_param}/:
    ...
    parameters:
    - name: path_param
      in: path
      required: true
      type: string

then it'll be converted into camelCase in generated route (using generateRouteTypes: true):

'/some/{path_param}/': {
    get: {
      params: {
        pathParam: number;
      };
      ...
    };
  }

I guess I found this place and I see that this behavior is hard-coded: https://github.com/acacode/swagger-typescript-api/blob/2b6db2346028fe6fb1f311bf5b1221a89837032e/src/schema-routes/schema-routes.js#L252

The problem is that in our project we don't want path params to be converted into camelCase. We expecting that they are stay as given by schema.

Would be nice to have an option for generateApi for disabling this converting. Something like

return generateApi({
  generateRouteTypes: true,
  pathParamsInCamelCase: false, // true by default for example
});

Quatters avatar Aug 23 '23 09:08 Quatters

We also want this functionality. It would be great to use function for that, like with hooks

vitalii-bilous-epa avatar Oct 05 '23 13:10 vitalii-bilous-epa

Same here. Sad this behavior is by default. That makes the library unusable for us.

nathanbrachotte avatar Mar 05 '24 08:03 nathanbrachotte

This issue was introduced by a change created to solve this issue #460

climam avatar Mar 19 '24 16:03 climam