Skip to content

feat(link): name methods from operationId - #51

Open
dimitropoulos wants to merge 2 commits into
mainfrom
dimitri/operation-id
Open

dimitropoulos wants to merge 2 commits into
mainfrom
dimitri/operation-id

Conversation

@dimitropoulos

Copy link
Copy Markdown
Collaborator

Summary

Methods can now be named from operationId, with the Fern extensions as an optional way to name them.

For each operation:

  1. With both x-fern-sdk-group-name and x-fern-sdk-method-name, neither empty, those name the method.
  2. Otherwise operationId is read as <group path>.<method name>, split at the last dot: pets.list is method list in group pets, and accounts.members.list is method list in group members inside accounts.
  3. An operationId with no dot, such as listPets, makes no method and is not an error.
  4. With neither, there is no method.
  5. x-fern-ignore: true still leaves the operation out, however it is named.

Only one of the two Fern extensions falls through to operationId. Names from operationId follow the same rules as Fern ones:

  • GET /a: operationId has a group name with no letters or digits (for a..b.list, .list)
  • GET /a: operationId has a method name with no letters or digits (for pets.)
  • equal method names in a group are an error, whether the methods are named by Fern or by operationId

An operationId that is not a string is a reading error, like other typed keys.

Aliases

An alias in x-forge-aliases follows the same rule using its own keys: both Fern extensions, or else its own operationId. An alias never takes the operation's operationId. operationId is not an extension, so it never shows up in Method::extensions.

Output change

Documents that already have dotted operationIds and no Fern extensions now produce methods for those operations.

Tests

New tests in tests/parse/methods.rs and tests/parse/aliases.rs cover: dotted and multi-level operationIds, dotless operationIds being ignored, Fern winning over operationId, a single Fern field falling back, x-fern-ignore with an operationId, empty and symbol-only parts as errors, a non-string operationId, aliases named by their own operationId, aliases not inheriting the operation's operationId, and duplicate names between Fern-named and operationId-named methods.

cargo test --locked --all-features, cargo fmt --check and both clippy runs from the lint recipe pass.

Closes #50

An operation or alias with both x-fern-sdk-group-name and
x-fern-sdk-method-name, neither empty, is named by them. Otherwise its
operationId names it as <group path>.<method name>, split at the last
dot: pets.list is the method list in the group pets, and
accounts.members.list is the method list in the group members inside
accounts.

An operationId with no dot, such as listPets, makes no method and is not
an error. x-fern-ignore still leaves the operation out. A group or method
name from an operationId with no letters or digits is an error naming the
operation, and equal method names in a group are an error however the
methods are named.

An alias in x-forge-aliases is named by its own keys in the same way, and
never by the operation's operationId. operationId is not an extension, so
it is not in Method::extensions.
Copilot AI balanced review requested due to automatic review settings October 19, 2026 00:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation and regression coverage match the stated requirements, with no blocking issues identified; tests were inspected but not executed.

No open issues 🎉

What changed in this PR

Adds dotted operationId naming for methods and aliases, making Fern naming extensions optional and addressing #50.

Changes:

  • Falls back to operationId while preserving Fern precedence and name validation.
  • Tests naming, aliases, ignored operations, invalid values, and duplicate names.
  • Documents the naming rules and alias isolation.
File Description
tests/​parse/​methods.rs Tests operation naming and validation.
tests/​parse/​aliases.rs Tests alias naming and independence.
src/​link/​openapi.rs Reads operationId for operations and aliases.
src/​link.rs Implements naming fallback and validation.
src/​lib.rs Documents method and group naming rules.

Review effort: Balanced

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/cloudflare/forge/@cloudflare/forge@51

commit: ac92cae

@srikrsna srikrsna left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just one comment.

Comment thread tests/parse/methods.rs Outdated
Comment thread tests/parse/methods.rs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Name methods from operationId when the Fern extensions are absent

3 participants