Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swagger: Add fields to all endpoints

Is there a way to add default fields to all of my end-points? I wish to add fields like api_key, sort, limit etc. to all of my end points.

Can you add a set of default input parameters to all end points in a central location?

like image 606
ChrisRich Avatar asked Nov 27 '25 08:11

ChrisRich


1 Answers

You can define Parameters like

"parameters": {
"skipParam": {
  "name": "skip",
  "in": "query",
  "description": "number of items to skip",
  "required": true,
  "type": "integer",
  "format": "int32"
},

and then use it like

 "parameters": [
      { "$ref": "#/parameters/skipParam" }
],

Using this, you will not have to specify parameter details again and again but will need to add ref where required.

More details can be found at Open Api Specification

like image 186
Bilal Akbar Avatar answered Dec 02 '25 05:12

Bilal Akbar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!