acacode / swagger-typescript-api

Generate the API Client for Fetch or Axios from an OpenAPI Specification
MIT License
3.08k stars 338 forks source link

Version 13.0.10 doesn't respect `onInsertPathParam` hook #806

Closed ramondeklein closed 3 days ago

ramondeklein commented 4 days ago

I'm using the following custom configuration:

module.exports = {
  hooks: {
    onInsertPathParam: (paramName) => `encodeURIComponent(${paramName})`,
  },
};

This encodes all parameters using encodeURIComponent in the URL path. This works great with v13.0.9, but it doesn't work with v13.0.10 anymore.

This is generated with v13.0.9:

    deleteBucket: (name: string, params: RequestParams = {}) =>
      this.request<void, ApiError>({
        path: `/buckets/${encodeURIComponent(name)}`,
        method: "DELETE",
        secure: true,
        ...params,
      }),

This is generated with v13.0.10:

    deleteBucket: (name: string, params: RequestParams = {}) =>
      this.request<void, ApiError>({
        path: `/buckets/${name}`,
        method: "DELETE",
        secure: true,
        ...params,
      }),
shrpne commented 4 days ago

Loading of custom config is broken in 13.0.10, downgrading to 13.0.9 should help

@smorimoto Probably replacing require() with import() should fix it index.js#L304 Also it is a good idea to display an error instead of hiding it index.js#L306

smorimoto commented 4 days ago

I'm away from home today and can't deal with this right away, so the patch is very welcome.

ramondeklein commented 2 days ago

This fix didn't solve our issue. It's still broken with 13.0.12. Could this issue be reopened?