def _add_swagger_integration(self, api, function):
swagger_body = api.get("<STR_LIT>")<EOL>if swagger_body is None:<EOL><INDENT>return<EOL><DEDENT>function_arn = function.get_runtime_attr('<STR_LIT>')<EOL>partition = ArnGenerator.get_partition_name()<EOL>uri = fnSub('<STR_LIT>' + partition + '<STR_LIT>' +<EOL>make_shorthand(function_arn) + '<STR_LIT>')<EOL>editor = SwaggerEditor(swagger_body)<EOL>if editor.has_integration(self.Path, self.Method):<EOL><INDENT>raise InvalidEventException(<EOL>self.relative_id,<EOL>'<STR_LIT>'.format(<EOL>method=self.Method, path=self.Path))<EOL><DEDENT>condition = None<EOL>if CONDITION in function.resource_attributes:<EOL><INDENT>condition = function.resource_attributes[CONDITION]<EOL><DEDENT>editor.add_lambda_integration(self.Path, self.Method, uri, self.Auth, api.get('<STR_LIT>'), condition=condition)<EOL>if self.Auth:<EOL><INDENT>method_authorizer = self.Auth.get('<STR_LIT>')<EOL>if method_authorizer:<EOL><INDENT>api_auth = api.get('<STR_LIT>')<EOL>api_authorizers = api_auth and api_auth.get('<STR_LIT>')<EOL>if method_authorizer != '<STR_LIT>':<EOL><INDENT>if not api_authorizers:<EOL><INDENT>raise InvalidEventException(<EOL>self.relative_id,<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>authorizer=method_authorizer, method=self.Method, path=self.Path))<EOL><DEDENT>if method_authorizer != '<STR_LIT>' and not api_authorizers.get(method_authorizer):<EOL><INDENT>raise InvalidEventException(<EOL>self.relative_id,<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>authorizer=method_authorizer, method=self.Method, path=self.Path))<EOL><DEDENT>if method_authorizer == '<STR_LIT>' and not api_auth.get('<STR_LIT>'):<EOL><INDENT>raise InvalidEventException(<EOL>self.relative_id,<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>method=self.Method, path=self.Path))<EOL><DEDENT><DEDENT>editor.add_auth_to_method(api=api, path=self.Path, method_name=self.Method, auth=self.Auth)<EOL><DEDENT><DEDENT>api["<STR_LIT>"] = editor.swagger<EOL>
Adds the path and method for this Api event source to the Swagger body for the provided RestApi.

        :param model.apigateway.ApiGatewayRestApi rest_api: the RestApi to which the path and method should be added.