;i UdZddlmZddlZddlZddlZddlZddlZddl Z ddl m Z m Z ddl mZmZmZddlmZddlmZddlmZdd lmZmZmZmZmZmZmZmZmZm Z ddl!Z!dd l!m"Z"m#Z#m$Z$m%Z%m&Z&dd l'm(Z(dd l)m*Z*m+Z+m,Z,m-Z-dd l.m/Z/ddl0m1Z1m2Z2ddl3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:ddl;mZ>m?Z?ddl@mAZAmBZBmCZCer ddlDmEZEddlFmGZGmHZHddlImJZJddlKmLZLddlMmNZNee%jOe%jPfZQ eReSefZT edZU dddZVdeWd<edZX Gdd eYZZe[Z\ d!Z] ed"eSZ^ed#eSZ_ed$eSZ`eae^eUfZbed%e&Zcd'Zdejedcie8jfGd(d)ZgGd*d+Zhd,e]d-ehd.fddd=Zid,dde]d-ehd>dedEZjeekeleSemdeadFeaeaeSdGfdHffZndIeWdG<dfdMZodgdPZpejedcie8jfGdQdRZqGdSdTZrdhdXZsedYZter eetdHfZun%ejedcie8jfGdZd[Zudid^ZvdjdbZwdS)ka!!! 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)HashableIterableSequence)deepcopy)Enum)Pattern) TYPE_CHECKING AnnotatedAnyCallableLiteralNewTypeTypeVarUnioncastoverload)MISSING CoreSchema PydanticOmit core_schemato_jsonable_python) ComputedField) TypeAlias assert_never deprecatedfinal)get_literal_values)PydanticDeprecatedSince26PydanticDeprecatedSince29)_config_core_metadata _core_utils _decorators_internal_dataclass _mock_val_ser_schema_generation_shared)GetJsonSchemaHandler)JsonDict JsonValue)PydanticInvalidForJsonSchemaPydanticSchemaGenerationErrorPydanticUserError) ConfigDict)CoreSchemaFieldCoreSchemaOrField)PydanticDataclass)GetJsonSchemaFunction BaseModel) validation serializationInputOutputzdict[JsonSchemaMode, str]_MODE_TITLE_MAPPING)skipped-choicenon-serializable-defaultskipped-discriminatorceZdZdZdS)PydanticJsonSchemaWarningaThis 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__HC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\pydantic/json_schema.pyrArAesrGrAz#/$defs/{model}CoreRefDefsRefJsonRefJsonSchemaKeyT)bound)stringbooleannullintegernumbercTeZdZUded<ded<edd ZddZddZddZdS)_DefinitionsRemappingzdict[DefsRef, DefsRef]defs_remappingzdict[JsonRef, JsonRef]json_remappingprioritized_choicesdict[DefsRef, list[DefsRef]] defs_to_jsondict[DefsRef, JsonRef] definitionsdict[DefsRef, JsonSchemaValue]returnct|}d|i}tdD]}tt|D]0}||}|D]#}|||$1D]}t ||<i} i} |D];} || }t fd|D} | | | <|| | || <zA_DefinitionsRemapping.from_prioritized_choices..s=(j(jqCH`abHcDdDdhiDiDiDiDiDiDi(j(jrGz.Failed to simplify the JSON schema definitions) r rangerlistappend_deduplicate_schemasnextrTremap_json_schemar.)rWrYr[copied_definitionsdefinitions_schema_iterdefs_ref alternatives alternativerUrVoriginal_defs_refremapped_defs_ref remappingnew_definitions_schemares @rHfrom_prioritized_choicesz._DefinitionsRemapping.from_prioritized_choicess&k22%'9:3ZZ 8 8EMXY]M^M^ $. _ _28< #/__K,[9@@AST\A]^^^^_ 5 n n5IJbckJl5m5m(2268N57N%0 b b!23DE $((j(j(j(jL(j(j(j$j$j!4E01BNO`Ba|,=>??-nnMMI%.%@%@'K]A^%_%_ "!%;;;    !7  *+[\\\rGrefrJc8|j||SN)rUgetselfrxs rHremap_defs_refz$_DefinitionsRemapping.remap_defs_ref"&&sC000rGrKc8|j||Srz)rVr{r|s rHremap_json_refz$_DefinitionsRemapping.remap_json_refrrGschemarc,t|tr"t|St|trfd|DSt|t r|D]\}}|dkr;t|tr&t||d<F|dkr*fd|dD|d<v|||<|S)zH Recursively update the JSON schema replacing all $refs c:g|]}|SrF)rlrcitemr}s rH z;_DefinitionsRemapping.remap_json_schema..s'DDDTD**400DDDrG$refr_ci|];\}}t||z;_DefinitionsRemapping.remap_json_schema..sR'''&C++GCLL994;Q;QRW;X;X'''rG) isinstancestrrrKrhdictitemsrl)r}rrrs` rHrlz'_DefinitionsRemapping.remap_json_schemas, fc " " @&&wv77 7  % % @DDDDVDDD D  % % @$llnn @ @ U&==Zs%;%;=%)%8%8%H%HF6NNG^^''''*0/*?*?*A*A'''F7OO #'"8"8"?"?F3KK rGN)rWrXrYrZr[r\r]rT)rxrJr]rJ)rxrKr]rK)rrr]r) rBrCrD__annotations__ staticmethodrwr~rrlrFrGrHrTrTs********,],],]\,]\11111111rGrTceZdZUdZdZdhZded<dedfddZe ddZ e ddZ ddZ ddZ ddd Zdd"Zddd'Zddd)Zdd+Zdd-Zdd/Zdd1Zdd3Zdd5Zdd7Zdd9Zdd;Zdd=Zdd?ZddAZddCZddEZddGZ d dIZ!d dKZ"d dMZ#d dOZ$d dQZ%e&dRd#Se'ddUZ(e&dVd#Se'ddWZ)ddXZ*ddZZ+dd\Z,dd^Z-dd`Z.ddbZ/dddZ0ddfZ1ddhZ2ddjZ3ddlZ4ddmZ5ddoZ6ddqZ7ddtZ8ddvZ9ddyZ:dd{Z;d d}Z<d!dZ=d"dZ>e?d#dZ@d$dZAd%dZBd&dZCd'dZDd(dZEd)dZFd*dZGd+dZHd,dZId-dZJd.dZKd/dZLd0dZMd1dZNd2dZOd3dZPd4dZQd5dZRd6dZSd7dZTd8dZUd9dZVd:dZWd;dZXddńZ[d?dȄZ\d@dʄZ]dAd˄Z^dBd̄Z_dAd̈́Z`dCdфZadDdՄZbd,dքZcdEdلZddFdۄZedGd߄ZfGddZgddZhdHdZidIdZjdJdZkdKdZldLdZmdMdZnd#S(NGenerateJsonSchemaa !!! 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. union_format: The format to use when combining schemas from unions together. Can be one of: - `'any_of'`: Use the [`anyOf`](https://json-schema.org/understanding-json-schema/reference/combining#anyOf) keyword to combine schemas (the default). - `'primitive_type_array'`: Use the [`type`](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (`string`, `boolean`, `null`, `integer` or `number`) or contains constraints/metadata, falls back to `any_of`. Raises: JsonSchemaError: If the instance of the class is inadvertently reused after generating a schema. z,https://json-schema.org/draft/2020-12/schemar=zset[JsonSchemaWarningKind]ignored_warning_kindsTany_ofby_aliasbool ref_templater union_format)Literal['any_of', 'primitive_type_array']r]Nonecv||_||_||_i|_i|_i|_i|_i|_tj tj i|_ d|_ i|_ tt|_i|_||_i|_d|_dS)Nr8F)rrrcore_to_json_refscore_to_defs_refsdefs_to_core_refsjson_to_defs_refsr[r$ConfigWrapperStack ConfigWrapper_config_wrapper_stack_mode_prioritized_defsref_choicesrint_collision_counter_collision_indexbuild_schema_type_to_method_schema_type_to_method"_core_defs_invalid_for_json_schema_used)r}rrrs rH__init__zGenerateJsonSchema.__init__ s ! (GS=?=?=?9;;=%,%?@UVX@Y@Y%Z%Z"%1 KM)2=c2B2B02&*&F&F&H&H#`b/ rG_config.ConfigWrapperc|jjSrz)rtailr}s rHr$zGenerateJsonSchema._config4s)..rGJsonSchemaModec@|jj |jjS|jSrz)r$json_schema_mode_overriderrs rHmodezGenerateJsonSchema.mode8s < 1 =<9 9: rGKdict[CoreSchemaOrFieldType, Callable[[CoreSchemaOrField], JsonSchemaValue]]c ^i}ttt}|D]}|ddd} t ||||<0#t $rJ}t jdrYd}~Std|dt|j d|d |d}~wwxYw|S) aOBuilds 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: .)) rhr CoreSchemaOrFieldTypereplacegetattrAttributeErrorosgetenv TypeErrortyperB)r}mappingcore_schema_typesr method_namees rHrz.GenerateJsonSchema.build_schema_type_to_method?s`b9=>PQf>g>g9h9h$  C [[c22;;;K &t[99 !   9LMMHHHHGPSGG"&t**"5GG8CGGG sA B* B%9,B%%B*inputsGSequence[tuple[JsonSchemaKeyT, JsonSchemaMode, core_schema.CoreSchema]]ctuple[dict[tuple[JsonSchemaKeyT, JsonSchemaMode], JsonSchemaValue], dict[DefsRef, JsonSchemaValue]]c|jr'tdt|jdd|D]"\}}}||_||#|}i}|D]<\}}}||_||}|||||f<=d|ji}||}d|_|| |dfS)aGenerates 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-usedcoder_T) rr0rrBrgenerate_inner_build_definitions_remappingrlr[sort) r}rrrrdefinitions_remappingjson_schemas_mapr json_schemas rHgenerate_definitionsz'GenerateJsonSchema.generate_definitionsYs/2 : #j59$ZZ5Hjjj/  & ( (OAtVDJ    ' ' ' ' $ A A C CQS!' a a CvDJ--f55K,A,S,ST_,`,` c4[ ) ) 01 +==kJJ  ;w+?!@!@@@rGr8rrrJsonSchemaValuec||_|jr'tdt|jdd||}||}tt| d}|| |}||dkra|_t|dkrL| }||xxdzcc<tt| d}d}|| ||}|jr |j|d<||}d |_||S) aGenerates 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. rrrrrNr#r_T)rrr0rrBrget_json_ref_countsrrKr{get_schema_from_definitionsrbcopy_garbage_collect_definitionsrr[rlr)r}rrrjson_ref_countsrxref_json_schemars rHgeneratezGenerateJsonSchema.generates : #j59$ZZ5Hjjj/  (,':':6'B'B 22;??7KOOF3344o">>sCCOs#q((_-HSQ\M]M]abMbMb-2244 $$$)$$$7KOOF$;$;<<Co ))+666 $ A A C C   4#'#3K +==kJJ  yy%%%rGr3cF d|vrJt|d}|jf}|jvr#j|jvrdj|iSdfd dfd }t j|}ttj | d i}| d x r|fd fd }t j|}| dx r|fd fd }t j|}| ddD] } || fdfd } t j| }!| ddD]} || fdd} t j| }||} tj |r || } | S)aGenerates 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. rxrrrrrr]cd|vrt|d}|\}}t|d}|dd|kr%|j|<j|d|}|S)Nrxr)rIget_cache_defs_ref_schemarKr{r[rpop)rrcore_refrprjson_refr}s rH populate_defsz8GenerateJsonSchema.generate_inner..populate_defss ##";u#566,0,J,J8,T,T)/"?6#:;;??6400H<<1.handler_funcs37KyO++?0R0R-_= "ooj99  +"{337ZZZ'/:=="&";";ff=M{<["\"\K"-o>>Y+BbcrBsBsY/3/J?[aKb/c,":":?"K"KKK#$Wo$W$WXXX rGmetadatapydantic_js_updatescurrent_handlerr+c&i||}|SrzrF)rrr js_updatess rHjs_updates_handler_funczBGenerateJsonSchema.generate_inner..js_updates_handler_func s%Q!A!APZP ""rGpydantic_js_extrac||}ttr#|tnt r ||Srz)rrupdatercallable)rrrjs_extras rHjs_extra_handler_funcz@GenerateJsonSchema.generate_inner..js_extra_handler_funcsl.oo>> h--*&&'9('C'CDDDDh''*H[)))""rGpydantic_js_functionsrFjs_modify_functionr5c|||}tj|r ||}||}|dd}|r|r|||S)Nr)r&rresolve_ref_schemarr)rrrroriginal_schemarxrs rHnew_handler_funcz;GenerateJsonSchema.generate_inner..new_handler_func's 10/RR -o>>N"/-"M"MK"1"D"D["Q"Q!oofd338;8#**;777&&rG pydantic_js_annotation_functionsc|||SrzrF)rrrs rHrz;GenerateJsonSchema.generate_inner..new_handler_func9s *)/?KKKrG)rrrrr]r)rr3r]r)rr3rr+r]r)rr3rr+rr5r]r) rIrrr[rr*GenerateJsonSchemaHandlerrr% CoreMetadatar{r&r)r}rr core_mode_refrrrrrrrrrrrs` @@@rHrz!GenerateJsonSchema.generate_inners F??ve}--H%ty1M 6664;QR_;`dhdt;t;t 6} EFF      # # # # # # J4MdT`aa3VZZ B5O5OPP"&;<< <: q9H # # # # # # #8QRVXoppO||$788 88 o9H # # # # # # #8QRVXmnnO"*,,/F"K"K j j 9H.`s*1k1k1k]a$2F2FtZ2X2X1k1k1krG)rrrrrrh)r}rrrrr sorted_lists` ` rHrz"GenerateJsonSchema._sort_recursiveUs eT " " 68K::<.6^^^1qTXT\S\H]?]?]q!?]?]?]rGupdate_with_validationsValidationsMappingnumericrr}rrs rH int_schemazGenerateJsonSchema.int_schemasQ(.y&9  $$[&$:Q:YZZZ^^ (9(9(;(;^^^ rGcore_schema.FloatSchemacddi}||||jjd|D}|S)zGenerates a JSON schema that matches a float value. Args: schema: The core schema. Returns: The generated JSON schema. rrRcPi|]#\}}|tjtj hv ||$SrFr-r0s rHrz3GenerateJsonSchema.float_schema..r3rGr4r8s rH float_schemazGenerateJsonSchema.float_schemasQ(.x&8  $$[&$:Q:YZZZ^^ (9(9(;(;^^^ rGcore_schema.DecimalSchemac dd}|tj||}|jdkr|d}|d }|d }|d }|d }d |tj|d|dnt ||dnt ||dnt ||dnt ||dnt ||gi}|S)zGenerates a JSON schema that matches a decimal value. Args: schema: The core schema. Returns: The generated JSON schema. rr>r]rc |d}|d}d}|+|)td||z }|d|d|dzd|d |d z }n'|||d|d|dzd z }n| | |d |d z }n|dz }|S)N max_digitsdecimal_placesz^(?!^[-+.]*$)[+-]?0*rz(?:\d{0,z }|(?=[\d.]{1,r#z }0*$)\d{0,z}\.\d{0,z}0*$)z}0*$)\d*\.\d*0*$)z \d*\.?\d{0,z}0*$z \d*\.?\d*$)r{max)rrArBpatterninteger_placess rHget_decimal_patternz>GenerateJsonSchema.decimal_schema..get_decimal_patternsL11J#ZZ(899N(  %.*D!$Q ^(C!D!D,%/N- 9G 'N,B(%/N#(B@>@@@@=(NrG)rDr8 multiple_oflegeltgtanyOf allow_inf_nanN)rMrGrHrIrJrK)rr>r]r) str_schemarrr{r=float) r}rrFrrGrHrIrJrKs rHdecimal_schemaz!GenerateJsonSchema.decimal_schemasR' ' ' ' Rook&.Hs7jjjRS&*Q2E2E'Lqww1MMjjjrGexpectedr#rconstenumc,h|]}t|SrFrrcrs rH z4GenerateJsonSchema.literal_schema..P+++Qa+++rGrNrrQrRrOarrayNrP)rbrrrOrrhr)r}rrrresulttypess rHliteral_schemaz!GenerateJsonSchema.literal_schema?skjW]^hWijjj!# x==A  &qkF7OO%F6N++(+++ SE>>%F6NN se^^&F6NN ug  %F6NN tf__&F6NN tf__$F6NN tDzzl " "#F6N rG!core_schema.MissingSentinelSchemact)zGenerates a JSON schema that matches the `MISSING` sentinel value. Args: schema: The core schema. Returns: The generated JSON schema. rrs rHmissing_sentinel_schemaz*GenerateJsonSchema.missing_sentinel_schema_s rGcore_schema.EnumSchemac0|d}|jsdntj|j}|dkrd}|j|d}d|D}d|dD}||d<d |D}t |t s |t hkrd |d <nqt |ts |thkrd |d <nJt |ts |thkrd |d <n#|thkrd|d <n|thkrd|d <|S)zGenerates a JSON schema that matches an Enum value. Args: schema: The core schema. Returns: The generated JSON schema. clsNzAn enumeration.)title descriptionci|] \}}||| SrzrFr0s rHrz2GenerateJsonSchema.enum_schema..zsCCC41aQ]!Q]]]rGc6g|]}t|jSrF)rrrqs rHrz2GenerateJsonSchema.enum_schema..|s#KKKA&qw//KKKrGmembersrtc,h|]}t|SrFrvrws rHrxz1GenerateJsonSchema.enum_schema..ryrGrNrrQrRrOrz) rEinspectcleandocrBrrrrrOrrh)r}r enum_typerr{rrr|s rH enum_schemazGenerateJsonSchema.enum_schemajsB5M "+"3\dd9I)J[9\9\ , , ,K+4+=k!Z!ZCC6<<>>CCCKK 9JKKK!v++(+++ i % % %3%%F6NN  3 ' ' %5SE>>&F6NN  5 ) ) %Uug-=-=%F6NN tf__&F6NN tf__$F6N rGcore_schema.IsInstanceSchemacB||d|ddS)aHandles 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. zcore_schema.IsInstanceSchema (rrhandle_invalid_for_json_schemars rHis_instance_schemaz%GenerateJsonSchema.is_instance_schemas-226;l\bch\i;l;l;lmmmrGcore_schema.IsSubclassSchemaciS)aIHandles 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. rFrs rHis_subclass_schemaz%GenerateJsonSchema.is_subclass_schemas  rGcore_schema.CallableSchemac.||dS)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. rrrs rHcallable_schemaz"GenerateJsonSchema.callable_schemas226;WXXXrGcore_schema.ListSchemacd|vrin||d}d|d}||||jj|S)zReturns a schema that matches a list schema. Args: schema: The core schema. Returns: The generated JSON schema. items_schemarzrrrr5r6rzr}rrrs rH list_schemazGenerateJsonSchema.list_schema],699rrt?R?RSYZhSi?j?j &>>  $$[&$:Q:WXXXrGD`tuple_positional_schema` is deprecated. Use `tuple_schema` instead.)categorycore_schema.TupleSchemacdtjdtd||S)Replaced by `tuple_schema`.r stacklevelwarningswarnr! tuple_schemars rHtuple_positional_schemaz*GenerateJsonSchema.tuple_positional_schemas<  R %      (((rGB`tuple_variable_schema` is deprecated. Use `tuple_schema` instead.cdtjdtd||S)rrrrrrs rHtuple_variable_schemaz(GenerateJsonSchema.tuple_variable_schemas<  P %      (((rGcddi}d|vry|d}|dkr$||d<fd|dd|D|d <|d zt|dkr%|d||d <nEd |d <n?fd |dD}|r||d <t||d<t||d<||jj|S)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. rrzvariadic_item_indexrminItemsc:g|]}|SrFrrs rHrz3GenerateJsonSchema.tuple_schema..s4...26D''--...rGrN prefixItemsr#rTc:g|]}|SrFrrs rHrz3GenerateJsonSchema.tuple_schema..s'XXX4..t44XXXrGmaxItems)rbrr5r6rz)r}rrrrs` rHrzGenerateJsonSchema.tuple_schemasE)/'8 F * *"()>"? "Q&&*= J'....:@:PQeReQe:f... M*#Q&#f^.D*E*EEE'+':':6.;QRe;f'g'g G$$ (, G$$XXXXAWXXXK 9-8 M*&)+&6&6K #&)+&6&6K # $$[&$:Q:WXXXrGcore_schema.SetSchemac,||S)zGenerates a JSON schema that matches a set schema. Args: schema: The core schema. Returns: The generated JSON schema. _common_set_schemars rH set_schemazGenerateJsonSchema.set_schema&&v...rGcore_schema.FrozenSetSchemac,||S)zGenerates a JSON schema that matches a frozenset schema. Args: schema: The core schema. Returns: The generated JSON schema. rrs rHfrozenset_schemaz#GenerateJsonSchema.frozenset_schemarrG3core_schema.SetSchema | core_schema.FrozenSetSchemacd|vrin||d}dd|d}||||jj|S)NrrzT)r uniqueItemsrrrs rHrz%GenerateJsonSchema._common_set_schemas]+699rrt?R?RSYZhSi?j?j &tlSS  $$[&$:Q:WXXXrGcore_schema.GeneratorSchemacd|vrin||d}d|d}||||jj|S)zReturns a JSON schema that represents the provided GeneratorSchema. Args: schema: The schema. Returns: The generated JSON schema. rrzrrrs rHgenerator_schemaz#GenerateJsonSchema.generator_schemarrGcore_schema.DictSchemacvddi}d|vr-||dni}d|vr-|dd}|ddnd}d|vr-||dni}|dd|s||||d <n ||i|d <nd |d <|dd krt |d ksd|vr|dd||d<||||jj|S)zGenerates a JSON schema that matches a dict schema. Args: schema: The core schema. Returns: The generated JSON schema. robject keys_schemarrDNr values_schemaadditionalPropertiespatternPropertiesTrNr# propertyNames)rrrr{rbr5r6r)r}rrr keys_patternrs rH dict_schemazGenerateJsonSchema.dict_schema's)/'9 KX\bKbKbd))&*?@@EEGGGhj  $ $&??9d;;L OOGT * * * * LO^bhOhOh++F?,CDDIIKKKnp '4(((  7L4#6C 2334@-3P /0026K. /__V $ $ 0 0S5E5E5I5I$$ OOFD ) ) )+6K ( $$[&$:Q:XYYYrG)core_schema.BeforeValidatorFunctionSchemac|jdkr,|dx}r||S||dS)zGenerates a JSON schema that matches a function-before schema. Args: schema: The core schema. Returns: The generated JSON schema. r8json_schema_input_schemarrr{rr}r input_schemas rHfunction_before_schemaz)GenerateJsonSchema.function_before_schemaWU 9 $ $&**E_:`:`*`, $&&|44 4""6(#3444rG(core_schema.AfterValidatorFunctionSchemac8||dS)zGenerates a JSON schema that matches a function-after schema. Args: schema: The core schema. Returns: The generated JSON schema. rrrs rHfunction_after_schemaz(GenerateJsonSchema.function_after_schemae""6(#3444rG(core_schema.PlainValidatorFunctionSchemac|jdkr,|dx}r||S||d|ddS)zGenerates a JSON schema that matches a function-plain schema. Args: schema: The core schema. Returns: The generated JSON schema. r8rz*core_schema.PlainValidatorFunctionSchema (functionr)rr{rrrs rHfunction_plain_schemaz(GenerateJsonSchema.function_plain_schemapsj 9 $ $&**E_:`:`*`, $&&|44 422 V ASVVV   rG'core_schema.WrapValidatorFunctionSchemac|jdkr,|dx}r||S||dS)zGenerates a JSON schema that matches a function-wrap schema. Args: schema: The core schema. Returns: The generated JSON schema. r8rrrrs rHfunction_wrap_schemaz'GenerateJsonSchema.function_wrap_schemarrGcore_schema.WithDefaultSchemac>||d}||}|tus |tur|S|jdkrt |d}|i|dx}rR||ddvs9 ||}n,#t$r|dd|d |cYSwxYw | |}n1#tj $r|dd |d |cYSwxYw||d <|S) zGenerates a JSON schema that matches a schema with a default value. Args: schema: The core schema. Returns: The generated JSON schema. rr9Nrrrr>zUnable to serialize value z> with the plain serializer; excluding default from JSON schemazDefault value z= is not JSON serializable; excluding default from JSON schemar) rget_default_value NoDefaultrr!_get_ser_schema_for_default_valuer{ Exception emit_warningencode_default pydantic_corePydanticSerializationError)r}rrrrser_funcencoded_defaults rHdefault_schemaz!GenerateJsonSchema.default_schemas))&*:;; ((00 i  7g#5#5  9 ' ':6(;KLLJ&!+ !;!;;X' Z^^K-H-HLo-o-o '&hw//GG ' ' '%%2~W~~~'&&& ' "11'::OO7      *gggg         "1 Is$ B$$&C  C C''+DDc8|dtS)aGet 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)r{rrs rHrz$GenerateJsonSchema.get_default_valueszz)Y///rGcore_schema.NullableSchemac~ddi}||d}||kr|S|||gS)zGenerates a JSON schema that matches a schema that allows null values. Args: schema: The core schema. Returns: The generated JSON schema. rrPr)rr)r}r null_schemainner_json_schemas rHnullable_schemaz"GenerateJsonSchema.nullable_schemasRv&  //x0@AA  + + ,,.?-MNN NrGcore_schema.UnionSchemacg}|d}|D]}t|tr|dn|} |||K#t$rYWt $r%}|d|jYd}~d}~wwxYwt|dkr|dS| |S)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. choicesrr=Nr#) rtuplerirrr.rmessagerbr)r}r generatedrchoice choice_schemaexcs rH union_schemazGenerateJsonSchema.union_schemas,. # A AF)3FE)B)BNF1IIM A  !4!4]!C!CDDDD   / A A A!!"2CK@@@@@@@@ A y>>Q  Q< ((333s(A B$ B-B  Bschemaslist[JsonSchemaValue]c|jdkrg}|D]x}|d}|nt|ts|g}t d|DsnTt |dkrn?||ydtt|iS| |S)aFReturns the JSON Schema representation for the union of the provided JSON Schemas. The result depends on the configured `'union_format'`. Args: schemas: The list of JSON Schemas to be included in the union. Returns: The JSON Schema representing the union of schemas. primitive_type_arrayrNc3(K|] }|tvVdSrz)_PRIMITIVE_JSON_SCHEMA_TYPES)rcts rHrfz:GenerateJsonSchema.get_union_of_schemas..s(SS1 <<SSSSSSrGr#) rr{rrhallrbextendrfromkeysget_flattened_anyof)r}rr|r schema_typess rHrz'GenerateJsonSchema.get_union_of_schemass   6 6 6!E! < <7=zz&7I7I 'E!,552$0>LSSlSSSSSEv;;!## E \****T]]5%9%9 : :;;''000rGcore_schema.TaggedUnionSchemac.i}|dD]\}}t|tr|j} |||t |<Z#t$rYft$r%}| d|j Yd}~d}~wwxYwt| }d|i}| ||}|$|d|Dd|d<|S)acGenerates 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. rr=NoneOfcBi|]\}}||d|S)rr{r0s rHrz:GenerateJsonSchema.tagged_union_schema..As,NNNDAqAquuVQ//NNNrG) propertyNamer discriminator)rrr rrrrrr.rrrjvalues_extract_discriminator) r}rrr1r2rone_of_choicesropenapi_discriminators rHtagged_union_schemaz&GenerateJsonSchema.tagged_union_schema!sY13 9%++-- A ADAq!T"" G A%)$7$7$:$:$?$?$A$A #a&&!!   / A A A!!"2CK@@@@@@@@ A.i.>.>.@.@AA(/'@ !% ; ;FN S S , 5NNIOO???rGcore_schema.LaxOrStrictSchemac|dd}|r||dS||dS)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)r{r)r}r use_stricts rHlax_or_strict_schemaz'GenerateJsonSchema.lax_or_strict_schemasSZZ%00   =&&vo'>?? ?&&vl';<< .s_J J J e$$U++J 4))%77 ?J J J rGfieldsr9computed_fieldsrNextra_behaviorforbidFrallow extras_schemaranyconfigextra_fields_behavior) r{rrr _name_required_computed_fields_get_typed_dict_configrpush_named_required_fields_schemar_update_class_schema)r}rnamed_required_fieldsrr@rextrar2s` @rHtyped_dict_schemaz$GenerateJsonSchema.typed_dict_schemas` 7D))J J J J J %h/5577J J J  9 ' ' ! ( ()L)LVZZXikmMnMn)o)o p p pjj',,  ' , ,V 4 4 T T<<=RSSK T T T T T T T T T T T T T T T ::& ' '8 3 327K. / / ZZ( ) )W 4 4&((VO-DQV-W-W6:6I6I&Q`Ja6b6b 2336: 23 ?  % %k3 ? ? ? ? #; 6 6JJx,,001HIIE  6; 233'!!6: 23sC''C+.C+r:list[ComputedField]1list[tuple[str, bool, core_schema.ComputedField]]cd|DS)Nc$g|] }|dd|fS) property_nameTrF)rcr8s rHrzEGenerateJsonSchema._name_required_computed_fields..s$SSS%'u5SSSrGrF)r:s rHrBz1GenerateJsonSchema._name_required_computed_fieldssTS?SSSSrGrG+Sequence[tuple[str, bool, CoreSchemaField]]ci}g}|D]\}}}|jr|||} ||}n#t$rYXwxYwd|vr/||r||}||d<||}|||<|r||d|d} |r|| d<| S)Nrrrrrequired) r_get_alias_namerrrfield_title_should_be_setget_title_from_namehandle_ref_overridesri) r}rGrrequired_fieldsr7rRr8field_json_schemarrs rHrEz0GenerateJsonSchema._named_required_fields_schemas*24 %'%: - - !D(E} 9++E488 $($7$7$>$>$C$C$E$E!!    ///D4R4RSX4Y4Y/0066-2!'* $ 9 9:K L L 0Jt  -&&t,,,'zBB  6&5K #s'A A A r8r2r7c|ddkr|d|}n8|jdkr|d|}n|d|}t|tr|}nt|trct d|}|D]O}t|tr8t |dkr%t|d tr |d }nPnt||S) Nrcomputed-fieldrr8validation_aliasserialization_aliaszlist[str] | strr#r)r{rrrrhrrbr)r}r8r7rpaths rHrSz"GenerateJsonSchema._get_alias_names =, , ,7D11EE Y, & &II0$77EEII3T::E eS ! ! DD t $ $ *E22E  dD))c$ii1nnDQRGUXAYAYn 7DE     rGcore_schema.TypedDictFieldc8||dS)zGenerates a JSON schema that matches a schema that defines a typed dict field. Args: schema: The core schema. Returns: The generated JSON schema. rrrs rHtyped_dict_field_schemaz*GenerateJsonSchema.typed_dict_field_schema rrGcore_schema.DataclassFieldc8||dS)zGenerates a JSON schema that matches a schema that defines a dataclass field. Args: schema: The core schema. Returns: The generated JSON schema. rrrs rHdataclass_field_schemaz)GenerateJsonSchema.dataclass_field_schemarrGcore_schema.ModelFieldc8||dS)zGenerates a JSON schema that matches a schema that defines a model field. Args: schema: The core schema. Returns: The generated JSON schema. rrrs rHmodel_field_schemaz%GenerateJsonSchema.model_field_schemarrGcore_schema.ComputedFieldc8||dS)zGenerates a JSON schema that matches a schema that defines a computed field. Args: schema: The core schema. Returns: The generated JSON schema. return_schemarrs rHcomputed_field_schemaz(GenerateJsonSchema.computed_field_schema*s""6/#:;;;rGcore_schema.ModelSchemactd|d}|j}|j|5||d}dddn #1swxYwY|||||S)zGenerates a JSON schema that matches a schema that defines a model. Args: schema: The core schema. Returns: The generated JSON schema. ztype[BaseModel]rrN)r model_configrrDrrF)r}rrr@rs rH model_schemazGenerateJsonSchema.model_schema5s$fUm44!  ' , ,V 4 4 @ @--fX.>??K @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ !!+sF;;;sA  A$'A$rr type[Any]r@r1c.ddlm}ddlm}|dx}|d|ng|dx}rP||}t |tstd|d|j |d|d|vr |j |d<||ustj |rdn|j } | r)|d tj| n:t!||r*|jd jx} r|d | |d } d |vr| d krd|d <n | dkrd|d <|d} t!||r0|jr)|jd j} | r| rt-d| r| } t | t.t0fr| |} t | t4r|| ngt9| rCt;tj| jdkr | ||n!| |n| t-d| dtA|drd|d<dSdS)aUpdate 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#r6) RootModelrNmodel_title_generatorzmodel_title_generator z must return str, not rrootrHrr=Tr<Fjson_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)!mainr7 root_modelrqr{ setdefaultrrr __class__rB dataclasses is_dataclassrErr issubclass__pydantic_fields__r__pydantic_root_model__ model_fieldsrt ValueErrorr classmethod__get__rrrrb signature parametershasattr)r}rrr@r7rq config_titlerrr docstringroot_descriptionrHrtroot_json_schema_extras rHrFz'GenerateJsonSchema._update_class_schemaJsM $#####))))))"JJw// /L <  " "7L 9 9 9 9&,jj1H&I&I I " 3))#..EeS)) y w9N w wfkfu w wxxx  " "7E 2 2 2 + % %#& >  ' . .    0 1 1 1 1 ' ( ( 7$%677BCCaGG!!+s3333!!+....  *l5Flll  3( ) ) -(,K % % % - -rGcd|vrD|d}|t|}|td||}d|vD|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. rNz(Cannot update undefined schema for $ref=)rrKr)r}rrxschema_to_updates rHrz%GenerateJsonSchema.resolve_ref_schemasj ##f%C#?? MM '"#Sc#S#STTT*K  ## rGcore_schema.ModelFieldsSchemacfd|dD}jdkr<||dg|}|dd}|-|}||d<|S)zGenerates a JSON schema that matches a schema that defines a model's fields. Args: schema: The core schema. Returns: The generated JSON schema. ctg|]4\}}|||d|f5S)Tr2r4)rcr7r8r}s rHrz:GenerateJsonSchema.model_fields_schema..sbJ J J e$$U++J 4))%t)<Nr)rrr rBr{rErr)r}rrGrr>rs` rHmodel_fields_schemaz&GenerateJsonSchema.model_fields_schemasJ J J J %h/5577J J J  9 ' ' ! ( ()L)LVZZXikmMnMn)o)o p p p889NOO  ?D99  $#66{CC 7;7J7J=7Y7Y 3 4rGc|jdkr|d S|jdkrdSt|jdS)aWhether 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. r9serialization_excluder8TN)rr{r)r}r8s rHr5z#GenerateJsonSchema.field_is_presentsQ 9 ' 'yy!8999 9 Y, & &4  # # # # #rGPcore_schema.ModelField | core_schema.DataclassField | core_schema.TypedDictFieldr2c|ddkr|d|}n|dddk}|jdkr+|ddu}|jjr| S|o| S|S) aYWhether 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. rztyped-dict-fieldrRrrr9serialization_exclude_ifN)r{rr$+json_schema_serialization_defaults_required)r}r8r2rRhas_exclude_ifs rHr6z$GenerateJsonSchema.field_is_requireds" =. . .yyU33HHXv.);H 9 ' '"YY'ABB$NN|G 7)))6$66OrGcore_schema.DataclassArgsSchemacfd|dD}jdkr<||dg|S)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. czg|]7}||d|d|f8S)r7Trr4)rcr8r}s rHrz.sbJ J J $$U++J 6]D2252EEu MJ J J rGr9r9r:)rr rBr{rE)r}rrGs` rHdataclass_args_schemaz(GenerateJsonSchema.dataclass_args_schemasJ J J J )J J J  9 ' ' ! ( ()L)LVZZXikmMnMn)o)o p p p112GHHHrGcore_schema.DataclassSchemacddlm}|d}t|dtdi}|j|5||d}dddn #1swxYwY||||||rd}n"|j dntj |j }|r||d<|S) zGenerates a JSON schema that matches a schema that defines a dataclass. Args: schema: The core schema. Returns: The generated JSON schema. r#)is_stdlib_dataclassr__pydantic_config__r1rNr) _internal._dataclassesrrrrrDrrrFrErr)r}rrrr@rrs rHdataclass_schemaz#GenerateJsonSchema.dataclass_schemasJ @?????Um$S*?lTVAWAWXX  ' , ,V 4 4 G G--fX.>??DDFFK G G G G G G G G G G G G G G G !!+sF;;;  s # # YKK"%+"5$$7;KCK;X;XK  5)4K &s.BB Bcore_schema.ArgumentsSchemac|did}|d}d|D}d|D}d|D}|d}|d}|r!| o| } | r|||z|S| o| } | r|||z|S|s!| o| } | r|||z|Std ) 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_argumentsarguments_schemacDg|]}|ddk|S)r keyword_onlyrrcas rHrz7GenerateJsonSchema.arguments_schema..)s,UUU1QUU6]]n5T5TQ5T5T5TrGc@g|]}|ddv|S)r>Npositional_or_keywordrrs rHrz7GenerateJsonSchema.arguments_schema..*s-fff1QUU6]]Fe5e5eQ5e5e5erGcDg|]}|ddk|S)rpositional_onlyrrs rHrz7GenerateJsonSchema.arguments_schema..+s-WWW!AEE&MMEV4V4VA4V4V4VrGvar_args_schemavar_kwargs_schemazfUnable to generate JSON schema for arguments validator with positional-only and keyword-only arguments)r{p_arguments_schemakw_arguments_schemar.) r}rprefer_positional argumentskw_only_argumentskw_or_p_argumentsp_only_argumentsrrpositional_possiblekeyword_possibles rHrz#GenerateJsonSchema.arguments_schemasd#JJz266::;dee-. UU UUUff fffWWyWWW **%677"JJ':;;  f&7"7"Q@Q+>?P+Q+Q (+ S6R 2327K. /rGrcg}d}|D]}||}||d}d|vr3||dr|||d<|||dddkr|dz }ddi}|r||d<|r||d <|r||} | r| |d <nt ||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. rrrrrr#rzrrrr)rrrrTrUrirb) r}rr prefix_items min_itemsrr7rrrs rHrz%GenerateJsonSchema.p_arguments_schemags:/1  !  H))(33D"11(82DEEJJLLOo--$2P2PQYZbQc2d2d-+/+C+CD+I+I(    0 0 0!&)Y66Q (.'8  6)5K &  0&/K #  8..??L 4'3 G$&),&7&7K #rGrAcore_schema.ArgumentsParameter | core_schema.ArgumentsV3Parameterc|d}|jr.|d}t|tr|}n |S)zRetrieves the name of an argument. Args: argument: The core schema. Returns: The name of the argument. r7r)rr{rr)r}rr7rs rHrz$GenerateJsonSchema.get_argument_namesJ = LL))E%%%  rGcore_schema.ArgumentsV3Schemac|d}i}g}|D]}|dd}||}||d}|dkrd|d}n |dkrd |d }|d |||||<|d krd |vs|dvr'|dddkr||d |d} |r|| d <| S)rrrrrvar_argsrzrvar_kwargs_uniformr)rrrvar_kwargs_unpacked_typed_dictrR>rrrrrrQ)r{rrrrxrUri) r}rrrrRrrr7rrs rHarguments_v3_schemaz&GenerateJsonSchema.arguments_v3_schemasG-. 13  ! & &H<<(?@@D))(33D"11(82DEEJJLLOz!!+2_"M"M---+3_"]"]  & &w0H0H0N0N O O O.Jt 999jO>[>[cccX&v.);; %%%08 'S'S  /&.K #rGcore_schema.CallSchemac8||dS)zGenerates a JSON schema that matches a schema that defines a function call. Args: schema: The core schema. Returns: The generated JSON schema. rrrs rH call_schemazGenerateJsonSchema.call_schemas""6*<#=>>>rGcore_schema.CustomErrorSchemac8||dS)zGenerates a JSON schema that matches a schema that defines a custom error. Args: schema: The core schema. Returns: The generated JSON schema. rrrs rHcustom_error_schemaz&GenerateJsonSchema.custom_error_schemarrGcore_schema.JsonSchemac|dptj}||}|jdkrdd|dS|S)zGenerates a JSON schema that matches a schema that defines a JSON object. Args: schema: The core schema. Returns: The generated JSON schema. rr8rNzapplication/json)rcontentMediaType contentSchema)r{rr#rr)r}rcontent_core_schemacontent_json_schemas rHrzGenerateJsonSchema.json_schemas`%jj22Nk6L6N6N"112EFF 9 $ $$:L_rss s' &rGcore_schema.UrlSchemacTdddd}||||jj|S)zGenerates a JSON schema that matches a schema that defines a URL. Args: schema: The core schema. Returns: The generated JSON schema. rNurir#rrY minLengthr5r6rNr8s rH url_schemazGenerateJsonSchema.url_schemas7 (5qII  $$[&$:Q:XYYYrGcore_schema.MultiHostUrlSchemacTdddd}||||jj|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. rNzmulti-host-urir#rrr8s rHmulti_host_url_schemaz(GenerateJsonSchema.multi_host_url_schemas9 (3CRSTT  $$[&$:Q:XYYYrGcore_schema.UuidSchemac dddS)zGenerates a JSON schema that matches a UUID. Args: schema: The core schema. Returns: The generated JSON schema. rNuuidrXrFrs rH uuid_schemazGenerateJsonSchema.uuid_schema rarGcore_schema.DefinitionsSchemac|dD]h} ||#t$rC}t|d}||j|||jf<Yd}~ad}~wwxYw||dS)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. r[rxNr)rr.rIr get_defs_refr)r}r definitionrrs rHrnz%GenerateJsonSchema.definitions_schemas!/  J ##J/////   $+Ju,=$>$>de78I8I8UYU^J_8`8`a ""6(#3444s" A/9A**A/%core_schema.DefinitionReferenceSchemac`t|d}||\}}|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)rIr)r}rrrrs rHdefinition_ref_schemaz(GenerateJsonSchema.definition_ref_schema*s46,/00!;;HEE?rGVcore_schema.SerSchema | core_schema.IncExSeqSerSchema | core_schema.IncExDictSerSchemaJsonSchemaValue | Nonec:|d}|dks|dkr-|d}|||SnY|dks|dkr&|tjS|ddkr||d SdS) zGenerates a JSON schema that matches a schema that defines a serialized object. Args: schema: The core schema. Returns: The generated JSON schema. rfunction-plainz function-wrapriNrYz to-stringmodelr)r{rrNr)r}r schema_typeris rHrzGenerateJsonSchema.ser_schema7sVn * * *k_.L.L"JJ77M(**=999) H $ $ {(B(B??;#9#;#;<< < F^w & &&&vh'788 8trGcore_schema.ComplexSchemac ddiS)aGenerates 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. rrNrFrs rHcomplex_schemaz!GenerateJsonSchema.complex_schemaPs!!rGcv|ddS)zRetrieves a title from a name. Args: name: The name to retrieve a title from. Returns: The title. r )rrstripr}r7s rHrUz&GenerateJsonSchema.get_title_from_namebs.zz||##C--33555rGctj|r2|ddkr |d}n|d}||Stj|r{|drdS|ddvr||dStj|r||dS|ddkrdSd St d |) aReturns 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. rrZrirrxF>rrr[zdefinition-refTr)r&rrTrr{is_function_with_inner_schemar.)r}r field_schemas rHrTz,GenerateJsonSchema.field_title_should_be_setms   +F 3 3 [f~!111%o6 %h/ 11,?? ?  ' / / [zz%   uf~!GGG55fX6FGGG8@@ H55fX6FGGGf~!111u4//YQW/Y/YZZ ZrGcVtjdd|ddS)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.\-_]rr__)resubrrs rHnormalize_namez!GenerateJsonSchema.normalize_names)v)355==c4HHHrGr  CoreModeRefrJc|\}}tjd|}d|D}d|}d|D}d|}t|}t ||}t ||d|z} t ||} t | d|} t ||} |j| } | ,|j| xxdz cc<|j| x} |j| <t | d| }t | d| }|| | | ||g|j |<|S) 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([\][,])cFg|]}|dddS):r#r)rsplitrcrds rHrz3GenerateJsonSchema.get_defs_ref..s+>>>aahhsA&&q)>>>rGc:g|]}tjdd|S)z(?:[^.[\]]+\.)+((?:[^.[\]]+))z\1)rrrs rHrz3GenerateJsonSchema.get_defs_ref..s']]]Qbf=uaHH]]]rGrNr#r) rsplitjoinr<rJrrr{rr)r}r rr componentscore_ref_no_id short_ref mode_titler7 name_modemodule_qualnamemodule_qualname_modemodule_qualname_idoccurrence_indexmodule_qualname_occurrencemodule_qualname_occurrence_modes rHrzGenerateJsonSchema.get_defs_refs'$Xk844 >>:>>> ,,]]R\]]] GGJ'' (. t**95566D// ::=M=M=MMNN !$"5"5n"E"EFF&/'H'HJ'H'HII$T%8%8%B%BCC0445GHH  #  #O 4 4 4 9 4 4 4KOKbcrKs s t45GH%,-U-UCS-U-U%V%V"*15I2_2_M]2_2_*`*`'    & + N )*IJ/.rGrrItuple[DefsRef, JsonSchemaValue]cL||jf}|j|}||j|}|d|ifS||}||j|<||j|<t |j|}||j|<||j |<d|i}||fS)aThis 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. Nrr) rrr{rrrrKrrYr)r}rr maybe_defs_refrrprs rHrz,GenerateJsonSchema.get_cache_defs_ref_schemas"49- /33MBB  %-mGenerateJsonSchema.get_json_ref_counts.._add_json_refsi s&$'' &V##&vf~66H%h44&.)&;Oh'''1,'''&"#'#9(#C#t'NNN"&"I("SS&t'7'ABBBB#"""'223JKK"!"""#LLNN&&DAqJ:a+>+>!"N1%%%% && FD)) &&&A"N1%%%% & &&&s 9B B=<B=)rrr]r)r)r}rrCrDs` @@rHrz&GenerateJsonSchema.get_json_ref_countse sN(/  & & & & & & & &: {###rG error_infoc&td|)Nz!Cannot generate a JsonSchema for )r.)r}rrEs rHrz1GenerateJsonSchema.handle_invalid_for_json_schema s*+[z+[+[\\\rGkindJsonSchemaWarningKinddetailcn|||}|tj|tdSdS)zfThis method simply emits PydanticJsonSchemaWarnings based on handling in the `warning_message` method.N)render_warning_messagerrrA)r}rGrIrs rHrzGenerateJsonSchema.emit_warning s>--dF;;   M'#< = = = = =  rGc(||jvrdS|d|dS)amThis 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)r}rGrIs rHrKz)GenerateJsonSchema.render_warning_message s." 4- - -4##D####rGrTci}|jD]4}|D]/}t|j|}|||<05t |j||jS)Nr)rrrKrrYrTrwr[)r}rY defs_refsrprs rHrz/GenerateJsonSchema._build_definitions_remapping s/1 :AACC 2 2I% 2 2"4#4#;#;(#;#K#KLL)1 X&& 2%==  -|T=M   rGctt|}|r|} |j|}|vr)||t|j|n&#t$r|dsYnwxYw|fd|j D|_dS)Nrc$i|] \}}|v || SrFrF)rcr1r2visited_defs_refss rHrzCGenerateJsonSchema._garbage_collect_definitions.. s*```TQN_I_I_AqI_I_I_rG) set_get_all_json_refsrraddrr[r r!r)r}runvisited_json_refs next_json_ref next_defs_refrRs @rHrz/GenerateJsonSchema._garbage_collect_definitions s*-%%088! /3355M  $ 6} E  $555!%%m444#**+=d>N}>]+^+^____   $//0GHH " a```T-=-C-C-E-E```sB AB B.-B.)rrrrrrr]r)r]r)r]r)r]r)rrr]r)r8)rrrrr]r)rr3r]rrz)rrrrr]r)rrrrr]r)rrr]r)rr!r]r)rr$r]r)rr'r]r)rr*r]r)rr:r]r)rr>r]r)rrQr]r)rrSr]r)rr]r]r)rrbr]r)rrfr]r)rrir]r)rrnr]r)rr~r]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrrrr]r)rr r]r)rr&r]r)rr-r]r)rr0r]r)r:rJr]rK)rGrOr]r)r8r2r7rr]r)rr^r]r)rrar]r)rrdr]r)rrgr]r)rrkr]r)rrrror@r1r]r)rrr]r)rrr]r)r8r2r]r)r8rr2rr]r)rrr]r)rrr]r)rrr]r)rrrrr]r)rrrrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)rrr]r)r7rr]r)rr3r]r)r rr]rJ)rrIr]r)rrKr]r)r#rr]r)rrrrrr-r]r)rrr]r>)rr3rErr]r)rGrHrIrr]r)rGrHrIrr]r)r]rT)rrr]r)orBrCrDrEschema_dialectrrDEFAULT_REF_TEMPLATErpropertyr$rrrrrrrr r#r&r)r9r=rPrNr\r`rerhrmr}rrrrrrrrrrrrrrrrrrrrrrrrrrrr%r,r/rIrrBrErSr`rcrfrjrnrFrrr5r6rrrrrrrrrrrrrrnrrrrUrTrrrrVrrr5r6r rrrrKrrrFrGrHrrs''RDN:J8JJJJJ0BJ (((((T///X/X 4/A/A/A/Ab/&/&/&/&/&bJJJJX     $jjjj          # # # #        IIIIV     4 4 4 4 4 4 4 4 9 9 9 9 8 8 8 8@    """"H n n n n     Y Y Y Y    ZVaefff ))) Ugf)ZT_cddd ))) Ued)!!!!F / / / / / / / /    ....` 5 5 5 5 5 5 5 5    5 5 5 54444l 0 0 0 0OOOO"44442"1"1"1"1H####J+%+%+%+%Z @ @ @ @====& : : : :////bTTT\T 2* 5 5 5 5 5 5 5 5 5 5 5 5 < < < <*E-E-E-E-N(.$$$$$>IIII$<" " " " H$$$$L))))V$%%%%N ? ? ? ? 5 5 5 5''''"         4 4 4 45555$    2""""$ 6 6 6 6![![![![F I I I I././././`))))86        : E E E E        @ " " " """""H]]]]>>>> $$$$*     aaaaaarGrTrr8r)type[BaseModel] | type[PydanticDataclass]rrrrrrschema_generatortype[GenerateJsonSchema]rrr]dict[str, Any]cJddlm}||||}t|jtjr|j||urtdt|jtjr Jd||j|S)aUtility 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. union_format: The format to use when combining schemas from unions together. Can be one of: - `'any_of'`: Use the [`anyOf`](https://json-schema.org/understanding-json-schema/reference/combining#anyOf) keyword to combine schemas (the default). - `'primitive_type_array'`: Use the [`type`](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (`string`, `boolean`, `null`, `integer` or `number`) or contains constraints/metadata, falls back to `any_of`. 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#r6rrrzTmodel_json_schema() must be called on a subclass of BaseModel, not BaseModel itself.zthis is a bug! please report it)r) rvr7r__pydantic_core_schema__r)MockCoreSchemarebuildrr)rrrrr]rr7schema_generator_instances rHmodel_json_schemarf s@  0 0 <!!!#. 0LMM/ $,,... isttt#6 8TUUxxWxxx U $ - -c.JQU - V VVrG)rrrrrr]modelsJSequence[tuple[type[BaseModel] | type[PydanticDataclass], JsonSchemaMode]]rrrotuple[dict[tuple[type[BaseModel] | type[PydanticDataclass], JsonSchemaMode], JsonSchemaValue], JsonSchemaValue]c|D]=\}}t|jtjr|j>||||} d|D} | | \} } i} | r| | d<|r|| d<|r|| d<| | fS)aUtility 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. union_format: The format to use when combining schemas from unions together. Can be one of: - `'any_of'`: Use the [`anyOf`](https://json-schema.org/understanding-json-schema/reference/combining#anyOf) keyword to combine schemas (the default). - `'primitive_type_array'`: Use the [`type`](https://json-schema.org/understanding-json-schema/reference/type) keyword as an array of strings, containing each type of the combination. If any of the schemas is not a primitive type (`string`, `boolean`, `null`, `integer` or `number`) or contains constraints/metadata, falls back to `any_of`. 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. rac(g|]\}}|||jfSrF)rb)rcmrs rHrz&models_json_schema.. s9bbb29!TD!,-bbbrGr_rr)rrbr)rcrdr)rgrrrrrr]rrinstancerrr[rs rHmodels_json_schemarn sH33Q c2M4P Q Q 3  ( 0 0 2 2 2 [ghhhHbb=CbbbF%-$A$A&$I$I!k"$K+* G %$ G1%0 M" [ ((rG)_HashableJsonValue.ro.rrIterable[JsonDict]rcXtd|DS)Nc.i|]}t||SrF_make_json_hashable)rcrs rHrz(_deduplicate_schemas..9 s#KKK$V,,fKKKrG)rhr)rs rHrjrj8 s+ KK7KKKRRTT U UUrGrr-ct|tr8ttd|DSt|t rtd|DS|S)Nc3>K|]\}}|t|fVdSrzrsr0s rHrfz&_make_json_hashable..> s4RRDAqQ 3A 6 67RRRRRRrGc34K|]}t|VdSrzrsrqs rHrfz&_make_json_hashable..@ s+;;(++;;;;;;rG)rrrrrrh)rs rHrtrt< su%VRREKKMMRRRRRSSS E4 ;;U;;;;;; rGc<eZdZUdZded<dZded<dd ZddZdS)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. rrN-Literal['validation', 'serialization'] | Nonerrcore_schema.CoreSchemahandlerr+r]rc|jp|j}||jkr ||S|jt|jSrz)rrrr)r}rr|rs rH__get_pydantic_json_schema__z+WithJsonSchema.__get_pydantic_json_schema__X sSy(GL 7<  7;'' '   # #((** *rGrcDtt|jSrzhashrrrs rH__hash__zWithJsonSchema.__hash__d DOO$$$rGrr{r|r+r]rr]r)rBrCrDrErrr~rrFrGrHryryE sg  (''':>D>>>> + + + +%%%%%%rGryceZdZdZeed ddd Zeddd Z dddZddZddZdS)ExamplesaAdd 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.NrAr_rrzr]rcdSrzrFr}rArs rHrzExamples.__init__r s srG list[Any]cdSrzrFrs rHrzExamples.__init__x sqtqtrGdict[str, Any] | list[Any]ct|trtjdtd||_||_dS)Nz>Using a dict for `examples` is deprecated, use a list instead.rr)rrrrr"rArrs rHrzExamples.__init__{ sL h % %  MP)     !  rGrr{r|r+rcL|jp|j}||}||jkr|S|d}|t|j|d<t |t rt |jt rQtjdttd| D|jz|d<nti||j|d<t |t rt |jt rt||jz|d<njt |jt rPtjdtt|d|j Dz|d<|S)NrAzUpdating 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.cg|] }|D]}| SrFrFrcrexs rHrz9Examples.__get_pydantic_json_schema__.. s%GGGEGG2RGGGGrGzUpdating 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.cg|] }|D]}| SrFrFrs rHrz9Examples.__get_pydantic_json_schema__.. s&WWWuQVWW2WWWWrG) rr{rrArrrhrr UserWarningr)r}rr|rrrAs rHr~z%Examples.__get_pydantic_json_schema__ sy(GLgk** 7<   ??:..  &8&G&GK # h % % \$-.. \ J  +=GGX__%6%6GGG$-W++ J''+==Z=ZDM=Z*[*[ J' h % % $-.. *rs   322222 ,,,,,,,,8888888888                        \\\\\\\\\\\\\\333333HHHHHHHHHHHH>>>>>>RRRRRRRR544444''''''''bbbbbbbbbb IIIIIIII999999JJJJJJ :K<[ [\ sCx.67AHZb1c1ccccc ef  FHH  )A ')S ! ! ')S ! ! ')S ! !G^+, ):::Q88,788MMMMMMM98M`g#ag#ag#ag#ag#ag#ag#ag#a^G,>F1C' -W-W-W-W-Wf",>F1C6)6)6)6)6)6)x!&T4'@!A5sThOhIiknInCoo! VVVV88,788%%%%%%%98%DG%G%G%G%G%G%G%G%T8 ')  >$w|,NN[<<0;<<9$9$9$9$9$9$9$=<9$x C C C C C CrG