
    ,h                      U d Z ddlmZ ddlZddlZddlZddlZddlZddl	Z	ddl
mZmZ ddlmZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZmZmZmZmZmZmZmZmZm Z  ddl!Z!dd
l!m"Z"m#Z#m$Z$m%Z% ddl&m'Z' ddl(m)Z)m*Z*m+Z+m,Z, ddl-m.Z. ddl/m0Z0m1Z1 ddl2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9 ddl:m;Z; ddl<m=Z=m>Z> ddl?m@Z@mAZAmBZB er ddlCmDZD ddlEmFZFmGZG ddlHmIZI ddlJmKZK ddlLmMZM ee$j                  e$j                  f   ZP	 eQeRef   ZS	 ed   ZT	 dddZUdeVd<   ed   ZW	  G d d eX      ZY eZ       Z[	 d!Z\	  ed"eR      Z] ed#eR      Z^ ed$eR      Z_e`e]eTf   Za ed%e&      Zb ej                  d?i e7j                   G d' d(             Ze G d) d*      Zfd+e\efd,f	 	 	 	 	 	 	 	 	 	 	 d@d-Zgd+dde\efd.	 	 	 	 	 	 	 	 	 	 	 	 	 dAd/ZheeiejeRekde`d0   e`e`eRd1f   d2f   f   Zld3eVd1<   dBd4ZmdCd5Zn ej                  d?i e7j                   G d6 d7             Zo G d8 d9      ZpdDd:Zq ed;      Zrereerd2f   Zsn) ej                  d?i e7j                   G d< d=             ZsdEd>Zty)Fa  !!! abstract "Usage Documentation"
    [JSON Schema](../concepts/json_schema.md)

The `json_schema` module contains classes and functions to allow the way [JSON Schema](https://json-schema.org/)
is generated to be customized.

In general you shouldn't need to use this module directly; instead, you can use
[`BaseModel.model_json_schema`][pydantic.BaseModel.model_json_schema] and
[`TypeAdapter.json_schema`][pydantic.TypeAdapter.json_schema].
    )annotationsN)Counterdefaultdict)HashableIterableSequence)deepcopy)Enum)Pattern)
TYPE_CHECKING	AnnotatedAnyCallableLiteralNewTypeTypeVarUnioncastoverload)
CoreSchemaPydanticOmitcore_schemato_jsonable_python)ComputedField)	TypeAliasassert_never
deprecatedfinal)get_literal_values)PydanticDeprecatedSince26PydanticDeprecatedSince29   )_config_core_metadata_core_utils_decorators_internal_dataclass_mock_val_ser_schema_generation_shared)GetJsonSchemaHandler)JsonDict	JsonValue)PydanticInvalidForJsonSchemaPydanticSchemaGenerationErrorPydanticUserError)
ConfigDict)CoreSchemaFieldCoreSchemaOrField)PydanticDataclass)GetJsonSchemaFunction	BaseModel)
validationserializationInputOutputzdict[JsonSchemaMode, str]_MODE_TITLE_MAPPING)skipped-choicenon-serializable-defaultskipped-discriminatorc                      e Zd ZdZy)PydanticJsonSchemaWarninga  This class is used to emit warnings produced during JSON schema generation.
    See the [`GenerateJsonSchema.emit_warning`][pydantic.json_schema.GenerateJsonSchema.emit_warning] and
    [`GenerateJsonSchema.render_warning_message`][pydantic.json_schema.GenerateJsonSchema.render_warning_message]
    methods for more details; these can be overridden to control warning behavior.
    N)__name__
__module____qualname____doc__     V/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/pydantic/json_schema.pyr@   r@   e   s    rF   r@   z#/$defs/{model}CoreRefDefsRefJsonRefJsonSchemaKeyT)boundc                  \    e Zd ZU ded<   ded<   e	 	 	 	 	 	 	 	 d
d       ZddZddZddZy	)_DefinitionsRemappingzdict[DefsRef, DefsRef]defs_remappingzdict[JsonRef, JsonRef]json_remappingc                   t        |      }d|i}t        d      D ]  }t        t              |D ]%  }| |   }|D ]  }|   j	                  ||           ' D ]  }t        |         |<    i }	i }
|D ]+  }| |   }t        fd|D              }||	|<   ||   |
||   <   - t        |	|
      }|j                  d|i      }||k(  r|c S |} t        d      )z
        This function should produce a remapping that replaces complex DefsRef with the simpler ones from the
        prioritized_choices such that applying the name remapping would result in an equivalent JSON schema.
        $defsd   c              3  F   K   | ]  }t        |         d k(  s|  yw)r"   N)len).0xschemas_for_alternativess     rG   	<genexpr>zA_DefinitionsRemapping.from_prioritized_choices.<locals>.<genexpr>   s%     (jqCH`abHcDdhiDi(js   !!z.Failed to simplify the JSON schema definitions)
r	   ranger   listappend_deduplicate_schemasnextrN   remap_json_schemar-   )prioritized_choicesdefs_to_jsondefinitionscopied_definitionsdefinitions_schema_iterdefs_refalternativesalternativerO   rP   original_defs_refremapped_defs_ref	remappingnew_definitions_schemarX   s                  @rG   from_prioritized_choicesz._DefinitionsRemapping.from_prioritized_choices   sN    &k2%'9:3Z 	8EMXY]M^$. _28<#/ _K,[9@@AST\A]^__ 5 n5IJbckJl5m(2n 68N57N%0 b!23DE$((jL(j$j!4E01BNO`Ba|,=>?b .nnMI%.%@%@'K]A^%_"!%;;  !77	8: ++[\\rF   c                :    | j                   j                  ||      S N)rO   getselfrefs     rG   remap_defs_refz$_DefinitionsRemapping.remap_defs_ref       ""&&sC00rF   c                :    | j                   j                  ||      S ro   )rP   rp   rq   s     rG   remap_json_refz$_DefinitionsRemapping.remap_json_ref   ru   rF   c           
     Z   t        |t              r| j                  t        |            S t        |t              r|D cg c]  }| j                  |       c}S t        |t              r|j                         D ]  \  }}|dk(  r.t        |t              r| j                  t        |            |d<   9|dk(  rR|d   j                         D ci c]/  \  }}| j                  t        |            | j                  |      1 c}}|d<   | j                  |      ||<    |S c c}w c c}}w )zH
        Recursively update the JSON schema replacing all $refs
        $refrR   )

