Customizing OpenAPI Definitions

Operation summary

To populate operation.summary, set the header X-OpenAPI-Summary in your response.

Examples

Ruby on Rails

class AccountActivationsController < ApplicationController
  def edit
    response.headers['X-OpenAPI-Summary'] = 'Activate the account of an existing user'

openapi.yaml

/account_activations/{id}/edit:
    get:
      responses:
        '302':
          content: {}
          description: Found
      parameters:
        - name: email
          in: query
          schema:
            type: string
        - name: id
          in: path
          schema:
            type: string
          required: true
      summary: Activate the account of an existing user

Django REST Framework

class UserViewSet(viewsets.ReadOnlyModelViewSet):
    """
    This viewset automatically provides `list` and `detail` actions.
    """
    queryset = User.objects.all()
    serializer_class = UserSerializer

    def list(request, *args, **kwargs):
        response = super().list(request, *args, **kwargs)
        response['X-OpenAPI-Summary'] = 'List users'
        return response

openapi.yml

/users/:
  get:
    responses:
      '200':
        content:
          text/html: {}
        description: OK
    summary: List users

Was this page helpful? thumb_up Yes thumb_down No
Thank you for your feedback!