Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

separating commands by tags #224

Open
jmls opened this issue Oct 20, 2023 · 1 comment
Open

separating commands by tags #224

jmls opened this issue Oct 20, 2023 · 1 comment

Comments

@jmls
Copy link

jmls commented Oct 20, 2023

if I have an openapi spec that has a number of tags (let say "foo" and "bar") then when I do a restish myapi -h I get

Usage:
  restish myapi [command]
  
  foo commands:
    update
    
  bar commands
    update
    
    

yes, my operation ids are the same (using nestjs and controllers, so generated from the method name)

I was hoping to be able to do something like

restish myapi foo update
restish myapi bar update

but it seems not.

Am I forced into changing the operationIds to be fooUpdate and barUpdate ? my restish api then looks like this

Usage:
  restish myapi [command]
  
  foo commands:
    fooupdate
    
  bar commands
    barupdate
    
    

which kinda looks .. sucky ;)

So in a nutshell, I 'm looking for some way of using the tags in the spec to specify a command and sub-command (tag / operratiionid)

@danielgtaylor
Copy link
Owner

danielgtaylor commented Oct 23, 2023

@jmls great question. Right now Restish is set up to have a flat list of operation commands rather than a hierarchy like you are describing. There are a few different ways you could make a hierarchy and it's not easy to do this in a generic way that would work for everyone, but I'm open to ideas!

As for using the same operation ID multiple times... see the OpenAPI spec:

Unique string used to identify the operation. The id MUST be unique among all operations described in the API. The operationId value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions.

I'm not sure what nestjs is doing or recommends, but the spec says they must be unique, which is why Restish uses them as the unique command name.

Edit: also just FYI, you can provide an OpenAPI extension x-cli-name which overrides the operation name in Restish to anything you like. See here: https://rest.sh/#/openapi?id=name

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

No branches or pull requests

2 participants