isinstancestrrw   rJ   r[   r_   dictitemsrt   rI   )rr   schemaitemkeyvalues        rG   r_   z'_DefinitionsRemapping.remap_json_schema   s    fc"&&wv77%=CDTD**40DD%$lln 	@
U&=Zs%;%)%8%8%HF6NG^ +1/*?*?*A'&C ++GCL94;Q;QRW;XX'F7O
 #'"8"8"?F3K	@  E's   D"4D'N)r`   zdict[DefsRef, list[DefsRef]]ra   zdict[DefsRef, JsonRef]rb   zdict[DefsRef, JsonSchemaValue]returnrN   )rs   rI   r   rI   )rs   rJ   r   rJ   )r~   r   r   r   )	rA   rB   rC   __annotations__staticmethodrm   rt   rw   r_   rE   rF   rG   rN   rN      sZ    ****,]9,],,] 4,] 
	,] ,]\11rF   rN   c                     e Zd ZU dZdZdhZded<   defdmdZe	dnd       Z
e	dod	       Z	 	 dpd
Z	 	 	 	 dqdZdrdsdZdtdZdudvdZdudwdZdxdZdydZdzdZd{dZd|dZd}dZd~dZddZddZddZddZddZddZddZddZ dd Z!dd!Z"dd"Z#dd#Z$ e%d$d%      e&dd&              Z' e%d'd%      e&dd(              Z(dd)Z)dd*Z*dd+Z+dd,Z,dd-Z-dd.Z.dd/Z/dd0Z0dd1Z1dd2Z2dd3Z3dd4Z4dd5Z5dd6Z6dd7Z7	 	 	 	 	 	 dd8Z8dd9Z9dd:Z:dd;Z;dd<Z<e=	 	 	 	 dd=       Z>	 	 	 	 dd>Z?dd?Z@dd@ZAddAZBddBZCddCZDddDZEddEZFddFZGddGZHddHZI	 	 	 	 	 	 ddIZJddJZKddKZLddLZM	 	 	 	 	 	 ddMZN	 	 	 	 	 	 ddNZOddOZPddPZQddQZRddRZSddSZTddTZUddUZVddVZWddWZXddXZY	 	 	 	 ddYZZddZZ[dd[Z\dd\Z]dd]Z^dd^Z_dd_Z`dd`ZaddaZbddbZc	 	 	 	 	 	 	 	 ddcZd G dd de      ZeddfZfddgZgddhZhddiZiddjZjddkZkddlZly)GenerateJsonSchemaa]  !!! abstract "Usage Documentation"
        [Customizing the JSON Schema Generation Process](../concepts/json_schema.md#customizing-the-json-schema-generation-process)

    A class for generating JSON schemas.

    This class generates JSON schemas based on configured parameters. The default schema dialect
    is [https://json-schema.org/draft/2020-12/schema](https://json-schema.org/draft/2020-12/schema).
    The class uses `by_alias` to configure how fields with
    multiple names are handled and `ref_template` to format reference names.

    Attributes:
        schema_dialect: The JSON schema dialect used to generate the schema. See
            [Declaring a Dialect](https://json-schema.org/understanding-json-schema/reference/schema.html#id4)
            in the JSON Schema documentation for more information about dialects.
        ignored_warning_kinds: Warnings to ignore when generating the schema. `self.render_warning_message` will
            do nothing if its argument `kind` is in `ignored_warning_kinds`;
            this value can be modified on subclasses to easily control which warnings are emitted.
        by_alias: Whether to use field aliases when generating the schema.
        ref_template: The format string used when generating reference names.
        core_to_json_refs: A mapping of core refs to JSON refs.
        core_to_defs_refs: A mapping of core refs to definition refs.
        defs_to_core_refs: A mapping of definition refs to core refs.
        json_to_defs_refs: A mapping of JSON refs to definition refs.
        definitions: Definitions in the schema.

    Args:
        by_alias: Whether to use field aliases in the generated schemas.
        ref_template: The format string to use when generating reference names.

    Raises:
        JsonSchemaError: If the instance of the class is inadvertently reused after generating a schema.
    z,https://json-schema.org/draft/2020-12/schemar<   zset[JsonSchemaWarningKind]ignored_warning_kindsTc                X   || _         || _        i | _        i | _        i | _        i | _        i | _        t        j                  t        j                  i             | _
        d| _        i | _        t        t              | _        i | _        | j#                         | _        i | _        d| _        y )Nr7   F)by_aliasref_templatecore_to_json_refscore_to_defs_refsdefs_to_core_refsjson_to_defs_refsrb   r#   ConfigWrapperStackConfigWrapper_config_wrapper_stack_mode_prioritized_defsref_choicesr   int_collision_counter_collision_indexbuild_schema_type_to_method_schema_type_to_method"_core_defs_invalid_for_json_schema_used)rr   r   r   s      rG   __init__zGenerateJsonSchema.__init__   s     (=?=?=?9;;=%,%?%?@U@UVX@Y%Z"%1
 KM)2=c2B02&*&F&F&H# `b/ 
rF   c                .    | j                   j                  S ro   )r   tailrr   s    rG   r#   zGenerateJsonSchema._config$  s    ))...rF   c                r    | j                   j                  | j                   j                  S | j                  S ro   )r#   json_schema_mode_overrider   r   s    rG   modezGenerateJsonSchema.mode(  s,    <<11=<<999::rF   c                :   i }t        t        t                    }|D ]'  }|j                  dd       d}	 t	        | |      ||<   ) |S # t
        $ rH}t        j                  d      rY d}~Ot        d|dt        |       j                   d| d	      |d}~ww xY w)
aO  Builds a dictionary mapping fields to methods for generating JSON schemas.

        Returns:
            A dictionary containing the mapping of `CoreSchemaOrFieldType` to a handler method.

        Raises:
            TypeError: If no method has been defined for generating a JSON schema for a given pydantic core schema type.
        -__schema-PYDANTIC_PRIVATE_ALLOW_UNHANDLED_SCHEMA_TYPESNz9No method for generating JsonSchema for core_schema.type=z (expected: .))r[   r   CoreSchemaOrFieldTypereplacegetattrAttributeErrorosgetenv	TypeErrortyperA   )rr   mappingcore_schema_typesr   method_namees         rG   r   z.GenerateJsonSchema.build_schema_type_to_method/  s     `b9=>PQf>g9h$ 
	C [[c237;K&t[9
	  " 99LMOPSw W""&t*"5"5!6a}AG s   A			BB,)BBc                   | j                   r$t        dt        |       j                   dd      |D ]  \  }}}|| _        | j                  |         | j                         }i }|D ]4  \  }}}|| _        | j                  |      }|j                  |      |||f<   6 d| j                  i}|j                  |      }d| _         || j                  |d         fS )a  Generates JSON schema definitions from a list of core schemas, pairing the generated definitions with a
        mapping that links the input keys to the definition references.

        Args:
            inputs: A sequence of tuples, where:

                - The first element is a JSON schema key type.
                - The second element is the JSON mode: either 'validation' or 'serialization'.
                - The third element is a core schema.

        Returns:
            A tuple where:

                - The first element is a dictionary whose keys are tuples of JSON schema key type and JSON mode, and
                    whose values are the JSON schema corresponding to that pair of inputs. (These schemas may have
                    JsonRef references to definitions that are defined in the second returned element.)
                - The second element is a dictionary whose keys are definition references for the JSON schemas
                    from the first returned element, and whose values are the actual JSON schema definitions.

        Raises:
            PydanticUserError: Raised if the JSON schema generator has already been used to generate a JSON schema.
        nThis JSON schema generator has already been used to generate a JSON schema. You must create a new instance of  to generate a new JSON schema.json-schema-already-usedcoderR   T)
r   r/   r   rA   r   generate_inner_build_definitions_remappingr_   rb   sort)	rr   inputsr   r   r~   definitions_remappingjson_schemas_mapr   json_schemas	            rG   generate_definitionsz'GenerateJsonSchema.generate_definitionsI  s   2 ::#559$Z5H5H4IIhj/   & 	(OAtVDJ'	( !% A A CQS!' 	aCvDJ--f5K,A,S,ST_,`c4[)	a
  0 01+==kJ
;w+?!@@@rF   c                   || _         | j                  r$t        dt        |       j                   dd      | j                  |      }| j                  |      }t        t        |j                  d            }|j| j                  |      }||   dk(  rL|Jt        |      dk(  r<|j                         }||xx   dz  cc<   t        t        |j                  d            }d}|j| j                  |       | j                         }| j                  r| j                  |d<   |j!                  |      }d	| _        | j#                  |      S )
a  Generates a JSON schema for a specified schema in a specified mode.

        Args:
            schema: A Pydantic model.
            mode: The mode in which to generate the schema. Defaults to 'validation'.

        Returns:
            A JSON schema representing the specified schema.

        Raises:
            PydanticUserError: If the JSON schema generator has already been used to generate a JSON schema.
        r   r   r   r   ry   Nr"   rR   T)r   r   r/   r   rA   r   get_json_ref_countsr   rJ   rp   get_schema_from_definitionsrU   copy_garbage_collect_definitionsr   rb   r_   r   )rr   r~   r   r   json_ref_countsrs   ref_json_schemar   s           rG   generatezGenerateJsonSchema.generatez  sK    
::#559$Z5H5H4IIhj/  (,':':6'B22;?7KOOF34o">>sCOs#q(_-HSQ\M]abMb-224$)$7KOOF$;<C o 	))+6 $ A A C#'#3#3K +==kJ 
yy%%rF   c                n    d|v rVt        |d         }| j                  f}| j                  v r, j                  |    j                  v rd j                  |   iS d fdd fd}t        j                   |      }t        t        j                  |j                  di             }|j                  d      xr#|f	 	 	 	 	 dfd}t        j                   |      }|j                  d      xr#|f	 	 	 	 	 dfd	}t        j                   |      }|j                  d
d      D ](  }	||	f	 	 	 	 	 	 	 dfd}
t        j                   |
      }* |j                  dd      D ]&  }	||	f	 	 	 	 	 	 	 dd}
t        j                   |
      }(  ||      }t        j                  |      r	 ||      }|S )a  Generates a JSON schema for a given core schema.

        Args:
            schema: The given core schema.

        Returns:
            The generated JSON schema.

        TODO: the nested function definitions here seem like bad practice, I'd like to unpack these
        in a future PR. It'd be great if we could shorten the call stack a bit for JSON schema generation,
        and I think there's potential for that here.
        rs   ry   c                    d| v rrt        | d         }j                  |      \  }}t        |d         }|j                  dd       |k7  r+|j                  |<   j
                  j                  |d        |}|S )Nrs   ry   )rH   get_cache_defs_ref_schemarJ   rp   rb   r   pop)r   r   core_refrf   r   json_refrr   s         rG   populate_defsz8GenerateJsonSchema.generate_inner.<locals>.populate_defs  s    #";u#56,0,J,J8,T)/"?6#:; ??640H<1<D$$X.;;??$O-rF   c                n   d}j                   dk(  rLd| v rH| d   }j                  |      }|0|j                  d      dv r| d   dk(  rj                  ddi|g      }|Tt	        j
                  |       st	        j                  |       rj                  | d      } ||       }|S t        d|        |S )	a@  Generate a JSON schema based on the input schema.

            Args:
                schema_or_field: The core schema to generate a JSON schema from.

            Returns:
                The generated JSON schema.

            Raises:
                TypeError: If an unexpected schema type is encountered.
            Nr8   	when_usedzunless-nonezjson-unless-noner   nullablenullUnexpected schema type: schema=)	r   
ser_schemarp   get_flattened_anyofr%   is_core_schemais_core_schema_fieldr   r   )schema_or_fieldr   r   generate_for_schema_typerr   s       rG   handler_funcz7GenerateJsonSchema.generate_inner.<locals>.handler_func  s     37KyyO+?0R -_=
"ooj9
  +"{37ZZ'/:="&":":VV<Lk;Z"[K"--o>+BbBbcrBs/3/J/J?[aKb/c,":?"KK  $&EoEV$WXXrF   metadatapydantic_js_updatesc                     i  ||       }|S ro   rE   )r   current_handlerr   
js_updatess      rG   js_updates_handler_funczBGenerateJsonSchema.generate_inner.<locals>.js_updates_handler_func  s      Q!APZP""rF   pydantic_js_extrac                     ||       }t        t              r|j                  t                     |S t	              r |       |S ro   )rz   r|   updater   callable)r   r   r   js_extras      rG   js_extra_handler_funcz@GenerateJsonSchema.generate_inner.<locals>.js_extra_handler_func  sM     .o>h-&&'9('CD #" h'[)""rF   pydantic_js_functionsrE   c                     || |      }t        j                  |       r	 | |      }|j                  |      }|j                  dd       }|r|r|j	                  |       |S )Nry   )r%   r   resolve_ref_schemar   r   )r   r   js_modify_functionr   original_schemars   r   s         rG   new_handler_funcz;GenerateJsonSchema.generate_inner.<locals>.new_handler_func  sd    
 1/R--o>"/"MK"1"D"D["Q!oofd3;#**;7&&rF    pydantic_js_annotation_functionsc                     || |      S ro   rE   )r   r   r   s      rG   r   z;GenerateJsonSchema.generate_inner.<locals>.new_handler_func*  s    
 */?KKrF   )r   r   r   JsonSchemaValuer   r   )r   r2   r   r   )r   r2   r   r*   r   r   )r   r2   r   r*   r   r4   r   r   )rH   r   r   rb   r   r)   GenerateJsonSchemaHandlerr   r$   CoreMetadatarp   r%   r   )rr   r~   r   core_mode_refr   r   r   r   r   r   r   r   r   r   r   s   `           @@@rG   r   z!GenerateJsonSchema.generate_inner  sE     F?ve}-H%tyy1M 6 664;Q;QR_;`dhdtdt;t 6 6} EFF	$	L 4MMdT`a33VZZ
B5OP "&;<<:< 9H#!2#!5# !# 8QQRVXopO||$78888 9H
#!2
#!5
# !
# 8QQRVXmnO"*,,/F"K 	j 9H<N'!2'!5' %:' !	' 8QQRVXhiO!	j$ #+,,/QSU"V 		j 9H<NL!2L!5L %:L !	L 8QQRVXhiO		j &f-%%f-'<KrF   Nc                    i }|j                         }|dvrt        |      }|D ]  }| j                  ||   |      ||<    |S )ap  Override this method to customize the sorting of the JSON schema (e.g., don't sort at all, sort all keys unconditionally, etc.)

        By default, alphabetically sort the keys in the JSON schema, skipping the 'properties' and 'default' keys to preserve field definition order.
        This sort is recursive, so it will sort all nested dictionaries as well.
        
propertiesdefault
parent_key)keyssorted_sort_recursive)rr   r   r   sorted_dictr   r   s         rG   r   zGenerateJsonSchema.sort8  s[     35zz|66$<D 	PC#33E#J33OK	PrF   c                $   t        |t              rCi }|j                         }|dvrt        |      }|D ]  }| j	                  ||   |      ||<    |S t        |t
              r,g }|D ]#  }|j                  | j	                  ||             % |S |S )z%Recursively sort a JSON schema value.r   r   )rz   r|   r   r   r   r[   r\   )rr   r   r   r   r   r   sorted_listr   s           rG   r   z"GenerateJsonSchema._sort_recursiveF  s    eT"68K::<D!::d| T#'#7#7c
s#7#SC Tt$13K K""4#7#7j#IJKLrF   c                    t        d      )z%Placeholder - should never be called.zKCannot generate schema for invalid_schema. This is a bug! Please report it.)RuntimeErrorrr   r~   s     rG   invalid_schemaz!GenerateJsonSchema.invalid_schemaZ  s     hiirF   c                    i S )zGenerates a JSON schema that matches any value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        rE   r  s     rG   
any_schemazGenerateJsonSchema.any_schema_  s	     	rF   c                
    ddiS )zGenerates a JSON schema that matches `None`.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   r   rE   r  s     rG   none_schemazGenerateJsonSchema.none_schemaj  s     rF   c                
    ddiS )zGenerates a JSON schema that matches a bool value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   booleanrE   r  s     rG   bool_schemazGenerateJsonSchema.bool_schemau  s     	""rF   c                    ddi}| j                  ||| j                  j                         |j                         D ci c],  \  }}|t        j
                  t        j
                   hvs*||. }}}|S c c}}w )zGenerates a JSON schema that matches an int value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   integerupdate_with_validationsValidationsMappingnumericr}   mathinfrr   r~   r   kvs        rG   
int_schemazGenerateJsonSchema.int_schema  sv     (.y&9$$[&$:Q:Q:Y:YZ(3(9(9(;^1qTXT\T\S\H]?]q!t^^ _   +A5+A5c                    ddi}| j                  ||| j                  j                         |j                         D ci c],  \  }}|t        j
                  t        j
                   hvs*||. }}}|S c c}}w )zGenerates a JSON schema that matches a float value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   numberr  r  s        rG   float_schemazGenerateJsonSchema.float_schema  sv     (.x&8$$[&$:Q:Q:Y:YZ(3(9(9(;^1qTXT\T\S\H]?]q!t^^ _r  c                   | j                  t        j                                }| j                  dk(  r|j                  d      }|j                  d      }|j                  d      }|j                  d      }|j                  d      }d| j	                  t        j                  |j                  d      |d	n
t        |      |d	n
t        |      |d	n
t        |      |d	n
t        |      |d	n
t        |      
            |gi}|S )zGenerates a JSON schema that matches a decimal value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r7   multiple_oflegeltgtanyOfallow_inf_nanN)r%  r  r   r!  r"  r#  )
str_schemar   r   rp   r  float)rr   r~   r   r  r   r!  r"  r#  s           rG   decimal_schemaz!GenerateJsonSchema.decimal_schema  s     ook&<&<&>?99$ **]3KD!BD!BD!BD!B%%#00*0**_*E0;0C{I[')ztuRy')ztuRy')ztuRy')ztuRy	  K rF   c                    ddi}| j                  ||| j                  j                         t        |j	                  d      t
              r|j	                  d      j                  |d<   |S )zGenerates a JSON schema that matches a string value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   stringpattern)r  r  r*  rz   rp   r   r+  rr   r~   r   s      rG   r&  zGenerateJsonSchema.str_schema  s^     x($$[&$:Q:Q:X:XYkooi0':%0__Y%?%G%GK	"rF   c                    d| j                   j                  dk(  rdndd}| j                  ||| j                  j                         |S )zGenerates a JSON schema that matches a bytes value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r*  base64	base64urlbinaryr   format)r#   ser_json_bytesr  r  bytesr,  s      rG   bytes_schemazGenerateJsonSchema.bytes_schema  sG      ($,,B]B]aiBi;owx$$[&$:Q:Q:W:WXrF   c                    dddS )zGenerates a JSON schema that matches a date value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r*  dater1  rE   r  s     rG   date_schemazGenerateJsonSchema.date_schema       !F33rF   c                    dddS )zGenerates a JSON schema that matches a time value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r*  timer1  rE   r  s     rG   time_schemazGenerateJsonSchema.time_schema  r9  rF   c                    dddS )zGenerates a JSON schema that matches a datetime value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r*  z	date-timer1  rE   r  s     rG   datetime_schemaz"GenerateJsonSchema.datetime_schema  s     !K88rF   c                F    | j                   j                  dk(  rddiS dddS )zGenerates a JSON schema that matches a timedelta value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r'  r   r  r*  durationr1  )r#   ser_json_timedeltar  s     rG   timedelta_schemaz#GenerateJsonSchema.timedelta_schema  s,     <<**g5H%% J77rF   c           	        |d   D cg c])  }t        t        |t              r|j                  n|      + }}i }t	        |      dk(  r	|d   |d<   n||d<   |D ch c]  }t        |       }}|t        hk(  rd|d<   |S |t        hk(  rd|d<   |S |t        hk(  rd	|d<   |S |t        hk(  rd
|d<   |S |t        hk(  rd|d<   |S |t        d      hk(  rd|d<   |S c c}w c c}w )zGenerates a JSON schema that matches a literal value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        expectedr"   r   constenumr*  r   r  r  r  arrayNr   )r   rz   r
   r   rU   r   r{   r   r'  boolr[   )rr   r~   r  rD  resultr   typess          rG   literal_schemaz!GenerateJsonSchema.literal_schema  s"    X^^hWijRS&*Q2Eqww1Mjj!#x=A&qkF7O%F6N"*+Qa++SE>%F6N  se^&F6N  ug%F6N  tf_&F6N
 	 tf_$F6N  tDzl"#F6N+ k ,s   .CCc                   |d   }|j                   sdnt        j                  |j                         }|dk(  rd}|j                  |d}|j	                         D ci c]  \  }}|	|| }}}|d   D cg c]  }t        |j                         }}||d<   |D ch c]  }t        |       }	}t        |t              s
|	t        hk(  rd|d<   |S t        |t              s
|	t        hk(  rd	|d<   |S t        |t              s
|	t        hk(  rd
|d<   |S |	t        hk(  rd|d<   |S |	t        hk(  rd|d<   |S c c}}w c c}w c c}w )zGenerates a JSON schema that matches an Enum value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        clsNzAn enumeration.)titledescriptionmembersrF  r*  r   r  r  r  rG  )rD   inspectcleandocrA   r}   r   r   r   rz   r{   r   r'  rH  r[   )
rr   r~   	enum_typerO  rI  r  r  rD  r   rJ  s
             rG   enum_schemazGenerateJsonSchema.enum_schema(  s_    5M	"+"3"3d9I9I)J[J[9\,,K+4+=+=k!Z#)<<>C41aQ]!Q$CC9?	9JKA&qww/KK!v"*+Qa++i%3%%F6N  	3'5SE>&F6N  	5)Uug-=%F6N  tf_&F6N  tf_$F6N% DK ,s   
D6'D66D<Ec                4    | j                  |d|d    d      S )a  Handles JSON schema generation for a core schema that checks if a value is an instance of a class.

        Unless overridden in a subclass, this raises an error.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        zcore_schema.IsInstanceSchema (rM  r   handle_invalid_for_json_schemar  s     rG   is_instance_schemaz%GenerateJsonSchema.is_instance_schemaL  s*     226=[\bch\i[jjk;lmmrF   c                    i S )aI  Handles JSON schema generation for a core schema that checks if a value is a subclass of a class.

        For backwards compatibility with v1, this does not raise an error, but can be overridden to change this.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        rE   r  s     rG   is_subclass_schemaz%GenerateJsonSchema.is_subclass_schemaY  s	     	rF   c                &    | j                  |d      S )zGenerates a JSON schema that matches a callable value.

        Unless overridden in a subclass, this raises an error.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        core_schema.CallableSchemarV  r  s     rG   callable_schemaz"GenerateJsonSchema.callable_schemag  s     226;WXXrF   c                    d|vri n| j                  |d         }d|d}| j                  ||| j                  j                         |S )zReturns a schema that matches a list schema.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        items_schemarG  r   r}   r   r  r  rG  rr   r~   r_  r   s       rG   list_schemazGenerateJsonSchema.list_schemat  R     ,69rt?R?RSYZhSi?j&>$$[&$:Q:Q:W:WXrF   D`tuple_positional_schema` is deprecated. Use `tuple_schema` instead.)categoryc                \    t        j                  dt        d       | j                  |      S )Replaced by `tuple_schema`.re     
stacklevelwarningswarnr    tuple_schemar  s     rG   tuple_positional_schemaz*GenerateJsonSchema.tuple_positional_schema  s,     	R%	

   ((rF   B`tuple_variable_schema` is deprecated. Use `tuple_schema` instead.c                \    t        j                  dt        d       | j                  |      S )rh  rq  ri  rj  rl  r  s     rG   tuple_variable_schemaz(GenerateJsonSchema.tuple_variable_schema  s,     	P%	

   ((rF   c                   ddi}d|v rl|d   }|dkD  r-||d<   |d   d| D cg c]  }| j                  |       c}|d<   |d	z   t        |d         k(  r| j                  |d   |         |d
<   nJd|d
<   nD|d   D cg c]  }| j                  |       }}|r||d<   t        |      |d<   t        |      |d<   | j                  ||| j                  j                         |S c c}w c c}w )zGenerates a JSON schema that matches a tuple schema e.g. `tuple[int,
        str, bool]` or `tuple[int, ...]`.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   rG  variadic_item_indexr   minItemsr_  NprefixItemsr"   r}   TmaxItems)r   rU   r  r  rG  )rr   r~   r   ru  r   rw  s         rG   ro  zGenerateJsonSchema.tuple_schema  s)    )/'8 F*"()>"?"Q&*=J':@:PQeRe:f.26D''-.M* #Q&#f^.D*EE'+':':6.;QRe;f'gG$
 (,G$AGAWX4..t4XKX-8M*&)+&6K
#&)+&6K
#$$[&$:Q:Q:W:WX%. Ys   C"<C'c                $    | j                  |      S )zGenerates a JSON schema that matches a set schema.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        _common_set_schemar  s     rG   
set_schemazGenerateJsonSchema.set_schema       &&v..rF   c                $    | j                  |      S )zGenerates a JSON schema that matches a frozenset schema.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        rz  r  s     rG   frozenset_schemaz#GenerateJsonSchema.frozenset_schema  r}  rF   c                    d|vri n| j                  |d         }dd|d}| j                  ||| j                  j                         |S )Nr_  rG  T)r   uniqueItemsr}   ra  rb  s       rG   r{  z%GenerateJsonSchema._common_set_schema  sR    +69rt?R?RSYZhSi?j&tlS$$[&$:Q:Q:W:WXrF   c                    d|vri n| j                  |d         }d|d}| j                  ||| j                  j                         |S )zReturns a JSON schema that represents the provided GeneratorSchema.

        Args:
            schema: The schema.

        Returns:
            The generated JSON schema.
        r_  rG  r`  ra  rb  s       rG   generator_schemaz#GenerateJsonSchema.generator_schema  rd  rF   c                "   ddi}d|v r"| j                  |d         j                         ni }d|vr%|j                  dd      }|j                  dd       nd}d|v r"| j                  |d         j                         ni }|j                  dd       |s||||d	<   n||i|d
