You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering why Fern orders method parameters alphabetically. Wouldn't it make more sense to order them by the path?
For example, given an API with the path /api/v1/orgs/{org}/folder/{folder}/file/{file}/, Fern generates a method like getSomething(file, folder, org). Wouldn't it make more sense to have the arguments ordered as getSomething(org, folder, file) instead?
Why would it be useful?
Ordering parameters by the path would align the method signature with the logical flow of the API structure. This can make the code more intuitive for developers to read and understand, especially when dealing with APIs that reflect a hierarchical or domain-specific structure. It can also prevent confusion and reduce the learning curve when working across multiple endpoints.
Or even better, the method could use keyword arguments (kwargs) or a dictionary-like approach, such as doSomething(props), where the arguments would be passed as doSomething({org: 1, folder: 2, file: 3}). This would further enhance flexibility and clarity, especially as the number of parameters grows.
Describe the solution (optional)
A possible solution could be to provide an option in the SDK configuration to allow users to choose whether to order parameters alphabetically or based on their order in the API path. Another option would be to allow the use of keyword arguments or a dictionary approach, which would give more flexibility when passing parameters.
Problem description
I was wondering why Fern orders method parameters alphabetically. Wouldn't it make more sense to order them by the path?
For example, given an API with the path
/api/v1/orgs/{org}/folder/{folder}/file/{file}/
, Fern generates a method likegetSomething(file, folder, org)
. Wouldn't it make more sense to have the arguments ordered asgetSomething(org, folder, file)
instead?Why would it be useful?
Ordering parameters by the path would align the method signature with the logical flow of the API structure. This can make the code more intuitive for developers to read and understand, especially when dealing with APIs that reflect a hierarchical or domain-specific structure. It can also prevent confusion and reduce the learning curve when working across multiple endpoints.
Or even better, the method could use keyword arguments (kwargs) or a dictionary-like approach, such as
doSomething(props)
, where the arguments would be passed asdoSomething({org: 1, folder: 2, file: 3})
. This would further enhance flexibility and clarity, especially as the number of parameters grows.Describe the solution (optional)
A possible solution could be to provide an option in the SDK configuration to allow users to choose whether to order parameters alphabetically or based on their order in the API path. Another option would be to allow the use of keyword arguments or a dictionary approach, which would give more flexibility when passing parameters.
Additional context
slack discussion: chat
The text was updated successfully, but these errors were encountered: