Forum Discussion

lnash94's avatar
lnash94
Champion Level 0
7 months ago

How to document HATEOAS in the OpenAPI specification

Hi Team,

 

I have a REST API with a HATEOAS concept, may I know how can I document it in OpenAPI specifications? I tried in the following way[1] links directing to link schema under the component sections,

 

 

paths:
  /items/{itemId}:
    get:
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  itemId:
                    type: integer
                  itemName:
                    type: string
                  links:
                    type: array
                    items:
                      $ref: '#/components/schemas/Link'
components:
  schemas:
    Link:
      type: object
      properties:
        rel:
          type: string
        href:
          type: string

 

 

later I got to know about the Link section in the response https://swagger.io/docs/specification/links/ , May I know which approach is suitable for the HATEOAS mapping in REST API. 

No RepliesBe the first to reply