<   nd|d	<   |j                  d      dk(  rt	        |      dkD  sd|v r|j                  dd       ||d<   | j                  ||| j                  j                         |S )zGenerates a JSON schema that matches a dict schema.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   objectkeys_schemary   r+  NrN  values_schemaadditionalPropertiespatternPropertiesTr*  r"   propertyNames)r   r   r   rp   rU   r  r  r  )rr   r~   r   r  keys_patternr  s         rG   dict_schemazGenerateJsonSchema.dict_schema  s4    )/'9KX\bKbd))&*?@EEGhj$&??9d;LOOGT*  LO^bhOh++F?,CDIIKnp'4(L4#6C234@-3P/026K./ __V$0S5E5I$OOFD)+6K($$[&$:Q:Q:X:XYrF   c                    | j                   dk(  r$|j                  d      x}r| j                  |      S | j                  |d         S )zGenerates a JSON schema that matches a function-before schema.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r7   json_schema_input_schemar~   r   rp   r   rr   r~   input_schemas      rG   function_before_schemaz)GenerateJsonSchema.function_before_schema  K     99$&**E_:`*`,*`&&|44""6(#344rF   c                *    | j                  |d         S )zGenerates a JSON schema that matches a function-after schema.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r~   r   r  s     rG   function_after_schemaz(GenerateJsonSchema.function_after_schema#       ""6(#344rF   c                    | j                   dk(  r$|j                  d      x}r| j                  |      S | j                  |d|d    d      S )zGenerates a JSON schema that matches a function-plain schema.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r7   r  z*core_schema.PlainValidatorFunctionSchema (functionr   )r   rp   r   rW  r  s      rG   function_plain_schemaz(GenerateJsonSchema.function_plain_schema.  s^     99$&**E_:`*`,*`&&|4422@
AS@TTUV
 	
