code: def add_responses(swagger_operation, operation, ns, func):
      
      # default error
      swagger_operation.responses["default"] = build_response(
          description="An error occurred",
          resource=type_name(name_for(ErrorSchema())),
      )
  
      if getattr(func, "__doc__", None):
          description = func.__doc__.strip().splitlines()[0]
      else:
          description = "{} {}".format(operation.value.name, ns.subject_name)
  
      if operation in (Operation.Upload, Operation.UploadFor):
          swagger_operation.consumes = [
              "multipart/form-data"
          ]
  
      # resource request
      request_resource = get_request_schema(func)
      if isinstance(request_resource, str):
          if not hasattr(swagger_operation, "consumes"):
              swagger_operation.consumes = []
          swagger_operation.consumes.append(request_resource)
  
      # resources response
      response_resource = get_response_schema(func)
      if isinstance(response_resource, str):
          if not hasattr(swagger_operation, "produces"):
              swagger_operation.produces = []
          swagger_operation.produces.append(response_resource)
      elif not response_resource:
          response_code = (
              204
              if operation.value.default_code == 200
              else operation.value.default_code
          )
          swagger_operation.responses[str(response_code)] = build_response(
              description=description,
          )
      else:
          swagger_operation.responses[str(operation.value.default_code)] = build_response(
              description=description,
              resource=response_resource,
          )
docs: Add responses to an operation.