ChrisRich
ChrisRich

Reputation: 8736

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?

Upvotes: 3

Views: 721

Answers (1)

Bilal Akbar
Bilal Akbar

Reputation: 4970

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

Upvotes: 1

Related Questions