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 input settings for view functions.
  
  If the validation passed, the data will be injected into the view
  function as a keyword argument in the form of `dict` and named `{location}_data`.
  Otherwise, an error response with the detail of the validation result will be
  returned.
  
  > Be sure to put it under the routes decorators (i.e., `app.route`, `app.get`,
  `app.post`, etc.).
  
  Examples:
  
  ```python
  from apiflask import APIFlask
  
  app = APIFlask(__name__)
  
  @app.get('/')
  @app.input(PetIn, location='json')
  def hello(json_data):
      print(json_data)
      return 'Hello'!
  ```
  
  Arguments:
      schema: The marshmallow schema of the input data.
      location: The location of the input data, one of `'json'` (default),
          `'files'`, `'form'`, `'cookies'`, `'headers'`, `'query'`
          (same as `'querystring'`).
      arg_name: The name of the argument passed to the view function,
          defaults to `{location}_data`.
      schema_name: The schema name for dict schema, only needed when you pass
          a schema dict (e.g., `{'name': String(required=True)}`) for `json`
          location.
      example: The example data in dict for request body, you should use either
          `example` or `examples`, not both.
      examples: Multiple examples for request 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}
              },
          }
          ```
  
  *Version changed: 2.0.0*
  
  - Always pass parsed data to view function as a keyword argument.
    The argument name will be in the form of `{location}_data`.
  
  *Version changed: 1.0*
  
  - Ensure only one input body location was used.
  - Add `form_and_files` and `json_or_form` (from webargs) location.
  - Rewrite `files` to act as `form_and_files`.
  - Use correct request content type for `form` and `files`.
  
  *Version changed: 0.12.0*
  
  - Move to APIFlask and APIBlueprint classes.
  
  *Version changed: 0.4.0*
  
  - Add parameter `examples`.
docstr_tok: ["Add","input","settings","for","view","functions",".","If","the","validation","passed",",","the","data","will","be","injected","into","the","view","function","as","a","keyword","argument","in","the","form","of","`","dict","`","and","named","`","{","location","}","_data","`",".","Otherwise",",","an","error","response","with","the","detail","of","the","validation","result","will","be","returned",".",">","Be","sure","to","put","it","under","the","routes","decorators","(","i.e.",",","`","app.route","`",",","`","app.get","`",",","`","app.post","`",",","etc.",")",".","Examples",":","``","`","python","from","apiflask","import","APIFlask","app","=","APIFlask","(","__name__",")","@","app.get","(","'\/","'",")","@","app.input","(","PetIn",",","location='json","'",")","def","hello","(","json_data",")",":","print","(","json_data",")","return","'Hello","'","!","``","`","Arguments",":","schema",":","The","marshmallow","schema","of","the","input","data",".","location",":","The","location","of","the","input","data",",","one","of","`","'json","'","`","(","default",")",",","`","'files","'","`",",","`","'form","'","`",",","`","'cookies","'","`",",","`","'headers","'","`",",","`","'query","'","`","(","same","as","`","'querystring","'","`",")",".","arg_name",":","The","name","of","the","argument","passed","to","the","view","function",",","defaults","to","`","{","location","}","_data","`",".","schema_name",":","The","schema","name","for","dict","schema",",","only","needed","when","you","pass","a","schema","dict","(","e.g.",",","`","{","'name","'",":","String","(","required=True",")","}","`",")","for","`","json","`","location",".","example",":","The","example","data","in","dict","for","request","body",",","you","should","use","either","`","example","`","or","`","examples","`",",","not","both",".","examples",":","Multiple","examples","for","request","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","}","}",",","}","``","`","*","Version","changed",":","2.0.0","*","-","Always","pass","parsed","data","to","view","function","as","a","keyword","argument",".","The","argument","name","will","be","in","the","form","of","`","{","location","}","_data","`",".","*","Version","changed",":","1.0","*","-","Ensure","only","one","input","body","location","was","used",".","-","Add","`","form_and_files","`","and","`","json_or_form","`","(","from","webargs",")","location",".","-","Rewrite","`","files","`","to","act","as","`","form_and_files","`",".","-","Use","correct","request","content","type","for","`","form","`","and","`","files","`",".","*","Version","changed",":","0.12.0","*","-","Move","to","APIFlask","and","APIBlueprint","classes",".","*","Version","changed",":","0.4.0","*","-","Add","parameter","`","examples","`","."]
code: def input(
      self,
      schema: SchemaType,
      location: str = "json",
      arg_name: 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,
      **kwargs: t.Any,
  ) -> t.Callable[[DecoratedType], DecoratedType]:
      """Add input settings for view functions.
  
      If the validation passed, the data will be injected into the view
      function as a keyword argument in the form of `dict` and named `{location}_data`.
      Otherwise, an error response with the detail of the validation result will be
      returned.
  
      > Be sure to put it under the routes decorators (i.e., `app.route`, `app.get`,
      `app.post`, etc.).
  
      Examples:
  
      ```python
      from apiflask import APIFlask
  
      app = APIFlask(__name__)
  
      @app.get('/')
      @app.input(PetIn, location='json')
      def hello(json_data):
          print(json_data)
          return 'Hello'!
      ```
  
      Arguments:
          schema: The marshmallow schema of the input data.
          location: The location of the input data, one of `'json'` (default),
              `'files'`, `'form'`, `'cookies'`, `'headers'`, `'query'`
              (same as `'querystring'`).
          arg_name: The name of the argument passed to the view function,
              defaults to `{location}_data`.
          schema_name: The schema name for dict schema, only needed when you pass
              a schema dict (e.g., `{'name': String(required=True)}`) for `json`
              location.
          example: The example data in dict for request body, you should use either
              `example` or `examples`, not both.
          examples: Multiple examples for request 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}
                  },
              }
              ```
  
      *Version changed: 2.0.0*
  
      - Always pass parsed data to view function as a keyword argument.
        The argument name will be in the form of `{location}_data`.
  
      *Version changed: 1.0*
  
      - Ensure only one input body location was used.
      - Add `form_and_files` and `json_or_form` (from webargs) location.
      - Rewrite `files` to act as `form_and_files`.
      - Use correct request content type for `form` and `files`.
  
      *Version changed: 0.12.0*
  
      - Move to APIFlask and APIBlueprint classes.
  
      *Version changed: 0.4.0*
  
      - Add parameter `examples`.
      """
      if isinstance(schema, ABCMapping):
          schema = _generate_schema_from_mapping(schema, schema_name)
      if isinstance(schema, type):  # pragma: no cover
          schema = schema()
  
      def decorator(f):
          f = _ensure_sync(f)
          is_body_location = location in BODY_LOCATIONS
          if (
              is_body_location
              and hasattr(f, "_spec")
              and "body" in f._spec
          ):
              raise RuntimeError(
                  "When using the app.input() decorator, you can only declare one request "
                  'body location (one of "json", "form", "files", "form_and_files", '
                  'and "json_or_form").'
              )
          if location == "json":
              _annotate(
                  f,
                  body=schema,
                  body_example=example,
                  body_examples=examples,
              )
          elif location == "form":
              _annotate(
                  f,
                  body=schema,
                  body_example=example,
                  body_examples=examples,
                  content_type="application/x-www-form-urlencoded",
              )
          elif location in ["files", "form_and_files"]:
              _annotate(
                  f,
                  body=schema,
                  body_example=example,
                  body_examples=examples,
                  content_type="multipart/form-data",
              )
          else:
              if not hasattr(f, "_spec") or f._spec.get("args") is None:
                  _annotate(f, args=[])
              if location == "path":
                  _annotate(f, omit_default_path_parameters=True)
              # TODO: Support set example for request parameters
              f._spec["args"].append((schema, location))
          return use_args(
              schema,
              location=location,
              arg_name=arg_name or f"{location}_data",
              **kwargs,
          )(f)
  
      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 8 for calling the APIScaffold obj's underlying member method code with example usage: obj.input(schema, location, arg_name, schema_name, example, examples) and returns: decorator, use_args