question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

default operationId to method name

See original GitHub issue

I’m submitting a…


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

An explicit @ApiOperation() annotation with an explicit operationId is needed in order to set an operation ID.

Expected behavior

The operationId should default to the name of the method that is annotated.

What is the motivation / use case for changing the behavior?

Operation IDs are used by swagger codegen for client method names.

Environment


Nest version: 6.0.1

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
arkraftcommented, May 6, 2019

There is an open pull request for that: #163. It defaults to the method name and you can overwrite it by setting the operationId with the @ApiOperation() decorator

0reactions
marefati110commented, Aug 24, 2021
import { ApiOperation } from '@nestjs/swagger';

export function DecoratorName(options: { operationId: string; summary: string; deprecated: boolean }) {
  return function (target: any, key: any, descriptor: PropertyDescriptor) {
    ApiOperation({
      operationId: options.operationId || key,
      summary: options.summary,
      deprecated: options.deprecated,
    })(target, key, descriptor as any);
    return descriptor;
  };
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Paths and Operations - Swagger
Some common use cases for operationId are: Some code generators use this value to name the corresponding methods in code. Links can refer...
Read more >
c# - Net Core: Swashbuckle Set operationId Automatically on ...
We are trying to override Swashbuckle/Swagger IO CodeGen naming conventions, ... Name should equal name of Action Method within Controller.
Read more >
Path Operation Advanced Configuration - FastAPI
If you want to use your APIs' function names as operationId s, you can iterate over all of them and override each path...
Read more >
OpenAPI Spec Simplification - FastAPI Utilities
When generating the OpenAPI spec, by default FastAPI includes the function name, endpoint path, and request method, in the generated operationId :.
Read more >
Decorators | tsoa - GitHub Pages
Set operationId parameter under operation's path. Useful for use with OpenAPI code generation tool since this parameter is used to name the function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found