class_docstr: A base class for [`APIFlask`][apiflask.app.APIFlask] and
  [`APIBlueprint`][apiflask.blueprint.APIBlueprint].
  
  This class contains the route shortcut decorators (i.e. `get`, `post`, etc.) and
  API-related decorators (i.e. `auth_required`, `input`, `output`, `doc`).
  
  *Version added: 1.0*
docstr: Add output settings for view functions.
  
  > Be sure to put it under the routes decorators (i.e., `app.route`, `app.get`,
  `app.post`, etc.).
  
  The decorator will format the return value of your view function with
  provided marshmallow schema. You can return a dict or an object (such
  as a model class instance of ORMs). APIFlask will handle the formatting
  and turn your return value into a JSON response.
  
  P.S. The output data will not be validated; it's a design choice of marshmallow.
  marshmallow 4.0 may be support the output validation.
  
  Examples:
  
  ```python
  from apiflask import APIFlask
  
  app = APIFlask(__name__)
  
  @app.get('/')
  @app.output(PetOut)
  def hello():
      return the_dict_or_object_match_petout_schema
  ```
  
  Arguments:
      schema: The schemas of the output data.
      status_code: The status code of the response, defaults to `200`.
      description: The description of the response.
      schema_name: The schema name for dict schema, only needed when you pass
          a schema dict (e.g., `{'name': String()}`).
      example: The example data in dict for response body, you should use either
          `example` or `examples`, not both.
      examples: Multiple examples for response body, you should pass a dict
          that contains multiple examples. Example:
  
          ```python
          {
              'example foo': {  # example name
                  'summary': 'an example of foo',  # summary field is optional
                  'value': {'name': 'foo', 'id': 1}  # example value
              },
              'example bar': {
                  'summary': 'an example of bar',
                  'value': {'name': 'bar', 'id': 2}
              },
          }
          ```
      links: The `links` of response. It accepts a dict which maps a link name to
          a link object. Example:
  
          ```python
          {
              'getAddressByUserId': {
                  'operationId': 'getUserAddress',
                  'parameters': {
                      'userId': '$request.path.id'
                  }
              }
          }
          ```
  
          See the [docs](https://apiflask.com/openapi/#response-links) for more details
          about setting response links.
  
      content_type: The content/media type of the response. It defautls to `application/json`.
      headers: The schemas of the headers.
  
  *Version changed: 2.1.0*
  
  - Add parameter `headers`.
  
  *Version changed: 2.0.0*
  
  - Don't change the status code to 204 for EmptySchema.
  
  *Version changed: 1.3.0*
  
  - Add parameter `content_type`.
  
  *Version changed: 0.12.0*
  
  - Move to APIFlask and APIBlueprint classes.
  
  *Version changed: 0.10.0*
  
  - Add `links` parameter.
  
  *Version changed: 0.9.0*
  
  - Add base response customization support.
  
  *Version changed: 0.6.0*
  
  - Support decorating async views.
  
  *Version changed: 0.5.2*
  
  - Return the `Response` object directly.
  
  *Version changed: 0.4.0*
  
  - Add parameter `examples`.
docstr_tok: ["Add","output","settings","for","view","functions",".",">","Be","sure","to","put","it","under","the","routes","decorators","(","i.e.",",","`","app.route","`",",","`","app.get","`",",","`","app.post","`",",","etc.",")",".","The","decorator","will","format","the","return","value","of","your","view","function","with","provided","marshmallow","schema",".","You","can","return","a","dict","or","an","object","(","such","as","a","model","class","instance","of","ORMs",")",".","APIFlask","will","handle","the","formatting","and","turn","your","return","value","into","a","JSON","response",".","P.S",".","The","output","data","will","not","be","validated",";","it","'s","a","design","choice","of","marshmallow",".","marshmallow","4.0","may","be","support","the","output","validation",".","Examples",":","``","`","python","from","apiflask","import","APIFlask","app","=","APIFlask","(","__name__",")","@","app.get","(","'\/","'",")","@","app.output","(","PetOut",")","def","hello","(",")",":","return","the_dict_or_object_match_petout_schema","``","`","Arguments",":","schema",":","The","schemas","of","the","output","data",".","status_code",":","The","status","code","of","the","response",",","defaults","to","`","200","`",".","description",":","The","description","of","the","response",".","schema_name",":","The","schema","name","for","dict","schema",",","only","needed","when","you","pass","a","schema","dict","(","e.g.",",","`","{","'name","'",":","String","(",")","}","`",")",".","example",":","The","example","data","in","dict","for","response","body",",","you","should","use","either","`","example","`","or","`","examples","`",",","not","both",".","examples",":","Multiple","examples","for","response","body",",","you","should","pass","a","dict","that","contains","multiple","examples",".","Example",":","``","`","python","{","'example","foo","'",":","{","#","example","name","'summary","'",":","'an","example","of","foo","'",",","#","summary","field","is","optional","'value","'",":","{","'name","'",":","'foo","'",",","'id","'",":","1","}","#","example","value","}",",","'example","bar","'",":","{","'summary","'",":","'an","example","of","bar","'",",","'value","'",":","{","'name","'",":","'bar","'",",","'id","'",":","2","}","}",",","}","``","`","links",":","The","`","links","`","of","response",".","It","accepts","a","dict","which","maps","a","link","name","to","a","link","object",".","Example",":","``","`","python","{","'getAddressByUserId","'",":","{","'operationId","'",":","'getUserAddress","'",",","'parameters","'",":","{","'userId","'",":","'","$","request.path.id'","}","}","}","``","`","See","the","[","docs","]","(","https",":","\/\/apiflask.com\/openapi\/","#","response-links",")","for","more","details","about","setting","response","links",".","content_type",":","The","content\/media","type","of","the","response",".","It","defautls","to","`","application\/json","`",".","headers",":","The","schemas","of","the","headers",".","*","Version","changed",":","2.1.0","*","-","Add","parameter","`","headers","`",".","*","Version","changed",":","2.0.0","*","-","Do","n't","change","the","status","code","to","204","for","EmptySchema",".","*","Version","changed",":","1.3.0","*","-","Add","parameter","`","content_type","`",".","*","Version","changed",":","0.12.0","*","-","Move","to","APIFlask","and","APIBlueprint","classes",".","*","Version","changed",":","0.10.0","*","-","Add","`","links","`","parameter",".","*","Version","changed",":","0.9.0","*","-","Add","base","response","customization","support",".","*","Version","changed",":","0.6.0","*","-","Support","decorating","async","views",".","*","Version","changed",":","0.5.2","*","-","Return","the","`","Response","`","object","directly",".","*","Version","changed",":","0.4.0","*","-","Add","parameter","`","examples","`","."]
code: def output(
      self,
      schema: SchemaType,
      status_code: int = 200,
      description: t.Optional[str] = None,
      schema_name: t.Optional[str] = None,
      example: t.Optional[t.Any] = None,
      examples: t.Optional[t.Dict[str, t.Any]] = None,
      links: t.Optional[t.Dict[str, t.Any]] = None,
      content_type: t.Optional[str] = "application/json",
      headers: t.Optional[SchemaType] = None,
  ) -> t.Callable[[DecoratedType], DecoratedType]:
      """Add output settings for view functions.
  
      > Be sure to put it under the routes decorators (i.e., `app.route`, `app.get`,
      `app.post`, etc.).
  
      The decorator will format the return value of your view function with
      provided marshmallow schema. You can return a dict or an object (such
      as a model class instance of ORMs). APIFlask will handle the formatting
      and turn your return value into a JSON response.
  
      P.S. The output data will not be validated; it's a design choice of marshmallow.
      marshmallow 4.0 may be support the output validation.
  
      Examples:
  
      ```python
      from apiflask import APIFlask
  
      app = APIFlask(__name__)
  
      @app.get('/')
      @app.output(PetOut)
      def hello():
          return the_dict_or_object_match_petout_schema
      ```
  
      Arguments:
          schema: The schemas of the output data.
          status_code: The status code of the response, defaults to `200`.
          description: The description of the response.
          schema_name: The schema name for dict schema, only needed when you pass
              a schema dict (e.g., `{'name': String()}`).
          example: The example data in dict for response body, you should use either
              `example` or `examples`, not both.
          examples: Multiple examples for response body, you should pass a dict
              that contains multiple examples. Example:
  
              ```python
              {
                  'example foo': {  # example name
                      'summary': 'an example of foo',  # summary field is optional
                      'value': {'name': 'foo', 'id': 1}  # example value
                  },
                  'example bar': {
                      'summary': 'an example of bar',
                      'value': {'name': 'bar', 'id': 2}
                  },
              }
              ```
          links: The `links` of response. It accepts a dict which maps a link name to
              a link object. Example:
  
              ```python
              {
                  'getAddressByUserId': {
                      'operationId': 'getUserAddress',
                      'parameters': {
                          'userId': '$request.path.id'
                      }
                  }
              }
              ```
  
              See the [docs](https://apiflask.com/openapi/#response-links) for more details
              about setting response links.
  
          content_type: The content/media type of the response. It defautls to `application/json`.
          headers: The schemas of the headers.
  
      *Version changed: 2.1.0*
  
      - Add parameter `headers`.
  
      *Version changed: 2.0.0*
  
      - Don't change the status code to 204 for EmptySchema.
  
      *Version changed: 1.3.0*
  
      - Add parameter `content_type`.
  
      *Version changed: 0.12.0*
  
      - Move to APIFlask and APIBlueprint classes.
  
      *Version changed: 0.10.0*
  
      - Add `links` parameter.
  
      *Version changed: 0.9.0*
  
      - Add base response customization support.
  
      *Version changed: 0.6.0*
  
      - Support decorating async views.
  
      *Version changed: 0.5.2*
  
      - Return the `Response` object directly.
  
      *Version changed: 0.4.0*
  
      - Add parameter `examples`.
      """
      if schema == {}:
          schema = EmptySchema
      if isinstance(schema, ABCMapping):
          schema = _generate_schema_from_mapping(schema, schema_name)
      if isinstance(schema, type):  # pragma: no cover
          schema = schema()
  
      if headers is not None:
          if headers == {}:
              headers = EmptySchema
          if isinstance(headers, ABCMapping):
              headers = _generate_schema_from_mapping(headers, None)
          if isinstance(headers, type):
              headers = headers()
  
      def decorator(f):
          f = _ensure_sync(f)
          _annotate(
              f,
              response={
                  "schema": schema,
                  "status_code": status_code,
                  "description": description,
                  "example": example,
                  "examples": examples,
                  "links": links,
                  "content_type": content_type,
                  "headers": headers,
              },
          )
  
          def _jsonify(
              obj: t.Any,
              many: bool = _sentinel,  # type: ignore
              *args: t.Any,
              **kwargs: t.Any,
          ) -> Response:  # pragma: no cover
              """From Flask-Marshmallow, see the NOTICE file for license information."""
              if many is _sentinel:
                  many = schema.many  # type: ignore
              base_schema: OpenAPISchemaType = current_app.config[
                  "BASE_RESPONSE_SCHEMA"
              ]
              if base_schema is not None and status_code != 204:
                  data_key: str = current_app.config[
                      "BASE_RESPONSE_DATA_KEY"
                  ]
  
                  if isinstance(obj, dict):
                      if data_key not in obj:
                          raise RuntimeError(
                              f"The data key {data_key!r} is not found in the returned dict."
                          )
                      obj[data_key] = schema.dump(obj[data_key], many=many)  # type: ignore
                  else:
                      if not hasattr(obj, data_key):
                          raise RuntimeError(
                              f"The data key {data_key!r} is not found in the returned object."
                          )
                      setattr(
                          obj,
                          data_key,
                          schema.dump(getattr(obj, data_key), many=many),  # type: ignore
                      )
  
                  data = base_schema().dump(obj)  # type: ignore
              else:
                  data = schema.dump(obj, many=many)  # type: ignore
              return jsonify(data, *args, **kwargs)
  
          @wraps(f)
          def _response(
              *args: t.Any, **kwargs: t.Any
          ) -> ResponseReturnValueType:
              rv = f(*args, **kwargs)
              if isinstance(rv, Response):
                  return rv
              if not isinstance(rv, tuple):
                  return _jsonify(rv), status_code
              json = _jsonify(rv[0])
              if len(rv) == 2:
                  rv = (
                      (json, rv[1])
                      if isinstance(rv[1], int)
                      else (json, status_code, rv[1])
                  )
              elif len(rv) >= 3:
                  rv = (json, rv[1], rv[2])
              else:
                  rv = (json, status_code)
              return rv  # type: ignore
  
          return _response
  
      return decorator
  
imports: import typing
  from collections.abc import Mapping
  from functools import wraps
  from flask import current_app
  from flask import jsonify
  from flask import Response
  from marshmallow import ValidationError
  from webargs.flaskparser import FlaskParser
  from webargs.multidictproxy import MultiDictProxy
  from .exceptions import _ValidationError
  from .helpers import _sentinel
  from .schemas import EmptySchema
  from .schemas import Schema
  from .types import DecoratedType
  from .types import DictSchemaType
  from .types import HTTPAuthType
  from .types import OpenAPISchemaType
  from .types import RequestType
  from .types import ResponseReturnValueType
  from .types import ResponsesType
  from .types import SchemaType
  from .views import MethodView
label_desc: Use image node_id 9 for calling the APIScaffold obj's underlying member method code with example usage: obj.output(schema, status_code, description, schema_name, example, examples, links, content_type, headers) and returns: decorator, _response, jsonify, rv, rv, _jsonify,  status_code