Skip to content

Order method parameters by path instead of alphabetically #4979

@BlueBeret

Description

@BlueBeret

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 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.

Additional context

name: fernapi/fern-typescript-node-sdk
version: 0.41.0-rc1

slack discussion: chat

Metadata

Metadata

Assignees

No one assigned

    Labels

    product/sdk-generatorFern's SDK Generator that outputs client libraries in 7 languages

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions