swag icon indicating copy to clipboard operation
swag copied to clipboard

Add support for top level parameters

Open watzon opened this issue 10 months ago • 1 comments

Is your feature request related to a problem? Please describe. It doesn't seem as though defining params at the top level currently works, only at the API route level.

Describe the solution you'd like It would be nice to follow the current convention and just allow for @Param tags to work at the top level.

As an example, this is more or less what I'm trying to emulate:

swagger: "2.0"
info:
  description: |
    This is a swagger defenition for [Telegram bot API](https://core.telegram.org/bots/api).
  version: "3.6"
  title: Telegram bot API
externalDocs:
  description: Find out more about Telegram bot API
  url: https://core.telegram.org/bots/api
host: api.telegram.org
schemes:
 - https
consumes:
- application/json
produces:
- application/json
basePath: /
parameters:
  token:
    in: path
    name: token
    required: false
    type: string
    description: bot's token to authorize the request

Describe alternatives you've considered Manually editing the generated docs or adding the parameters to each individual route seem to be the only solutions for now, unless I'm missing something and this is already possible.

watzon avatar Jan 28 '25 21:01 watzon

Not sure about your use case , usually having a global defined parameter will end up adding exclusions in different routes instead of defining it where it is required. This is an OOS project and you can contribute with an PR if this change would make your life easier.

ubogdan avatar Aug 18 '25 10:08 ubogdan