rF   c                    | j                   dk(  r$|j                  d      x}r| j                  |      S | j                  |d         S )zGenerates a JSON schema that matches a function-wrap schema.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r7   r  r~   r  r  s      rG   function_wrap_schemaz'GenerateJsonSchema.function_wrap_schema>  r  rF   c                8   | j                  |d         }| j                  |      }|t        u r|S | j                  dk(  rl|d   j	                  d      x}rV|j	                  d      x}rC|j	                  d      dk(  r/|j	                  d      s||j	                  d      dv s		  ||      }	 | j                  |      }||d<   |S # t
        $ r | j                  d	d
|d       |cY S w xY w# t        j                  $ r | j                  d	d| d       |cY S w xY w)zGenerates a JSON schema that matches a schema with a default value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r~   r8   r  r   function-plaininfo_argr   r   r=   zUnable to serialize value z> with the plain serializer; excluding default from JSON schemazDefault value z= is not JSON serializable; excluding default from JSON schemar   )
r   get_default_value	NoDefaultr   rp   	Exceptionemit_warningencode_defaultpydantic_corePydanticSerializationError)rr   r~   r   r   r   ser_funcencoded_defaults          rG   default_schemaz!GenerateJsonSchema.default_schemaL  sS    ))&*:;((0i II(%h/33ODDD'^^J777v&*::NN:._)DHk)k#"7+	"11':O "1I1  # !!.0;yz #"# 77 	* 	)fg
 	s$   #C ,C+ !C('C(++DDc                .    |j                  dt              S )a  Get the default value to be used when generating a JSON Schema for a core schema with a default.

        The default implementation is to use the statically defined default value. This method can be overridden
        if you want to make use of the default factory.

        Args:
            schema: The `'with-default'` core schema.

        Returns:
            The default value to use, or [`NoDefault`][pydantic.json_schema.NoDefault] if no default
                value is available.
        r   )rp   r  r  s     rG   r  z$GenerateJsonSchema.get_default_value  s     zz)Y//rF   c                f    ddi}| j                  |d         }||k(  r|S | j                  ||g      S )zGenerates a JSON schema that matches a schema that allows null values.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   r   r~   )r   r   )rr   r~   null_schemainner_json_schemas       rG   nullable_schemaz"GenerateJsonSchema.nullable_schema  sK     v& //x0@A+ ++->,LMMrF   c                N   g }|d   }|D ]:  }t        |t              r|d   n|}	 |j                  | j                  |             < t        |      dk(  r|d   S | j                  |      S # t        $ r Y lt
        $ r&}| j                  d|j                         Y d}~d}~ww xY w)zGenerates a JSON schema that matches a schema that allows values matching any of the given schemas.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        choicesr   r<   Nr"   )
