contiamo / restful-react

A consistent, declarative way of interacting with RESTful backends, featuring code-generation from Swagger and OpenAPI specs 🔥
MIT License
1.87k stars 109 forks source link

Final path parameter in DELETE requests is excluded from generated interfaces in `--skipReact` mode #366

Closed s-thom closed 3 years ago

s-thom commented 3 years ago

Describe the bug

The final path parameter is excluded from the generated *PathParams interface

To Reproduce Steps to reproduce the behavior:

  1. Create a path with a path parameter in the last segment of the path
  2. Define a GET and a DELETE operation for the path, properly defining all path parameters
  3. Generate a .ts file using restful-react --skipReact
  4. Observe the parameter's presence in the GET request, but not in the DELETE

An example reproduction can be found in this repository.

Expected behavior

I expect all path parameters to be defined in the generated interfaces.

Additional context

This is related to #334, which also found this case, but determined that it was a feature. In the cases of generating components, as described in the comment I tend to agree with this idea (though documentation would be nice). However, in the case of --skipReact, we won't have the <Delete /> component passing a function to fill in this last parameter. I believe it is more intuitive to include all parameters in the PathParams interface.

I suggest that this change only applies to --skipReact mode, so that it does not affect the primary use-case of this library. It would be a breaking change, as there may be others using --skipReact that are relying on this behaviour.

s-thom commented 3 years ago

From my quick investigation into this issue, I believe it can be resolved by not filtering the path parameters array if skipReact is true.