Thursday 19 March 2020

Swagger Editor: Adding headers to the API

You can add headers to an api using below snippet.
- in: header
  name: onetime_token
  description: token to be used at the time of login
  required: false
  schema:
    type: string
    example: 08c3372a-9314-49d6-b9dd-ff212c1715a5

data.yaml
openapi: 3.0.0
info:
  title: Customer Data Aceess API
  description: API to expose all the CRUD operations on  customers
  contact:
    name: Krishna
    email: krishna123@abc.com
    url: https://self-learning-java-tutorial.blogspot.com/
  version: 1.0.0
paths:
  /employees/{employeeId}:
    get:
      parameters: 
      - in: path
        name: employeeId
        required: true
        schema:
          type: integer
          example: 123
      responses:

Add data.yaml file content to swagger editor, you can see the respective API definition in right side of the window.



Previous                                                    Next                                                    Home

No comments:

Post a Comment