rz   tupler\   r   r   r-   r  messagerU   r   )rr   r~   	generatedr  choicechoice_schemaexcs          rG   union_schemazGenerateJsonSchema.union_schema  s     ,.	# 	AF)3FE)BF1IMA  !4!4]!CD		A y>QQ<''	22   / A!!"2CKK@@As    A++	B$6B$>BB$c           
     *   i }|d   j                         D ]M  \  }}t        |t              r|j                  }	 | j	                  |      j                         |t        |      <   O t        |j                               }d|i}| j                  ||      }|:||j                         D ci c]  \  }}||j                  d|       c}}d|d<   |S # t        $ r Y t        $ r&}| j                  d|j                         Y d}~d}~ww xY wc c}}w )ac  Generates a JSON schema that matches a schema that allows values matching any of the given schemas, where
        the schemas are tagged with a discriminator field that indicates which schema should be used to validate
        the value.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r  r<   NoneOfry   )propertyNamer   discriminator)r}   rz   r
   r   r   r   r{   r   r-   r  r  r]   values_extract_discriminatorrp   )	rr   r~   r  r  r  r  one_of_choicesr   openapi_discriminators	            rG   tagged_union_schemaz&GenerateJsonSchema.tagged_union_schema  s    13	9%++- 
	ADAq!T"GGA %)$7$7$:$?$?$A	#a&!
	A .i.>.>.@A(/'@ !% ; ;FN S , 5<EOO<MNDAqAquuVQ//N,K(
 !   / A!!"2CKK@@A Os#   +C+D	DD&DDc           	     @   d}t        |d   t              r|d   S t        |d   t              rt        |d         dk(  rt        |d   d   t              r|d   d   S |d   D ]  }t        |t              s |S t        |      dk7  r%|d   }t        |t              s;d}|D ]>  }	 | j	                  |      }|j                  di       }	t        |	t              r||	vs<d} n |s|} |S  |S # t
        $ r'}| j                  dt        |             i }Y d}~bd}~ww xY w)	zvExtract a compatible OpenAPI discriminator from the schema and one_of choices that end up in the final
        schema.Nr  r"   r   Tr>   r   F)	rz   r{   r[   rU   r   r  r  rp   r|   )
rr   r~   r  r  
alias_pathaliasalias_is_present_on_all_choicesr  r  r   s
             rG   r  z)GenerateJsonSchema._extract_discriminator  s\   
 -1f_-s3/**f_-t46/*+q0Z@WXY@Z\_5`o.q11
 %_5 
!*d3. %$- z?a'"1!%-26/, F$!%!8!8!@ "(L"!=J%j$75
;R:?7 3,1)$$32 %$ ( $ ))*A3s8L!#$s   %C--	D6DDc                V    | j                   dk(  rdnd}| j                  |d   |         S )a  Generates a JSON schema that matches a core_schema.ChainSchema.

        When generating a schema for validation, we return the validation JSON schema for the first step in the chain.
        For serialization, we return the serialization JSON schema for the last step in the chain.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r7   r   steps)r   r   )rr   r~   
step_indexs      rG   chain_schemazGenerateJsonSchema.chain_schema  s0     ))|3Q
""6'?:#>??rF   c                z    |j                  dd      }|r| j                  |d         S | j                  |d         S )zGenerates a JSON schema that matches a schema that allows values matching either the lax schema or the
        strict schema.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        strictFstrict_schema
lax_schema)rp   r   )rr   r~   
use_stricts      rG   lax_or_strict_schemaz'GenerateJsonSchema.lax_or_strict_schema  sE     ZZ%0
 &&vo'>??&&vl';<<rF   c                *    | j                  |d         S )a  Generates a JSON schema that matches a schema that allows values matching either the JSON schema or the
        Python schema.

        The JSON schema is used instead of the Python schema. If you want to use the Python schema, you should override
        this method.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   r  r  s     rG   json_or_python_schemaz(GenerateJsonSchema.json_or_python_schema1  s     ""6-#899rF   c           	     |   |j                  dd      }|d   j                         D cg c]+  \  }}| j                  |      r|| j                  ||      |f- }}}| j                  dk(  r0|j                  | j                  |j                  dg                    |j                  d      }t        |      }| j                  j                  |      5  | j                  |      }ddd       || j                  ||       |S |j                  d      }	|	d	k(  rd
d<   |S |	dk(  rdd<   S c c}}w # 1 sw Y   OxY w)zGenerates a JSON schema that matches a schema that defines a typed dict.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        totalTfieldsr8   computed_fieldsrM  NextraforbidFr  allow)rp   r}   field_is_presentfield_is_requiredr   extend_name_required_computed_fields_get_typed_dict_configr   push_named_required_fields_schema_update_class_schema)
rr   r~   r  namefieldnamed_required_fieldsrM  configr   r  s
             rG   typed_dict_schemaz$GenerateJsonSchema.typed_dict_schema@  sb    

7D)  &h/557J
e$$U+ 4))%7?J
 J

 99'!(()L)LVZZXikmMn)opjj','',,V4 	T<<=RSK	T ?%%k3?  JJw'E 6;23  '!6:23+J
	T 	Ts   0D,D22D;c                8    | D cg c]
  }|d   d|f c}S c c}w )Nproperty_nameTrE   )r  r  s     rG   r  z1GenerateJsonSchema._name_required_computed_fieldsa  s&     DSS%'u5SSSs   c                   i }g }|D ]  \  }}}| j                   r| j                  ||      }	 | j                  |      j                         }d|vr'| j                  |      r| j                  |      }||d<   | j                  |      }|||<   |s|j                  |        d|d}	|r||	d<   |	S # t        $ r Y w xY w)NrN  r  r   r   required)	r   _get_alias_namer   r   r   field_title_should_be_setget_title_from_namehandle_ref_overridesr\   )
rr   r  r   required_fieldsr  r  r  field_json_schemarN  r   s
             rG   r  z0GenerateJsonSchema._named_required_fields_schemag  s     24
%'%: 	-!D(E}}++E48$($7$7$>$C$C$E! //D4R4RSX4Y006-2!'* $ 9 9:K L0Jt&&t,	-  (zB&5K
#   s   B11	B=<B=c                   |d   dk(  r|j                  d|      }n4| j                  dk(  r|j                  d|      }n|j                  d|      }t        |t              r|}|S t        |t              rPt        d|      }|D ]=  }t        |t              st        |      dk(  s#t        |d	   t              s7|d	   } |S  |S t        |       |S )
Nr   computed-fieldr  r7   validation_aliasserialization_aliaszlist[str] | strr"   r   )rp   r   rz   r{   r[   r   rU   r   )rr   r  r  r  paths        rG   r  z"GenerateJsonSchema._get_alias_name  s    =,,7D1EYY,&II0$7EII3T:EeS!D  t$*E2E dD)c$i1nDQRGUXAY  7D   rF   c                *    | j                  |d         S )zGenerates a JSON schema that matches a schema that defines a typed dict field.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r~   r  r  s     rG   typed_dict_field_schemaz*GenerateJsonSchema.typed_dict_field_schema  r  rF   c                *    | j                  |d         S )zGenerates a JSON schema that matches a schema that defines a dataclass field.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r~   r  r  s     rG   dataclass_field_schemaz)GenerateJsonSchema.dataclass_field_schema  r  rF   c                *    | j                  |d         S )zGenerates a JSON schema that matches a schema that defines a model field.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r~   r  r  s     rG   model_field_schemaz%GenerateJsonSchema.model_field_schema  r  rF   c                *    | j                  |d         S )zGenerates a JSON schema that matches a schema that defines a computed field.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        return_schemar  r  s     rG   computed_field_schemaz(GenerateJsonSchema.computed_field_schema  s     ""6/#:;;rF   c                    t        d|d         }|j                  }| j                  j                  |      5  | j	                  |d         }ddd       | j                  ||       |S # 1 sw Y   xY w)zGenerates a JSON schema that matches a schema that defines a model.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        ztype[BaseModel]rM  r~   N)r   model_configr   r  r   r  )rr   r~   rM  r  r   s        rG   model_schemazGenerateJsonSchema.model_schema  s|     $fUm4!!'',,V4 	@--fX.>?K	@ 	!!+sF;	@ 	@s   A))A2c                   ddl m} ddlm} |j	                  d      x}|j                  d|       nX|j	                  d      x}rE ||      }t        |t              st        d| d|j                         |j                  d|       d|vr|j                  |d<   ||u st        j                  |      rdn|j                  }	|	r&|j                  d	t        j                  |	             n9t!        ||      r-|j"                  d
   j$                  x}
r|j                  d	|
       |j	                  d      }d|vr|dk(  rd|d<   n
|dk(  rd|d<   |j	                  d      }t!        ||      r8|j&                  r,|j(                  d
   j*                  }|r|rt-        d      |r|}t        |t.        t0        f      r|j3                  |      }t        |t4              r|j7                  |       nZt9        |      r>t;        t        j<                  |      j>                        dkD  r
 |||       n ||       n|t-        d| d      tA        |d      rd|d<   yy)a  Update json_schema with the following, extracted from `config` and `cls`:

        * title
        * description
        * additional properties
        * json_schema_extra
        * deprecated

        Done in place, hence there's no return value as the original json_schema is mutated.
        No ref resolving is involved here, as that's not appropriate for simple updates.
        r"   r5   )	RootModelrN  Nmodel_title_generatorzmodel_title_generator z must return str, not rO  rootr  r  r  Tr  Fjson_schema_extrazz"model_config['json_schema_extra']" and "Field.json_schema_extra" on "RootModel.root" field must not be set simultaneouslyz"model_config['json_schema_extra']=z$ should be a dict, callable, or None__deprecated__r   )!mainr6   
root_modelr  rp   
setdefaultrz   r{   r   	__class__rA   dataclassesis_dataclassrD   rQ  rR  
issubclass__pydantic_fields__rO  __pydantic_root_model__model_fieldsr  
ValueErrorr   classmethod__get__r|   r   r   rU   	signature
parametershasattr)rr   r   rM  r  r6   r  config_titler  rN  	docstringroot_descriptionr  r  root_json_schema_extras                 rG   r  z'GenerateJsonSchema._update_class_schema  sg    	$)"JJw//L<""7L9&,jj1H&II"I)#.EeS)"89N8OOefkfufuev wxx""7E2+%#&<<K   9,0H0H0MDSVS^S^	""='2B2B92MNY'AXAXY_A`AlAl-l-=-l""=2BC

7#!46:23("6;23"JJ':;c9%#*E*E%(%5%5f%=%O%O" %; <  &$:!',)DE 1 9 9# >'.01'(7$$%67BBCaG!+s3!+.*45F4GGkl  3()(,K% *rF   c                z    d|v r6|d   }| j                  t        |            }|t        d|       |}d|v r6|S )a$  Resolve a JsonSchemaValue to the non-ref schema if it is a $ref schema.

        Args:
            json_schema: The schema to resolve.

        Returns:
            The resolved schema.

        Raises:
            RuntimeError: If the schema reference can't be found in definitions.
        ry   z(Cannot update undefined schema for $ref=)r   rJ   r  )rr   r   rs   schema_to_updates       rG   r   z%GenerateJsonSchema.resolve_ref_schema  s[     #f%C#??M'"%McU#STT*K # rF   c           	        |d   j                         D cg c],  \  }}| j                  |      r|| j                  |d      |f. }}}| j                  dk(  r0|j	                  | j                  |j                  dg                    | j                  |      }|j                  dd      }|%| j                  |      }| j                  |      |d<   |S c c}}w )	zGenerates a JSON schema that matches a schema that defines a model's fields.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r  Tr  r8   r  extras_schemaNr  )
r}   r  r  r   r  r  rp   r  r   r   )rr   r~   r  r  r  r   r   r  s           rG   model_fields_schemaz&GenerateJsonSchema.model_fields_schema1  s      &h/557J
e$$U+ 4))%t)<eDJ
 J

 99'!(()L)LVZZXikmMn)op889NO

?D9$#66{C7;7J7J=7Y34J
s   1Cc                    | j                   dk(  r|j                  d       S | j                   dk(  ryt        | j                          y)a  Whether the field should be included in the generated JSON schema.

        Args:
            field: The schema for the field itself.

        Returns:
            `True` if the field should be included in the generated JSON schema, `False` otherwise.
        r8   serialization_excluder7   TN)r   rp   r   )rr   r  s     rG   r  z#GenerateJsonSchema.field_is_presentH  s@     99' yy!8999YY,&#rF   c                    | j                   dk(  r(| j                  j                  r|j                  d       S |d   dk(  r|j                  d|      S |d   d   dk7  S )aY  Whether the field should be marked as required in the generated JSON schema.
        (Note that this is irrelevant if the field is not present in the JSON schema.).

        Args:
            field: The schema for the field itself.
            total: Only applies to `TypedDictField`s.
                Indicates if the `TypedDict` this field belongs to is total, in which case any fields that don't
                explicitly specify `required=False` are required.

        Returns:
            `True` if the field should be marked as required in the generated JSON schema, `False` otherwise.
        r8   r#  r   ztyped-dict-fieldr  r~   r   )r   r#   +json_schema_serialization_defaults_requiredrp   )rr   r  r  s      rG   r  z$GenerateJsonSchema.field_is_requiredZ  sa    " 99'DLL,d,dyy!8999V} 22yyU33Xv.);;rF   c                    |d   D cg c],  }| j                  |      r|d   | j                  |d      |f. }}| j                  dk(  r0|j                  | j	                  |j                  dg                    | j                  |      S c c}w )zGenerates a JSON schema that matches a schema that defines a dataclass's constructor arguments.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r  r  Tr  r8   r  )r  r  r   r  r  rp   r  )rr   r~   r  r  s       rG   dataclass_args_schemaz(GenerateJsonSchema.dataclass_args_schemas  s      )J
$$U+ 6]D2252EuMJ
 J

 99'!(()L)LVZZXikmMn)op112GHHJ
s   1Bc                   ddl m} |d   }t        |dt        di             }| j                  j                  |      5  | j                  |d         j                         }ddd       | j                  ||        ||      rd}n-|j                  dnt        j                  |j                        }|r||d<   |S # 1 sw Y   ]xY w)	zGenerates a JSON schema that matches a schema that defines a dataclass.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r"   )is_builtin_dataclassrM  __pydantic_config__r0   r~   NrO  )_internal._dataclassesr)  r   r   r   r  r   r   r  rD   rQ  rR  )rr   r~   r)  rM  r  r   rO  s          rG   dataclass_schemaz#GenerateJsonSchema.dataclass_schema  s     	AUm$S*?lTVAWX'',,V4 	G--fX.>?DDFK	G 	!!+sF;  $K"%++"5$7;K;KCKK;XK)4K&	G 	Gs   #B==Cc                ^   |j                  di       j                  d      }|d   }|D cg c]  }|j                  d      dk(  s| }}|D cg c]  }|j                  d      dv s| }}|D cg c]  }|j                  d      dk(  s| }}|j                  d      }|j                  d	      }	|r| xr |	 }
|
r| j                  ||z   |      S | xr | }|r| j                  ||z   |	      S |s| xr |	 }
|
r| j                  ||z   |      S t        d
      c c}w c c}w c c}w )Generates a JSON schema that matches a schema that defines a function's arguments.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   'pydantic_js_prefer_positional_argumentsarguments_schemar   keyword_only>   Npositional_or_keywordpositional_onlyvar_args_schemavar_kwargs_schemazfUnable to generate JSON schema for arguments validator with positional-only and keyword-only arguments)rp   p_arguments_schemakw_arguments_schemar-   )rr   r~   prefer_positional	argumentsakw_only_argumentskw_or_p_argumentsp_only_argumentsr4  r5  positional_possiblekeyword_possibles               rG   r0  z#GenerateJsonSchema.arguments_schema  sg    #JJz26::;de-.	(1U1QUU6]n5TQUU(1f1QUU6]Fe5eQff'0W!AEE&MEV4VAWW **%67"JJ':;&7"7"Q@Q<Q"../?BS/SUdee//G4G++,=@Q,QSdee &7"7"Q@Q<Q"../?BS/SUdee*t
 	
) VfWs#   D D D%(D%2D*D*c                H   i }g }|D ]k  }| j                  |      }| j                  |d         j                         }| j                  |      |d<   |||<   |d   d   dk7  s[|j	                  |       m d|d}|r||d<   |r| j                  |      }	|	r|	|d<   |S d	|d<   |S )
zGenerates a JSON schema that matches a schema that defines a function's keyword arguments.

        Args:
            arguments: The core schema.

        Returns:
            The generated JSON schema.
        r~   rN  r   r   r  r  r  r  F)get_argument_namer   r   r  r\   )
rr   r9  r5  r   r  argumentr  argument_schemar   additional_properties_schemas
             rG   r7  z&GenerateJsonSchema.kw_arguments_schema  s     24
 ! 
	&H))(3D"11(82DEJJLO'+'?'?'EOG$.Jt!&)Y6 %
	& 19
'S&.K
#+/+>+>?P+Q(+6R23  38K./rF   c                f   g }d}|D ]k  }| j                  |      }| j                  |d         j                         }| j                  |      |d<   |j	                  |       |d   d   dk7  sg|dz  }m ddi}|r||d<   |r||d	<   |r| j                  |      }	|	r|	|d
<   |S t        |      |d<   |S )zGenerates a JSON schema that matches a schema that defines a function's positional arguments.

        Args:
            arguments: The core schema.

        Returns:
            The generated JSON schema.
        r   r~   rN  r   r   r"   rG  rw  rv  r}   rx  )rA  r   r   r  r\   rU   )
rr   r9  r4  prefix_items	min_itemsrB  r  rC  r   r_  s
             rG   r6  z%GenerateJsonSchema.p_arguments_schema  s     /1	! 	H))(3D"11(82DEJJLO'+'?'?'EOG$0!&)Y6 Q		 )/'8)5K&&/K
#..?L'3G$  '*,&7K
#rF   c                t    |d   }| j                   r&|j                  d      }t        |t              r|}|S 	 |S )zRetrieves the name of an argument.

        Args:
            argument: The core schema.

        Returns:
            The name of the argument.
        r  r  )r   rp   rz   r{   )rr   rB  r  r  s       rG   rA  z$GenerateJsonSchema.get_argument_name  sC     ==LL)E%%  rF   c                   |d   }i }g }|D ]  }|j                  dd      }| j                  |      }| j                  |d         j                         }|dk(  rd|d}n
|dk(  rd	|d
}|j	                  d| j                  |             |||<   |dk(  rd|v s|dvs|d   d   dk7  s|j                  |        d	|d}	|r||	d<   |	S )r.  r0  r   r2  r~   var_argsrG  r`  var_kwargs_uniformr  )r   r  rN  var_kwargs_unpacked_typed_dictr  >   rJ  rK  rL  r   r   r  )rp   rA  r   r   r
  r  r\   )
rr   r~   r9  r   r  rB  r   r  rC  r   s
             rG   arguments_v3_schemaz&GenerateJsonSchema.arguments_v3_schema(  s    -.	13
 ! 	&H<<(?@D))(3D"11(82DEJJLOz!+2_"M--+3_"]&&w0H0H0NO.Jt 99jO>[ccX&v.);
 %)	&, 19
'S&.K
#rF   c                *    | j                  |d         S )zGenerates a JSON schema that matches a schema that defines a function call.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r0  r  r  s     rG   call_schemazGenerateJsonSchema.call_schemaO  s     ""6*<#=>>rF   c                *    | j                  |d         S )zGenerates a JSON schema that matches a schema that defines a custom error.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r~   r  r  s     rG   custom_error_schemaz&GenerateJsonSchema.custom_error_schemaZ  r  rF   c                    |j                  d      xs t        j                         }| j                  |      }| j                  dk(  rdd|dS |S )zGenerates a JSON schema that matches a schema that defines a JSON object.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r~   r7   r*  zapplication/json)r   contentMediaTypecontentSchema)rp   r   r  r   r   )rr   r~   content_core_schemacontent_json_schemas       rG   r   zGenerateJsonSchema.json_schemae  sV     %jj2Nk6L6L6N"112EF99$$:L_rss '&rF   c                `    dddd}| j                  ||| j                  j                         |S )zGenerates a JSON schema that matches a schema that defines a URL.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r*  urir"   r   r2  	minLengthr  r  r*  r,  s      rG   
url_schemazGenerateJsonSchema.url_schemav  s4      (5qI$$[&$:Q:Q:X:XYrF   c                `    dddd}| j                  ||| j                  j                         |S )zGenerates a JSON schema that matches a schema that defines a URL that can be used with multiple hosts.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r*  zmulti-host-urir"   rY  r[  r,  s      rG   multi_host_url_schemaz(GenerateJsonSchema.multi_host_url_schema  s6      (3CRST$$[&$:Q:Q:X:XYrF   c                    dddS )zGenerates a JSON schema that matches a UUID.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r*  uuidr1  rE   r  s     rG   uuid_schemazGenerateJsonSchema.uuid_schema  r9  rF   c                    |d   D ]  }	 | j                  |        | j                  |d         S # t        $ rB}t        |d         }|| j                  | j	                  || j
                  f      <   Y d}~qd}~ww xY w)zGenerates a JSON schema that matches a schema that defines a JSON object with definitions.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        rb   rs   Nr~   )r   r-   rH   r   get_defs_refr   )rr   r~   
definitionr   r   s        rG   rd   z%GenerateJsonSchema.definitions_schema  s     !/ 	J##J/	 ""6(#344	 0 $+Ju,=$>de778I8I8UYU^U^J_8`as   1	A<8A77A<c                J    t        |d         }| j                  |      \  }}|S )zGenerates a JSON schema that matches a schema that references a definition.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        
schema_ref)rH   r   )rr   r~   r   r   r   s        rG   definition_ref_schemaz(GenerateJsonSchema.definition_ref_schema  s.     6,/0!;;HE?rF   c                    |d   }|dk(  s|dk(  r%|j                  d      }|| j                  |      S y|dk(  s|dk(  r#| j                  t        j                               S |d   dk(  r| j                  |d	         S y)
zGenerates a JSON schema that matches a schema that defines a serialized object.

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   r  zfunction-wrapr  Nr2  z	to-stringmodelr~   )rp   r   r&  r   )rr   r~   schema_typer  s       rG   r   zGenerateJsonSchema.ser_schema  s     Vn**k_.L"JJ7M(**=99  H${(B??;#9#9#;<<F^w&&&vh'788rF   c                
    ddiS )a  Generates a JSON schema that matches a complex number.

        JSON has no standard way to represent complex numbers. Complex number is not a numeric
        type. Here we represent complex number as strings following the rule defined by Python.
        For instance, '1+2j' is an accepted complex string. Details can be found in
        [Python's `complex` documentation][complex].

        Args:
            schema: The core schema.

        Returns:
            The generated JSON schema.
        r   r*  rE   r  s     rG   complex_schemaz!GenerateJsonSchema.complex_schema  s     !!rF   c                ^    |j                         j                  dd      j                         S )zRetrieves a title from a name.

        Args:
            name: The name to retrieve a title from.

        Returns:
            The title.
        r    )rN  r   striprr   r  s     rG   r  z&GenerateJsonSchema.get_title_from_name  s&     zz|##C-3355rF   c                z   t        j                  |      r$|d   dk(  r|d   }n|d   }| j                  |      S t        j                  |      r`|j	                  d      ry|d   dv r| j                  |d         S t        j
                  |      r| j                  |d         S |d   dk(  ryy	t        d
|       )a  Returns true if a field with the given schema should have a title set based on the field name.

        Intuitively, we want this to return true for schemas that wouldn't otherwise provide their own title
        (e.g., int, float, str), and false for those that would (e.g., BaseModel subclasses).

        Args:
            schema: The schema to check.

        Returns:
            `True` if the field should have a title set, `False` otherwise.
        r   r  r  r~   rs   F>   r   r   rb   zdefinition-refTr   )r%   r   r  r   rp   is_function_with_inner_schemar-   )rr   r~   field_schemas      rG   r  z,GenerateJsonSchema.field_title_should_be_set  s     ++F3f~!11%o6%h/11,??''/zz% f~!GG55fX6FGG88@55fX6FGGf~!11  /1PQWPX/YZZrF   c                P    t        j                  dd|      j                  dd      S )zNormalizes a name to be used as a key in a dictionary.

        Args:
            name: The name to normalize.

        Returns:
            The normalized name.
        z[^a-zA-Z0-9.\-_]r   r   __)resubr   rp  s     rG   normalize_namez!GenerateJsonSchema.normalize_name  s%     vv)35==c4HHrF   c                <   |\  }}t        j                  d|      }|D cg c]  }|j                  dd      d    }}dj                  |      }|D cg c]  }t        j                  dd|       }}dj                  |      }t
        |   }t        | j                  |            }	t        | j                  |      d| z         }
t        | j                  |            }t        | d|       }t        | j                  |            }| j                  j                  |      }|5| j                  |xx   dz  cc<   | j                  |   x}| j                  |<   t        | d	|       }t        | d	|       }|	|
||||g| j                  |<   |S c c}w c c}w )
zOverride this method to change the way that definitions keys are generated from a core reference.

        Args:
            core_mode_ref: The core reference.

        Returns:
            The definitions key.
        z([\][,]):r"   r    z(?:[^.[\]]+\.)+((?:[^.[\]]+))z\1r   ru  )rv  splitrsplitjoinrw  r;   rI   rx  r   rp   r   r   )rr   r   r   r   
componentsrW   core_ref_no_id	short_ref
mode_titler  	name_modemodule_qualnamemodule_qualname_modemodule_qualname_idoccurrence_indexmodule_qualname_occurrencemodule_qualname_occurrence_modes                    rG   rc  zGenerateJsonSchema.get_defs_ref  s    '$XXk84
3=>aahhsA&q)>
>,R\]Qbff=uaH]
]GGJ'	(.

 t**956D//	:q=MMN	!$"5"5n"EF&/):!J<'HI$T%8%8%BC00445GH###O494KOKbKbcrKsst445GH%,/@CSBT-U%V"*15I4J"M]L^2_*`'  &+N
))*IJ /.C ? ^s   FFc                v   || j                   f}| j                  j                  |      }|| j                  |   }|d|ifS | j	                  |      }|| j                  |<   || j
                  |<   t        | j                  j                  |            }|| j                  |<   || j                  |<   d|i}||fS )a  This method wraps the get_defs_ref method with some cache-lookup/population logic,
        and returns both the produced defs_ref and the JSON schema that will refer to the right definition.

        Args:
            core_ref: The core reference to get the definitions reference for.

        Returns:
            A tuple of the definitions reference and the JSON schema that will refer to it.
        ry   ri  )
r   r   rp   r   rc  r   rJ   r   r2  r   )rr   r   r   maybe_defs_refr   rf   r   s          rG   r   z,GenerateJsonSchema.get_cache_defs_ref_schemaO  s     "499-//33MB%--m<H!FH#555$$]3 19}-+8x(4,,33(3CD08}-+3x(!8,((rF   c                    d|v ri|j                         }| j                  t        |d               }||S t        |j	                               D ]  \  }}|dk(  r||v s||   |k(  s||=  |S )zRemove any sibling keys that are redundant with the referenced schema.

        Args:
            json_schema: The schema to remove redundant sibling keys from.

        Returns:
            The schema with redundant sibling keys removed.
        ry   )r   r   rJ   r[   r}   )rr   r   referenced_json_schemar  r  s        rG   r  z'GenerateJsonSchema.handle_ref_overridesk  s     [ %**,K%)%E%EgkZ`NaFb%c"%- #"[..01 '1;..3I!3LPQ3Q#A	' rF   c                    	 | j                   |   }|| j                  v r| j                  |   | j                  j                  |d       S # t        $ r |j                  d      rY y  w xY wNzhttp://zhttps://)r   r   rb   rp   KeyError
startswith)rr   r   def_refs      rG   r   z.GenerateJsonSchema.get_schema_from_definitions  ss    	,,X6G$AAA==gFF##''66 	""#:;	s   AA
 
A(&A(c                |   ddl m}m} | j                  }	  |t	        |            r|n8 |t	        |      |j
                        j                  || j                  d      }t        j                  ||j                  |j                  | j                        S # t        $ r t        j                  d|       w xY w)a  Encode a default value to a JSON-serializable value.

        This is used to encode default values for fields in the generated JSON schema.

        Args:
            dft: The default value to encode.

        Returns:
            The encoded default value.
        r"   )TypeAdapter_type_has_config)r  json)r   r   zUnable to encode default value )timedelta_mode
bytes_moder   )type_adapterr  r  r#   r   config_dictdump_pythonr   r.   r  r  r   rA  r3  )rr   dftr  r  r  r   s         rG   r  z!GenerateJsonSchema.encode_default  s     	@		d $DI.  c63E3EFRR$--f S   //F$=$=&J_J_jnjwjw
 	
 - 	d::=\]`\a;bcc	ds   AB "B;c                N    |j                         D ]  \  }}||v s||   ||<    y)a  Update the json_schema with the corresponding validations specified in the core_schema,
        using the provided mapping to translate keys in core_schema to the appropriate keys for a JSON schema.

        Args:
            json_schema: The JSON schema to update.
            core_schema: The core schema to get the validations from.
            mapping: A mapping from core_schema attribute names to the corresponding JSON schema attribute names.
        N)r}   )rr   r   r   r   core_keyjson_schema_keys         rG   r  z*GenerateJsonSchema.update_with_validations  s7     *1 	E%Ho;&/:8/DO,	ErF   c                  J    e Zd ZdZddddddZdd	d
Zdd	ddZddd
Zddd
Zy)%GenerateJsonSchema.ValidationsMappingag  This class just contains mappings from core_schema attribute names to the corresponding
        JSON schema attribute names. While I suspect it is unlikely to be necessary, you can in
        principle override this class in a subclass of GenerateJsonSchema (by inheriting from
        GenerateJsonSchema.ValidationsMapping) to change these mappings.
        
multipleOfmaximumminimumexclusiveMaximumexclusiveMinimum)r  r   r!  r"  r#  rZ  	maxLength)
min_length
max_lengthr+  )r  r  r+  rv  rx  minPropertiesmaxPropertiesN)	rA   rB   rC   rD   r  r4  r*  rG  r  rE   rF   rG   r  r    s^    	 ($$
 &%

 &% 
 %$

 *)
rF   r  c                    g }|D ]:  }t        |      dk(  rd|v r|j                  |d          *|j                  |       < t        |      }t        |      dk(  r|d   S d|iS )Nr"   r$  r   )rU   r  r\   r]   )rr   schemasrP  r~   s       rG   r   z&GenerateJsonSchema.get_flattened_anyof  sr     	'F6{aGv$5vg/v&		'
 'w/w<11:!!rF   c                @     t               d fd |       S )zKGet all values corresponding to the key '$ref' anywhere in the json_schema.c                   t        | t              rd| v rut        | d         }t        |t              sy |v }|xx   dz  cc<   |ry 	 j                  |   }|j
                  v rj
                  |    j                  |          | j                         D ]#  \  }}|dk(  rt        |t              r |       % y t        | t              r| D ]
  } |        y y # t        $ r |j                  d      s Y uw xY w)Nry   r"   r  examples)rz   r|   rJ   r{   r   r   rb   r  r  r}   r[   )	r~   r   already_visitedrf   r  r  _add_json_refs	json_refsrr   s	         rG   r  z>GenerateJsonSchema.get_json_ref_counts.<locals>._add_json_refs  s    &$'V#&vf~6H%h4&.)&;Oh'1,'&"#'#9#9(#C#t'N'NN"&"I"I("SS&t'7'7'AB
 #LLN &DAqJ:a+> !"1%& FD) &A"1%& * $ "'223JK!  L"s   
AC# #D D)r~   r   r   None)r   )rr   r   r  r  s   ` @@rG   r   z&GenerateJsonSchema.get_json_ref_counts  s    (/			&: 	{#rF   c                    t        d|       )Nz!Cannot generate a JsonSchema for )r-   )rr   r~   
error_infos      rG   rW  z1GenerateJsonSchema.handle_invalid_for_json_schema	  s    *-Nzl+[\\rF   c                b    | j                  ||      }|t        j                  |t               yy)zfThis method simply emits PydanticJsonSchemaWarnings based on handling in the `warning_message` method.N)render_warning_messagerm  rn  r@   )rr   kinddetailr  s       rG   r  zGenerateJsonSchema.emit_warning	  s.    --dF;MM'#<= rF   c                0    || j                   v ry| d| dS )am  This method is responsible for ignoring warnings as desired, and for formatting the warning messages.

        You can override the value of `ignored_warning_kinds` in a subclass of GenerateJsonSchema
        to modify what warnings are generated. If you want more control, you can override this method;
        just return None in situations where you don't want warnings to be emitted.

        Args:
            kind: The kind of warning to render. It can be one of the following:

                - 'skipped-choice': A choice field was skipped because it had no valid choices.
                - 'non-serializable-default': A default value was skipped because it was not JSON-serializable.
            detail: A string with additional details about the warning.

        Returns:
            The formatted warning message, or `None` if no warning should be emitted.
        Nz [])r   )rr   r  r  s      rG   r  z)GenerateJsonSchema.render_warning_message	  s(    " 4---D6##rF   c                    i }| j                   j                         D ]3  }|D ],  }t        | j                  j	                  |            }|||<   . 5 t
        j                  | j                   || j                        S )Nr  )r   r  rJ   r   r2  rN   rm   rb   )rr   ra   	defs_refsrf   r   s        rG   r   z/GenerateJsonSchema._build_definitions_remapping+	  s    /1::AAC 	2I% 2"4#4#4#;#;(#;#KL)1X&2	2
 %==--|T=M=M
 	
rF   c                   t               }t        |      }|r`|j                         }	 | j                  |   }||v r'|j	                  |       |j                  t        | j                  |                |r`| j                  j                         D ci c]  \  }}||v s|| c}}| _        y # t        $ r |j                  d      s Y Yw xY wc c}}w r  )
set_get_all_json_refsr   r   addr   rb   r  r  r}   )rr   r~   visited_defs_refsunvisited_json_refsnext_json_refnext_defs_refr  r  s           rG   r   z/GenerateJsonSchema._garbage_collect_definitions6	  s    *-%08!/335M $ 6 6} E $55!%%m4#**+=d>N>N}>]+^_ " .2-=-=-C-C-E`TQN_I_AqD`	  $//0GH I as"   B1 8B1 C"C1CC)r   rH  r   r{   )r   z_config.ConfigWrapper)r   JsonSchemaMode)r   zKdict[CoreSchemaOrFieldType, Callable[[CoreSchemaOrField], JsonSchemaValue]])r   zGSequence[tuple[JsonSchemaKeyT, JsonSchemaMode, core_schema.CoreSchema]]r   zctuple[dict[tuple[JsonSchemaKeyT, JsonSchemaMode], JsonSchemaValue], dict[DefsRef, JsonSchemaValue]])r7   )r~   r   r   r  r   r   )r~   r2   r   r   ro   )r   r   r   
str | Noner   r   )r   r   r   r  r   r   )r~   zcore_schema.InvalidSchemar   r   )r~   zcore_schema.AnySchemar   r   )r~   zcore_schema.NoneSchemar   r   )r~   zcore_schema.BoolSchemar   r   )r~   zcore_schema.IntSchemar   r   )r~   zcore_schema.FloatSchemar   r   )r~   zcore_schema.DecimalSchemar   r   )r~   zcore_schema.StringSchemar   r   )r~   zcore_schema.BytesSchemar   r   )r~   zcore_schema.DateSchemar   r   )r~   zcore_schema.TimeSchemar   r   )r~   zcore_schema.DatetimeSchemar   r   )r~   zcore_schema.TimedeltaSchemar   r   )r~   zcore_schema.LiteralSchemar   r   )r~   zcore_schema.EnumSchemar   r   )r~   zcore_schema.IsInstanceSchemar   r   )r~   zcore_schema.IsSubclassSchemar   r   )r~   r\  r   r   )r~   zcore_schema.ListSchemar   r   )r~   zcore_schema.TupleSchemar   r   )r~   zcore_schema.SetSchemar   r   )r~   zcore_schema.FrozenSetSchemar   r   )r~   z3core_schema.SetSchema | core_schema.FrozenSetSchemar   r   )r~   zcore_schema.GeneratorSchemar   r   )r~   zcore_schema.DictSchemar   r   )r~   z)core_schema.BeforeValidatorFunctionSchemar   r   )r~   z(core_schema.AfterValidatorFunctionSchemar   r   )r~   z(core_schema.PlainValidatorFunctionSchemar   r   )r~   z'core_schema.WrapValidatorFunctionSchemar   r   )r~   core_schema.WithDefaultSchemar   r   )r~   r  r   r   )r~   zcore_schema.NullableSchemar   r   )r~   zcore_schema.UnionSchemar   r   )r~   core_schema.TaggedUnionSchemar   r   )r~   r  r  list[JsonDict]r   r  )r~   zcore_schema.ChainSchemar   r   )r~   zcore_schema.LaxOrStrictSchemar   r   )r~   zcore_schema.JsonOrPythonSchemar   r   )r~   zcore_schema.TypedDictSchemar   r   )r  zlist[ComputedField]r   z1list[tuple[str, bool, core_schema.ComputedField]])r  z+Sequence[tuple[str, bool, CoreSchemaField]]r   r   )r  r1   r  r{   r   r{   )r~   zcore_schema.TypedDictFieldr   r   )r~   zcore_schema.DataclassFieldr   r   )r~   zcore_schema.ModelFieldr   r   )r~   zcore_schema.ComputedFieldr   r   )r~   zcore_schema.ModelSchemar   r   )r   r   rM  z	type[Any]r  r0   r   r  )r   r   r   r   )r~   zcore_schema.ModelFieldsSchemar   r   )r  r1   r   rH  )r  zPcore_schema.ModelField | core_schema.DataclassField | core_schema.TypedDictFieldr  rH  r   rH  )r~   zcore_schema.DataclassArgsSchemar   r   )r~   zcore_schema.DataclassSchemar   r   )r~   zcore_schema.ArgumentsSchemar   r   )r9  $list[core_schema.ArgumentsParameter]r5  CoreSchema | Noner   r   )r9  r  r4  r  r   r   )rB  zAcore_schema.ArgumentsParameter | core_schema.ArgumentsV3Parameterr   r{   )r~   zcore_schema.ArgumentsV3Schemar   r   )r~   zcore_schema.CallSchemar   r   )r~   zcore_schema.CustomErrorSchemar   r   )r~   zcore_schema.JsonSchemar   r   )r~   zcore_schema.UrlSchemar   r   )r~   zcore_schema.MultiHostUrlSchemar   r   )r~   zcore_schema.UuidSchemar   r   )r~   zcore_schema.DefinitionsSchemar   r   )r~   z%core_schema.DefinitionReferenceSchemar   r   )r~   zVcore_schema.SerSchema | core_schema.IncExSeqSerSchema | core_schema.IncExDictSerSchemar   JsonSchemaValue | None)r~   zcore_schema.ComplexSchemar   r   )r  r{   r   r{   )r~   r2   r   rH  )r   CoreModeRefr   rI   )r   rH   r   ztuple[DefsRef, JsonSchemaValue])r   rJ   r   r  )r  r   r   r   )r   r   r   r   r   zdict[str, str]r   r  )r  zlist[JsonSchemaValue]r   r   )r   r   r   zdict[JsonRef, int])r~   r2   r  r{   r   r   )r  JsonSchemaWarningKindr  r{   r   r  )r  r  r  r{   r   r  )r   rN   )r~   r   r   r  )mrA   rB   rC   rD   schema_dialectr   r   DEFAULT_REF_TEMPLATEr   propertyr#   r   r   r   r   r   r   r   r  r  r
  r  r  r  r(  r&  r5  r8  r<  r>  rB  rK  rT  rX  rZ  r]  rc  r   r   rp  rs  ro  r|  r  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r   r!  r  r  r'  r,  r0  r7  r6  rA  rM  rO  rQ  r   r\  r^  ra  rd   rg  r   rl  r  r  rx  rc  r   r  r   r  r  r  r   r   rW  r  r  r   r   rE   rF   rG   r   r      s{   B DN :J8J5J(,BV "H / /  	T4/A]/A	l/Ab/&bKZ(j
		 	#B 	4	4	98@"HnY Vaef
)  g) T_cd
)  e)!F	/	/.`5	5
 54l0N&32#J+%3+%ES+%	+%Z@=&:B T,T	:T T
%P	2*	5	5	5	<*E-N(.$$<_< < 
	<2I$<"
H#=#Rc#	#J(=(Pa(	(T$%N	?	5'"	45$l	2"$	6![F	I./`)86	
:E*E9CEN\E	E
 
@
""H]>$*	
arF   r   Tr7   c                L   ddl m}  |||      }t        | j                  t        j
                        r| j                  j                          | |u rt        d      t        | j                  t        j
                        rJ d       |j                  | j                  |      S )a  Utility function to generate a JSON Schema for a model.

    Args:
        cls: The model class to generate a JSON Schema for.
        by_alias: If `True` (the default), fields will be serialized according to their alias.
            If `False`, fields will be serialized according to their attribute name.
        ref_template: The template to use for generating JSON Schema references.
        schema_generator: The class to use for generating the JSON Schema.
        mode: The mode to use for generating the JSON Schema. It can be one of the following:

            - 'validation': Generate a JSON Schema for validating data.
            - 'serialization': Generate a JSON Schema for serializing data.

    Returns:
        The generated JSON Schema.
    r"   r5   r   r   zTmodel_json_schema() must be called on a subclass of BaseModel, not BaseModel itself.zthis is a bug! please report it)r   )	r  r6   rz   __pydantic_core_schema__r(   MockCoreSchemarebuildr   r   )rM  r   r   schema_generatorr   r6   schema_generator_instances          rG   model_json_schemar  K	  s    .   0(Q] ^#..0L0LM$$,,.
istt#668T8TUxWxx$--c.J.JQU-VVrF   )r   rN  rO  r   r  c               T   | D ]D  \  }}t        |j                  t        j                        s+|j                  j	                          F  |||      }| D 	
cg c]  \  }	}
|	|
|	j                  f }}	}
|j                  |      \  }}i }|r||d<   |r||d<   |r||d<   ||fS c c}
}	w )a?  Utility function to generate a JSON Schema for multiple models.

    Args:
        models: A sequence of tuples of the form (model, mode).
        by_alias: Whether field aliases should be used as keys in the generated JSON Schema.
        title: The title of the generated JSON Schema.
        description: The description of the generated JSON Schema.
        ref_template: The reference template to use for generating JSON Schema references.
        schema_generator: The schema generator to use for generating the JSON Schema.

    Returns:
        A tuple where:
            - The first element is a dictionary whose keys are tuples of JSON schema key type and JSON mode, and
                whose values are the JSON schema corresponding to that pair of inputs. (These schemas may have
                JsonRef references to definitions that are defined in the second returned element.)
            - The second element is a JSON schema containing all definitions referenced in the first returned
                    element, along with the optional title and description keys.
    r  rR   rN  rO  )rz   r  r(   r  r  r   )modelsr   rN  rO  r   r  rM  r   instancemr   r   r   rb   r   s                  rG   models_json_schemar  p	  s    6  3Qc22M4P4PQ((0023  MH=Cb29!TD!,,-bF b %-$A$A&$I!k"$K*G$G%0M"[((bs   B$)_HashableJsonValue.r  .r   c                n    t        | D ci c]  }t        |      | c}j                               S c c}w ro   )r[   _make_json_hashabler  )r  r~   s     rG   r]   r]   	  s/    7K$V,f4KRRTUUKs   2c                    t        | t              r)t        t        d | j	                         D                    S t        | t
              rt        d | D              S | S )Nc              3  <   K   | ]  \  }}|t        |      f  y wro   r  )rV   r  r  s      rG   rY   z&_make_json_hashable.<locals>.<genexpr>	  s     RDAqQ 3A 67Rs   c              3  2   K   | ]  }t        |        y wro   r  )rV   r  s     rG   rY   z&_make_json_hashable.<locals>.<genexpr>	  s     ;(+;s   )rz   r|   r  r   r}   r[   )r   s    rG   r  r  	  sH    %VREKKMRRSS	E4	 ;U;;;rF   c                  F    e Zd ZU dZded<   dZded<   	 	 	 	 	 	 d	dZd
dZy)WithJsonSchemaaQ  !!! abstract "Usage Documentation"
        [`WithJsonSchema` Annotation](../concepts/json_schema.md#withjsonschema-annotation)

    Add this as an annotation on a field to override the (base) JSON schema that would be generated for that field.
    This provides a way to set a JSON schema for types that would otherwise raise errors when producing a JSON schema,
    such as Callable, or types that have an is-instance core schema, without needing to go so far as creating a
    custom subclass of pydantic.json_schema.GenerateJsonSchema.
    Note that any _modifications_ to the schema that would normally be made (such as setting the title for model fields)
    will still be performed.

    If `mode` is set this will only apply to that schema generation mode, allowing you
    to set different json schemas for validation and serialization.
    r  r   N-Literal['validation', 'serialization'] | Noner   c                    | j                   xs |j                   }||j                   k7  r ||      S | j                  t        | j                  j                         S ro   )r   r   r   r   )rr   r   handlerr   s       rG   __get_pydantic_json_schema__z+WithJsonSchema.__get_pydantic_json_schema__	  sT     yy(GLL7<<;''###((**rF   c                >    t        t        | j                              S ro   hashr   r   r   s    rG   __hash__zWithJsonSchema.__hash__	      DO$$rF   r   zcore_schema.CoreSchemar  r*   r   r   r   r   )rA   rB   rC   rD   r   r   r  r  rE   rF   rG   r  r  	  s<     (':>D
7>
+1
+<P
+	
+%rF   r  c                      e Zd ZdZe ed      	 d		 	 	 	 	 d
d              Zed	dd       Z	 d		 	 	 	 	 ddZ	 	 	 	 	 	 ddZddZy)Examplesa  Add examples to a JSON schema.

    If the JSON Schema already contains examples, the provided examples
    will be appended.

    If `mode` is set this will only apply to that schema generation mode,
    allowing you to add different examples for validation and serialization.
    zeUsing a dict for `examples` is deprecated since v2.9 and will be removed in v3.0. Use a list instead.Nc                     y ro   rE   rr   r  r   s      rG   r   zExamples.__init__	  s     rF   c                     y ro   rE   r  s      rG   r   zExamples.__init__	  s    qtrF   c                x    t        |t              rt        j                  dt        d       || _        || _        y )Nz>Using a dict for `examples` is deprecated, use a list instead.ri  rj  )rz   r|   rm  rn  r!   r  r   r  s      rG   r   zExamples.__init__	  s3     h%MMP)
 !	rF   c           	        | j                   xs |j                   } ||      }||j                   k7  r|S |j                  d      }|t        | j                        |d<   t	        |t
              rt	        | j                  t              r[t        j                  dt               t        |j                         D cg c]  }|D ]  }|  c}}| j                  z         |d<   nt        i || j                        |d<   t	        |t              rt	        | j                  t              rt        || j                  z         |d<   |S t	        | j                  t
              rZt        j                  dt               t        || j                  j                         D cg c]  }|D ]  }|  c}}z         |d<   |S c c}}w c c}}w )Nr  zUpdating existing JSON Schema examples of type dict with examples of type list. Only the existing examples values will be retained. Note that dict support for examples is deprecated and will be removed in v3.0.zUpdating existing JSON Schema examples of type list with examples of type dict. Only the examples values will be retained. Note that dict support for examples is deprecated and will be removed in v3.0.)r   rp   r   r  rz   r|   r[   rm  rn  UserWarningr  )rr   r   r  r   r   r  r   exs           rG   r  z%Examples.__get_pydantic_json_schema__	  s    yy(GLLk*7<<??:.&8&GK
#h%$--.J  	 +=%-__%6GEG2RGRG$--W+J' +==Z=ZDMM=Z*[J'h%$--.*<X=U*VJ'  DMM40J  	 +=0D0D0FWuQVW2WWW+J' % H  Xs   ;F=
Gc                >    t        t        | j                              S ro   r  r   s    rG   r  zExamples.__hash__
  r  rF   ro   )r  dict[str, Any]r   r  r   r  )r  z	list[Any]r   r  r   r  )r  zdict[str, Any] | list[Any]r   r  r   r  r  r  )	rA   rB   rC   rD   r   r   r   r  r  rE   rF   rG   r  r  	  s     wx^b&.[	 y  t t ko
2
:g
	
%1%<P%	%N%rF   r  c                   t               }| g}|r|j                         }t        |t              r|j	                         D ]  \  }}|dk(  rt        |t
              r|dk(  r+t        |t              r|j                  t        |             Lt        |t              r|j                  |       nt        |t
              s|j                  |        n!t        |t
              r|j                  |       |r|S )z6Get all the definitions references from a JSON schema.r  ry   )r  r   rz   r|   r}   r[   r{   r  rJ   r\   r  )r   refsstackcurrentr   r   s         rG   r  r  "
  s    DFE
))+gt$%mmo (
U*$E4)@ &=Zs%;HHWU^,t,LL't,LL'( &LL!% ( KrF   AnyTypec                  4    e Zd ZdZddZ	 	 	 	 	 	 ddZddZy)	SkipJsonSchemaaH  !!! abstract "Usage Documentation"
            [`SkipJsonSchema` Annotation](../concepts/json_schema.md#skipjsonschema-annotation)

        Add this as an annotation on a field to skip generating a JSON schema for that field.

        Example:
            ```python
            from pprint import pprint
            from typing import Union

            from pydantic import BaseModel
            from pydantic.json_schema import SkipJsonSchema

            class Model(BaseModel):
                a: Union[int, None] = None  # (1)!
                b: Union[int, SkipJsonSchema[None]] = None  # (2)!
                c: SkipJsonSchema[Union[int, None]] = None  # (3)!

            pprint(Model.model_json_schema())
            '''
            {
                'properties': {
                    'a': {
                        'anyOf': [
                            {'type': 'integer'},
                            {'type': 'null'}
                        ],
                        'default': None,
                        'title': 'A'
                    },
                    'b': {
                        'default': None,
                        'title': 'B',
                        'type': 'integer'
                    }
                },
                'title': 'Model',
                'type': 'object'
            }
            '''
            ```

            1. The integer and null types are both included in the schema for `a`.
            2. The integer type is the only type included in the schema for `b`.
            3. The entirety of the `c` field is omitted from the schema.
        c                "    t         | |        f   S ro   )r   )rM  r   s     rG   __class_getitem__z SkipJsonSchema.__class_getitem__u
  s    T35[))rF   c                    t         ro   )r   )rr   r   r  s      rG   r  z+SkipJsonSchema.__get_pydantic_json_schema__x
  s
     rF   c                *    t        t        |             S ro   )r  r   r   s    rG   r  zSkipJsonSchema.__hash__}
  s    T
##rF   N)r   r  r   r  )r   r   r  r*   r   r   r  )rA   rB   rC   rD   r
  r  r  rE   rF   rG   r  r  D
  s/    -	^	*	)	4H		
	$rF   r  c                X    | 	 t        j                  | d      S i S # t        $ r Y i S w xY w)Nr*  )r&   get_attribute_from_basesr   )rM  s    rG   r  r  
  s@    
	77=RSS I  	I	s    	))rE   )rM  z)type[BaseModel] | type[PydanticDataclass]r   rH  r   r{   r  type[GenerateJsonSchema]r   r  r   r  )r  zJSequence[tuple[type[BaseModel] | type[PydanticDataclass], JsonSchemaMode]]r   rH  rN  r  rO  r  r   r{   r  r  r   zotuple[dict[tuple[type[BaseModel] | type[PydanticDataclass], JsonSchemaMode], JsonSchemaValue], JsonSchemaValue])r  zIterable[JsonDict]r   r  )r   r,   r   r  )r   r   r   zset[JsonRef])rM  ztype[Any] | Noner   r0   )urD   
__future__r   _annotationsr  rQ  r  r   rv  rm  collectionsr   r   collections.abcr   r   r   r   r	   rF  r
   r   typingr   r   r   r   r   r   r   r   r   r   r  r   r   r   r   pydantic_core.core_schemar   typing_extensionsr   r   r   r   typing_inspection.introspectionr   pydantic.warningsr    r!   	_internalr#   r$   r%   r&   r'   r(   r)   annotated_handlersr*   r  r+   r,   errorsr-   r.   r/   r{  r0   _internal._core_utilsr1   r2   r+  r3   #_internal._schema_generation_sharedr4   r  r6   CoreSchemaTypeCoreSchemaFieldTyper   r|   r{   r   r  r;   r   r  r  r@   r  r  r  rH   rI   rJ   r  r  rK   	dataclass
slots_truerN   r   r  r  r   r'  rH  r  r]   r  r  r  r  r  r  r  rE   rF   rG   <module>r"     s>  	 3    	 	  , 8 8       S S 3 H H > R   5 ' b bI9J   : :K<[<[ [\  sCx. 67 AHZb1c . c   ef   H	 )  A
 )S
! )S
! )S
!G^+,): 8,778M M 9M`m!a m!ajC ,1C'"W	2"W"W "W /	"W
 "W "WP ",1C-)V-) -) 	-)
 -) -) /-) u-)f !&T4'@!A5sThOhIiknInCoo! I 
V 8,778% % 9%DG% G%T8 )
w|,N [<0;;<9$ 9$ =9$xrF   