fL 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%je%jfZQ eReSefZT edZU dddZVdeWd<edZX Gdd eYZZe[Z\ d!Z] ed"eSZ^ed#eSZ_ed$eSZ`eae^eUfZbed%e&Zcd'ZdejdBie8jGd(d)ZgGd*d+Zhd,e]d-ehd.f dCd/Zid,dde]d-ehd0 dDd1ZjeekeleSemdead2eaeaeSd3fd4ffZnd5eWd3<dEd6ZodFd7ZpejdBie8jGd8d9ZqGd:d;ZrdGd<Zsed=Ztereetd4fZun)ejdBie8jGd>d?ZudHd@ZvdIdAZwy)Ja!!! 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-discriminatorceZdZdZy)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__Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/pydantic/json_schema.pyrArAesrGrAz#/$defs/{model}CoreRefDefsRefJsonRefJsonSchemaKeyT)bound)stringbooleannullintegernumberc\eZdZUded<ded<e d dZd dZd dZd dZy )_DefinitionsRemappingzdict[DefsRef, DefsRef]defs_remappingzdict[JsonRef, JsonRef]json_remappingct|}d|i}tdD]}tt|D]%}||}|D]}|j ||'D]}t ||<i} i} |D]+} || }t fd|D} | | | <|| | || <-t| | } | jd|i}||k(r| cS|}td)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. $defsdc3FK|]}t|dk(s|yw)r#N)len).0xschemas_for_alternativess rH zA_DefinitionsRemapping.from_prioritized_choices..s%(jqCH`abHcDdhiDi(js!!z.Failed to simplify the JSON schema definitions) r rangerlistappend_deduplicate_schemasnextrTremap_json_schemar.)prioritized_choices defs_to_json definitionscopied_definitionsdefinitions_schema_iterdefs_ref alternatives alternativerUrVoriginal_defs_refremapped_defs_ref remappingnew_definitions_schemar^s @rHfrom_prioritized_choicesz._DefinitionsRemapping.from_prioritized_choicessN&k2%'9:3Z 8EMXY]M^ $. _28< #/_K,[9@@AST\A]^_ _5 n5IJbckJl5m(2 n68N57N%0 b!23DE $((jL(j$j!4E01BNO`Ba|,=>?  b .nnMI%.%@%@'K]A^%_ "!%;;  !7 7 8:++[\\rGc:|jj||SN)rUgetselfrefs rHremap_defs_refz$_DefinitionsRemapping.remap_defs_ref""&&sC00rGc:|jj||Sru)rVrvrws rHremap_json_refz$_DefinitionsRemapping.remap_json_refr{rGc Zt|tr|jt|St|tr|Dcgc]}|j |c}St|t r|jD]\}}|dk(r.t|tr|jt||d<9|dk(rR|djDcic]/\}}|jt||j |1c}}|d<|j |||<|Scc}wcc}}w)zH Recursively update the JSON schema replacing all $refs $refrX) isinstancestrr}rKraredictitemsrzrJ)rxschemaitemkeyvalues rHrez'_DefinitionsRemapping.remap_json_schemas fc "&&wv7 7  %=CDTD**40D D  %$lln @ U&=Zs%;%)%8%8%HF6NG^+1/*?*?*A'&C++GCL94;Q;QRW;XX'F7O #'"8"8"?F3K @ E 's D"4D'N)rfzdict[DefsRef, list[DefsRef]]rgzdict[DefsRef, JsonRef]rhzdict[DefsRef, JsonSchemaValue]returnrT)ryrJrrJ)ryrKrrK)rrrr) rBrCrD__annotations__ staticmethodrsrzr}rerFrGrHrTrTsZ****,]9,],,]4,]  ,],]\11rGrTc0eZdZUdZdZdhZded<dedf dpdZe dqd Z e drd Z dsd Z dtd Z dudvd ZdwdZdxdydZdxdzdZd{dZd|dZd}dZd~dZddZddZddZddZddZddZddZddZddZddZdd 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.dd0Z/dd1Z0dd2Z1dd3Z2dd4Z3dd5Z4dd6Z5dd7Z6dd8Z7dd9Z8dd:Z9 dd;Z:dd<Z;dd=Z
Z=dd?Z>e? dd@Z@ ddAZAddBZBddCZCddDZDddEZEddFZFddGZGddHZHddIZIddJZJddKZK ddLZLddMZMddNZNddOZO ddPZP ddQZQddRZRddSZSddTZTddUZUddVZVddWZWddXZXddYZYddZZZdd[Z[ dd\Z\dd]Z]dd^Z^dd_Z_dd`Z`ddaZaddbZbddcZcdddZdddeZe ddfZfGdgdhZgddiZhddjZiddkZjddlZkddmZlddnZmddoZny)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. 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_ofcf||_||_||_i|_i|_i|_i|_i|_tjtji|_ d|_ i|_ tt|_i|_|j%|_i|_d|_y)Nr8F)by_alias ref_template union_formatcore_to_json_refscore_to_defs_refsdefs_to_core_refsjson_to_defs_refsrhr$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)rxrrrs rH__init__zGenerateJsonSchema.__init__ s ! (GS=?=?=?9;;=%,%?%?@U@UVX@Y%Z"%1 KM)2=c2B02&*&F&F&H#`b/ rGc.|jjSru)rtailrxs rHr$zGenerateJsonSchema._config4s))...rGcr|jj|jjS|jSru)r$json_schema_mode_overriderrs rHmodezGenerateJsonSchema.mode8s, << 1 1 =<<99 9:: rGc :i}ttt}|D]'}|jddd} t ||||<)|S#t $rH}t jdrYd}~Otd|dt|jd|d |d}~wwxYw) 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: .)) rar CoreSchemaOrFieldTypereplacegetattrAttributeErrorosgetenv TypeErrortyperB)rxmappingcore_schema_typesr method_namees rHrz.GenerateJsonSchema.build_schema_type_to_method?s`b9=>PQf>g9h$ C [[c237;K &t[9  " 99LMOPSwW""&t*"5"5!6a }AG sA  BB,)BBc|jr$tdt|jdd|D]\}}}||_|j | |j }i}|D]4\}}}||_|j |}|j||||f<6d|ji}|j|}d|_||j|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-usedcoderXT) rr0rrBrgenerate_inner_build_definitions_remappingrerhsort) rxinputsrrrdefinitions_remappingjson_schemas_mapr json_schemas rHgenerate_definitionsz'GenerateJsonSchema.generate_definitionsYs2 ::#559$Z5H5H4IIhj/  & (OAtVDJ    ' (!% A A CQS!' a CvDJ--f5K,A,S,ST_,` c4[ ) a  0 01 +==kJ  ;w+?!@@@rGc||_|jr$tdt|jdd|j |}|j |}tt|jd}|j|j|}||dk(rL|Jt|dk(r<|j}||xxdzcc<tt|jd}d}|j|j||j}|jr|j|d<|j!|}d |_|j#|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#rXT)rrr0rrBrget_json_ref_countsrrKrvget_schema_from_definitionsr[copy_garbage_collect_definitionsrrhrer)rxrrrjson_ref_countsryref_json_schemars rHgeneratezGenerateJsonSchema.generatesK ::#559$Z5H5H4IIhj/  (,':':6'B 22;?7KOOF34o">>sCOs#q(_-HSQ\M]abMb-224 $)$7KOOF$;<Co ))+6 $ A A C   #'#3#3K +==kJ  yy%%rGcn d|vrVt|d}|jf}|jvr,j|jvrdj|iSdfd dfd }t j |}ttj|jdi}|jdx r#|f d fd }t j |}|jdx r#|f d fd }t j |}|jd d D](} || f dfd } t j | }*|jd d D]&} || f dd} 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. ryrcd|vrrt|d}j|\}}t|d}|jdd|k7r+|j|<j j |d|}|S)Nryr)rIget_cache_defs_ref_schemarKrvrhrpop)rrcore_refrlrjson_refrxs rH populate_defsz8GenerateJsonSchema.generate_inner..populate_defss #";u#56,0,J,J8,T)/"?6#:;??640H<1.handler_funcs37KyyO+?0R-_= "ooj9  +"{37ZZ'/:="&";";ff=M{<["\K"--o>+BbBbcrBs/3/J/J?[aKb/c,":?"KK $&EoEV$WXX rGmetadatapydantic_js_updatesc i||}|SrurF)rcurrent_handlerr js_updatess rHjs_updates_handler_funczBGenerateJsonSchema.generate_inner..js_updates_handler_func s Q!APZP ""rGpydantic_js_extrac||}ttr|jt|St r||Sru)rrupdatercallable)rrrjs_extras rHjs_extra_handler_funcz@GenerateJsonSchema.generate_inner..js_extra_handler_funcsM.o> h-&&'9('CD#"h'[)""rGpydantic_js_functionsrFc|||}tj|r ||}|j|}|jdd}|r|r|j ||S)Nr)r&rresolve_ref_schemarr)rrjs_modify_functionroriginal_schemaryrs rHnew_handler_funcz;GenerateJsonSchema.generate_inner..new_handler_func'sd 1/R --o>"/"MK"1"D"D["Q!oofd3;#**;7&&rG pydantic_js_annotation_functionsc|||SrurF)rrrs rHrz;GenerateJsonSchema.generate_inner..new_handler_func9s */?KKrG)rrrJsonSchemaValuerr)rr3rr)rr3rr+rr)rr3rr+rr5rr) rIrrrhrr*GenerateJsonSchemaHandlerrr% CoreMetadatarvr&r)rxrr core_mode_refrrrrrrrrrrrs` @@@rHrz!GenerateJsonSchema.generate_innersE F?ve}-H%tyy1M 6 664;Q;QR_;`dhdtdt;t 6 6} EFF # J4MMdT`a33VZZ B5OP"&;< <: <9H #!2 #!5 #! #8QQRVXopO||$78 88 89H #!2 #!5 #! #8QQRVXmnO"*,,/F"K j 9HGenerateJsonSchema.decimal_schema..get_decimal_patterns L1J#ZZ(89N(  %.*D!$Q ^(C!D,-.$$.N#34,-Z7GH 8N%'N,B(\*$$.N#34"N#(Bl>*:%@@ N=(NrG)r'r8 multiple_oflegeltgtanyOf allow_inf_nanN)r0r*r+r,r-r.)rcore_schema.DecimalSchemarr) str_schemarrrvr!float) rxrr)rr*r+r,r-r.s rHdecimal_schemaz!GenerateJsonSchema.decimal_schemas' Rook&<&%F6N se^&F6N ug %F6N tf_&F6N  tf_$F6N tDzl "#F6N +k,s .CCct)zGenerates a JSON schema that matches the `MISSING` sentinel value. Args: schema: The core schema. Returns: The generated JSON schema. rr s rHmissing_sentinel_schemaz*GenerateJsonSchema.missing_sentinel_schema_s rGc|d}|jsdntj|j}|dk(rd}|j|d}|j Dcic] \}}| || }}}|dDcgc]}t |j }}||d<|Dchc] }t|} }t|ts | thk(rd|d<|St|ts | thk(rd |d<|St|ts | thk(rd |d<|S| thk(rd |d<|S| thk(rd |d<|Scc}}wcc}wcc}w) zGenerates a JSON schema that matches an Enum value. Args: schema: The core schema. Returns: The generated JSON schema. clsNzAn enumeration.)title descriptionmembersrPrNrrQrRrOrQ)rEinspectcleandocrBrrrrrrrr3rRra) rxr enum_typer\rSrrrNrrTs rH enum_schemazGenerateJsonSchema.enum_schemajs_5M "+"3"3d9I9I)J[J[9\ , ,K+4+=+=k!Z#)<<>C41aQ]!Q$CC9? 9JKA&qww/KK!v"*+Qa++ i %3%%F6N  3 '5SE>&F6N  5 )Uug-=%F6N  tf_&F6N tf_$F6N %DK,s D6'D66D<Ec4|j|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 (rZrhandle_invalid_for_json_schemar s rHis_instance_schemaz%GenerateJsonSchema.is_instance_schemas*226=[\bch\i[jjk;lmmrGciS)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. rFr s rHis_subclass_schemaz%GenerateJsonSchema.is_subclass_schemas  rGc&|j|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. core_schema.CallableSchemarcr s rHcallable_schemaz"GenerateJsonSchema.callable_schemas226;WXXrGcd|vrin|j|d}d|d}|j|||jj|S)zReturns a schema that matches a list schema. Args: schema: The core schema. Returns: The generated JSON schema. items_schemarQrrrrrrQrxrrlrs rH list_schemazGenerateJsonSchema.list_schemaR,69rt?R?RSYZhSi?j &>  $$[&$:Q:Q:W:WXrGD`tuple_positional_schema` is deprecated. Use `tuple_schema` instead.)categoryc\tjdtd|j|S)Replaced by `tuple_schema`.rr stacklevelwarningswarnr! tuple_schemar s rHtuple_positional_schemaz*GenerateJsonSchema.tuple_positional_schemas,  R %   ((rGB`tuple_variable_schema` is deprecated. Use `tuple_schema` instead.c\tjdtd|j|S)rur~rvrwryr s rHtuple_variable_schemaz(GenerateJsonSchema.tuple_variable_schemas,  P %   ((rGcddi}d|vrl|d}|dkDr-||d<|dd|Dcgc]}|j|c}|d<|d zt|dk(r|j|d||d <nJd |d <nD|dDcgc]}|j|}}|r||d<t||d<t||d <|j|||jj|Scc}wcc}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. rrQvariadic_item_indexrminItemsrlN prefixItemsr#rTmaxItems)rr[rrrQ)rxrrrrrs rHr|zGenerateJsonSchema.tuple_schemas))/'8 F *"()>"? "Q&*= J':@:PQeRe:f.26D''-. M*#Q&#f^.D*EE'+':':6.;QRe;f'g G$ (, G$AGAWX4..t4XKX-8 M*&)+&6K #&)+&6K # $$[&$:Q:Q:W:WX%.Ys 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 rH set_schemazGenerateJsonSchema.set_schema&&v..rGc$|j|S)zGenerates a JSON schema that matches a frozenset schema. Args: schema: The core schema. Returns: The generated JSON schema. rr s rHfrozenset_schemaz#GenerateJsonSchema.frozenset_schemarrGcd|vrin|j|d}dd|d}|j|||jj|S)NrlrQT)r uniqueItemsrrnros rHrz%GenerateJsonSchema._common_set_schemasR+69rt?R?RSYZhSi?j &tlS  $$[&$:Q:Q:W:WXrGcd|vrin|j|d}d|d}|j|||jj|S)zReturns a JSON schema that represents the provided GeneratorSchema. Args: schema: The schema. Returns: The generated JSON schema. rlrQrmrnros rHgenerator_schemaz#GenerateJsonSchema.generator_schemarqrGc"ddi}d|vr"|j|djni}d|vr%|jdd}|jddnd}d|vr"|j|djni}|jdd|s||||d <n ||i|d <nd |d <|jdd k(rt |d kDsd|vr|jdd||d<|j |||j j|S)zGenerates a JSON schema that matches a dict schema. Args: schema: The core schema. Returns: The generated JSON schema. robject keys_schemarr'Nr[ values_schemaadditionalPropertiespatternPropertiesTrNr# propertyNames)rrrrvr[rrr)rxrrr keys_patternrs rH dict_schemazGenerateJsonSchema.dict_schema's4)/'9 KX\bKbd))&*?@EEGhj  $&??9d;L OOGT * LO^bhOh++F?,CDIIKnp '4( L4#6C 234@-3P /026K. /__V $ 0S5E5I$ OOFD )+6K ( $$[&$:Q:Q:X:XYrGc|jdk(r$|jdx}r|j|S|j|dS)zGenerates a JSON schema that matches a function-before schema. Args: schema: The core schema. Returns: The generated JSON schema. r8json_schema_input_schemarrrvrrxr input_schemas rHfunction_before_schemaz)GenerateJsonSchema.function_before_schemaWK 99 $&**E_:`*`,*`&&|4 4""6(#344rGc*|j|dS)zGenerates a JSON schema that matches a function-after schema. Args: schema: The core schema. Returns: The generated JSON schema. rrr s rHfunction_after_schemaz(GenerateJsonSchema.function_after_schemae""6(#344rGc|jdk(r$|jdx}r|j|S|j|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)rrvrrdrs rHfunction_plain_schemaz(GenerateJsonSchema.function_plain_schemaps^ 99 $&**E_:`*`,*`&&|4 422 @ AS@TTUV  rGc|jdk(r$|jdx}r|j|S|j|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_schemarrGc|j|d}|j|}|tus|tur|S|jdk(rAt |d}|1|j dx}r||j ddvs ||} |j|}||d <|S#t$r|jdd|d|cYSwxYw#tj$r|jdd |d |cYSwxYw) zGenerates a JSON schema that matches a schema with a default value. Args: schema: The core schema. Returns: The generated JSON schema. rr9rrrr>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_valuerv Exception emit_warningencode_default pydantic_corePydanticSerializationError)rxrrrrser_funcencoded_defaults rHdefault_schemaz!GenerateJsonSchema.default_schemas6))&*:; ((0 i 7g#5  99 ':6(;KLJ&!+ !;;X; Z^^K-HLo-o '&w/G "11':O"1 I1! '%%24WK?}~'& '77    *  )fg     s$B! C!!CC+C65C6c.|jdtS)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)rvrr s rHrz$GenerateJsonSchema.get_default_valueszz)Y//rGcfddi}|j|d}||k(r|S|j||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)rxr null_schemainner_json_schemas rHnullable_schemaz"GenerateJsonSchema.nullable_schemasIv&  //x0@A  + ,,.?-MN NrGcNg}|d}|D]:}t|tr|dn|} |j|j|<t|dk(r|dS|j|S#t$rYlt $r&}|j d|jYd}~d}~wwxYw)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#) rtuplerbrrr.rmessager[r)rxr generatedrchoice choice_schemaexcs rH union_schemazGenerateJsonSchema.union_schemas,. # AF)3FE)BF1IM A  !4!4]!CD  A y>Q Q< ((33   / A!!"2CKK@@ As A++ B$6B$>BB$cN|jdk(rg}|D]_}|jd}|njt|ts|g}t d|DsnCt |dk7rn3|j |adttj|iS|j|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_arrayrc3,K|] }|tvywru)_PRIMITIVE_JSON_SCHEMA_TYPES)r\ts rHr_z:GenerateJsonSchema.get_union_of_schemas..sS1 <<Ssr#) rrvrraallr[extendrfromkeysget_flattened_anyof)rxschemasrTr schema_typess rHrz'GenerateJsonSchema.get_union_of_schemass    6 6!E! <7=zz&7I '!,5$0>LSlSSv;!#  \*! <&T]]5%9 :;;''00rGc *i}|djD]M\}}t|tr |j} |j |j |t |<Ot|j}d|i}|j||}|:||jDcic]\}}||jd|c}}d|d<|S#t$rYt$r&}|jd|jYd}~d}~wwxYwcc}}w)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=NoneOfr) propertyNamer discriminator)rrr rrrrrr.rrrcvalues_extract_discriminatorrv) rxrrrrrone_of_choicesropenapi_discriminators rHtagged_union_schemaz&GenerateJsonSchema.tagged_union_schema!s13 9%++- ADAq!T"GG A%)$7$7$:$?$?$A #a&! A.i.>.>.@A(/'@ !% ; ;FN S , 5} |j |}|jdi} t| tr|| vs??rGcz|jdd}|r|j|dS|j|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)rvr)rxr use_stricts rHlax_or_strict_schemaz'GenerateJsonSchema.lax_or_strict_schemasEZZ%0  &&vo'>? ?&&vl';< $C$C$E!//D4R4RSX4Y006-2!'* $ 9 9:K L 0Jt &&t, - (zB &5K #   sB11 B=<B=c|ddk(r|jd|}n4|jdk(r|jd|}n|jd|}t|tr|}|St|trPt d|}|D]=}t|tst |dk(s#t|d ts7|d }|S|St||S) Nrcomputed-fieldrr8validation_aliasserialization_aliaszlist[str] | strr#r)rvrrrrarr[r)rxrrrpaths rHrz"GenerateJsonSchema._get_alias_names =, ,7D1E YY, &II0$7EII3T:E eS !D t $*E2E dD)c$i1nDQRGUXAY 7D      rGc*|j|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. rrr s rHtyped_dict_field_schemaz*GenerateJsonSchema.typed_dict_field_schema rrGc*|j|dS)zGenerates a JSON schema that matches a schema that defines a dataclass field. Args: schema: The core schema. Returns: The generated JSON schema. rrr s rHdataclass_field_schemaz)GenerateJsonSchema.dataclass_field_schemarrGc*|j|dS)zGenerates a JSON schema that matches a schema that defines a model field. Args: schema: The core schema. Returns: The generated JSON schema. rrr s rHmodel_field_schemaz%GenerateJsonSchema.model_field_schemarrGc*|j|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_schemarr s rHcomputed_field_schemaz(GenerateJsonSchema.computed_field_schema*s""6/#:;;rGctd|d}|j}|jj|5|j |d}ddd|j |||S#1swYxYw)zGenerates a JSON schema that matches a schema that defines a model. Args: schema: The core schema. Returns: The generated JSON schema. ztype[BaseModel]rZrN)r model_configrrrr)rxrrZrrs rH model_schemazGenerateJsonSchema.model_schema5s|$fUm4!!  ' ' , ,V 4 @--fX.>?K @ !!+sF;  @ @s A))A2cddlm}ddlm}|j dx}|j d|nX|j dx}rE||}t |tstd|d|j|j d|d|vr|j|d<||ustj|rdn |j} | r&|j d tj| n9t!||r-|j"d j$x} r|j d | |j d } d |vr| d k(rd|d <n | dk(rd|d <|j d} t!||r8|j&r,|j(d j*} | r | r t-d| r| } t | t.t0fr| j3|} t | t4r|j7| nZt9| r>t;tj<| j>dkDr | ||n| |n| t-d| dtA|drd|d<yy)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) RootModelr[Nmodel_title_generatorzmodel_title_generator z must return str, not r\rootrrrTrFjson_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_modelrrv setdefaultrrr __class__rB dataclasses is_dataclassrEr^r_ issubclass__pydantic_fields__r\__pydantic_root_model__ model_fieldsr  ValueErrorr classmethod__get__rrrr[ signature parametershasattr)rxrrZrr7r config_titlerr[ docstringroot_descriptionrr root_json_schema_extras rHrz'GenerateJsonSchema._update_class_schemaJsg $)"JJw/ /L <  " "7L 9&,jj1H&I I " I)#.EeS)"89N8OOefkfufuev wxx  " "7E 2 + %#&<  ' .   0 1 ' (7$$%67BBCaG!+s3!+.  *45F4GGkl  3( )(,K % *rGczd|vr6|d}|jt|}|td||}d|vr6|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. rz(Cannot update undefined schema for $ref=)rrKr )rxrryschema_to_updates rHrz%GenerateJsonSchema.resolve_ref_schemas[ #f%C#?? M '"%McU#STT*K  # rGc |djDcgc],\}}|j|r||j|d|f.}}}|jdk(r0|j |j |j dg|j|}|j dd}|%|j|}|j||d<|Scc}}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. rTrr9rrNr) rrrrrrrvrrr)rxrrrrrrr7s rHmodel_fields_schemaz&GenerateJsonSchema.model_fields_schemas &h/557J e$$U+4))%t)?DDFK G !!+sF; s #K"%++"5$7;K;KCKK;XK )4K & G Gs #B==Cc^|jdijd}|d}|Dcgc]}|jddk(s|}}|Dcgc]}|jddvs|}}|Dcgc]}|jddk(s|}}|jd}|jd } |r| xr| } | r|j||z|S| xr| } | r|j||z| S|s| xr| } | r|j||z|Std cc}wcc}wcc}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_argumentsarguments_schemar keyword_only>Npositional_or_keywordpositional_onlyvar_args_schemavar_kwargs_schemazfUnable to generate JSON schema for arguments validator with positional-only and keyword-only arguments)rvp_arguments_schemakw_arguments_schemar.) rxrprefer_positional argumentsakw_only_argumentskw_or_p_argumentsp_only_argumentsrOrPpositional_possiblekeyword_possibles rHrKz#GenerateJsonSchema.arguments_schemasg#JJz26::;de-. (1U1QUU6]n5TQUU(1f1QUU6]Fe5eQff'0W!AEE&MEV4VAWW **%67"JJ':; &7"7"Q@Q+>?P+Q (+6R 2338K. /rGcg}d}|D]}|j|}|j|dj}d|vr(|j|dr|j ||d<|j ||dddk7s|dz }ddi}|r||d<|r||d <|r|j|} | r| |d <|St ||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. rrr[rrr#rQrrrr)r\rrrrrbr[) rxrTrO prefix_items min_itemsr]rr^rrls rHrQz%GenerateJsonSchema.p_arguments_schemags /1  ! H))(3D"11(82DEJJLOo-$2P2PQYZbQc2d+/+C+CD+I(    0!&)Y6Q  )/'8 )5K & &/K # ..?L'3 G$'*,&7K #rGct|d}|jr&|jd}t|tr|}|S |S)zRetrieves the name of an argument. Args: argument: The core schema. Returns: The name of the argument. rr)rrvrr)rxr]rrs rHr\z$GenerateJsonSchema.get_argument_namesC ==LL)E%%  rGc|d}i}g}|D]}|jdd}|j|}|j|dj}|dk(rd|d}n |dk(rd |d }|j d |j ||||<|d k(rd |vs|dvs|dddk7s|j |d |d} |r|| d <| S)rIrKrrMrvar_argsrQrmvar_kwargs_uniformr)rrr[var_kwargs_unpacked_typed_dictr>rerfrgrrr)rvr\rrr$rrb) rxrrTrrr]rrr^rs rHarguments_v3_schemaz&GenerateJsonSchema.arguments_v3_schemas -. 13  ! &H<<(?@D))(3D"11(82DEJJLOz!+2_"M--+3_"]  & &w0H0H0N O.Jt 99jO>[ccX&v.); %) &,19 'S &.K #rGc*|j|dS)zGenerates a JSON schema that matches a schema that defines a function call. Args: schema: The core schema. Returns: The generated JSON schema. rKrr s rH call_schemazGenerateJsonSchema.call_schemas""6*<#=>>rGc*|j|dS)zGenerates a JSON schema that matches a schema that defines a custom error. Args: schema: The core schema. Returns: The generated JSON schema. rrr s rHcustom_error_schemaz&GenerateJsonSchema.custom_error_schemarrGc|jdxstj}|j|}|jdk(rdd|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)rvrrrr)rxrcontent_core_schemacontent_json_schemas rHrzGenerateJsonSchema.json_schemasV%jj2Nk6L6L6N"112EF 99 $$:L_rs s' &rGc`dddd}|j|||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#rr< minLengthrrrNr6s rH url_schemazGenerateJsonSchema.url_schemas4 (5qI  $$[&$:Q:Q:X:XYrGc`dddd}|j|||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#rtrvr6s rHmulti_host_url_schemaz(GenerateJsonSchema.multi_host_url_schemas6 (3CRST  $$[&$:Q:Q:X:XYrGc dddS)zGenerates a JSON schema that matches a UUID. Args: schema: The core schema. Returns: The generated JSON schema. rNuuidr;rFr s rH uuid_schemazGenerateJsonSchema.uuid_schema rCrGc|dD]} |j||j|dS#t$rB}t|d}||j|j ||j f<Yd}~qd}~wwxYw)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. rhryNr)rr.rIr get_defs_refr)rxr definitionrrs rHrjz%GenerateJsonSchema.definitions_schemas!/ J ##J/ ""6(#344 0 $+Ju,=$>de778I8I8UYU^U^J_8`a s1 A<8A77A<cJt|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)rIr)rxrrrrs rHdefinition_ref_schemaz(GenerateJsonSchema.definition_ref_schema*s.6,/0!;;HE?rGc|d}|dk(s|dk(r%|jd}||j|Sy|dk(s|dk(r#|jtjS|ddk(r|j|d Sy) 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-wraprNr<z to-stringmodelr)rvrr2r)rxr schema_typers rHrzGenerateJsonSchema.ser_schema7sVn * *k_.L"JJ7M(**=99 H $ {(B??;#9#9#;< < F^w &&&vh'78 8rGc 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. rrNrFr s rHcomplex_schemaz!GenerateJsonSchema.complex_schemaPs!!rGc^|jjddjS)zRetrieves a title from a name. Args: name: The name to retrieve a title from. Returns: The title. r )r[rstriprxrs rHrz&GenerateJsonSchema.get_title_from_namebs&zz|##C-3355rGcztj|r$|ddk(r|d}n|d}|j|Stj|r`|j dry|ddvr|j|dStj |r|j|dS|ddk(ryy t 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. rr rrryF>rrrhzdefinition-refTr)r&rrrrvis_function_with_inner_schemar.)rxr field_schemas rHrz,GenerateJsonSchema.field_title_should_be_setms  + +F 3f~!11%o6 %h/ 11,? ?  ' ' /zz% f~!GG55fX6FGG88@55fX6FGGf~!11/1PQWPX/YZ ZrGcPtjdd|jddS)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%vv)35==c4HHrGc<|\}}tjd|}|Dcgc]}|jddd}}dj|}|Dcgc]}tjdd|}}dj|}t |}t |j|} t |j|d|z} t |j|} t | d|} t |j|} |jj| }|5|j| xxdz cc<|j| x}|j| <t | d |}t | d |}| | | | ||g|j|<|Scc}wcc}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#rz(?:[^.[\]]+\.)+((?:[^.[\]]+))z\1rr) rsplitrsplitjoinrr<rJrrrvrr)rxrrr componentsr]core_ref_no_id short_ref mode_titler name_modemodule_qualnamemodule_qualname_modemodule_qualname_idoccurrence_indexmodule_qualname_occurrencemodule_qualname_occurrence_modes rHr~zGenerateJsonSchema.get_defs_refs'$XXk84 3=>aahhsA&q)> >,R\]Qbff=uaH] ]GGJ' (. t**956D// :q =MMN !$"5"5n"EF&/):!J<'HI$T%8%8%BC00445GH  #  # #O 4 9 4KOKbKbcrKs s t445GH%,/@CSBT-U%V"*15I4J"M]L^2_*`'    & + N ))*IJ/.C?^s FFcv||jf}|jj|}||j|}|d|ifS|j |}||j|<||j |<t |jj|}||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. rr) rrrvrr~rrKrr<r)rxrrmaybe_defs_refrrlrs rHrz,GenerateJsonSchema.get_cache_defs_ref_schemas"499- //33MB  %--mrNrQrrFrGrHrr9 s^ ($$  &%  &%   %$  *) rGrcg}|D]:}t|dk(rd|vr|j|d*|j|<t|}t|dk(r|dSd|iS)Nr#r/r)r[rrbrc)rxrr]rs rHrz&GenerateJsonSchema.get_flattened_anyofY sr 'F6{aGv$5vg/v&  ' 'w/ w<1 1: !!rGc@tdfd |S)zKGet all values corresponding to the key '$ref' anywhere in the json_schema.ct|trd|vrut|d}t|tsy|v}|xxdz cc<|ry j|}|j vrj |j ||jD]#\}}|dk(rt|tr|%yt|tr|D] }| yy#t$r|jdsYuwxYw)Nrr#rexamples) rrrKrrrrhrrrra) rralready_visitedrlrr_add_json_refs json_refsrxs rHrz>GenerateJsonSchema.get_json_ref_counts.._add_json_refsi s &$'V#&vf~6H%h4&.)&;Oh'1,'&"#'#9#9(#C#t'N'NN"&"I"I("SS&t'7'7'AB #LLN&DAqJ:a+>!"1% & FD)&A"1%&*$"'223JK! L"s AC##DD)rrrNone)r)rxrrrs` @@rHrz&GenerateJsonSchema.get_json_ref_countse s(/  &: {#rGctd|)Nz!Cannot generate a JsonSchema for )r.)rxr error_infos rHrdz1GenerateJsonSchema.handle_invalid_for_json_schema s*-Nzl+[\\rGcb|j||}|tj|tyy)zfThis method simply emits PydanticJsonSchemaWarnings based on handling in the `warning_message` method.N)render_warning_messagerzr{rA)rxkinddetailrs rHrzGenerateJsonSchema.emit_warning s.--dF;   MM'#< = rGc0||jvry|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)rxrrs rHrz)GenerateJsonSchema.render_warning_message s(" 4-- -D6##rGci}|jjD]3}|D],}t|jj |}|||<.5t j |j||jS)Nr)rrrKrr<rTrsrh)rxrg defs_refsrlrs rHrz/GenerateJsonSchema._build_definitions_remapping s/1 ::AAC 2I% 2"4#4#4#;#;(#;#KL)1 X& 2 2 %==  - -|T=M=M  rGct}t|}|r`|j} |j|}||vr'|j ||j t|j ||r`|j jDcic] \}}||vs ||c}}|_y#t$r|jdsYYwxYwcc}}wr) set_get_all_json_refsrraddrrhrrr)rxrvisited_defs_refsunvisited_json_refs next_json_ref next_defs_refrrs rHrz/GenerateJsonSchema._garbage_collect_definitions s*-%08!/335M  $ 6 6} E  $55!%%m4#**+=d>N>N}>]+^_".2-=-=-C-C-E`TQN_I_AqD`  $//0GHI as"B18B1 C"C1CC)rrRrrr)Literal['any_of', 'primitive_type_array']rr)rz_config.ConfigWrapper)rJsonSchemaMode)rzKdict[CoreSchemaOrFieldType, Callable[[CoreSchemaOrField], JsonSchemaValue]])rzGSequence[tuple[JsonSchemaKeyT, JsonSchemaMode, core_schema.CoreSchema]]rzctuple[dict[tuple[JsonSchemaKeyT, JsonSchemaMode], JsonSchemaValue], dict[DefsRef, JsonSchemaValue]])r8)rrrrrr)rr3rrru)rrr str | Nonerr)rrrrrr)rzcore_schema.InvalidSchemarr)rzcore_schema.AnySchemarr)rzcore_schema.NoneSchemarr)rzcore_schema.BoolSchemarr)rzcore_schema.IntSchemarr)rzcore_schema.FloatSchemarr)rr1rr)rzcore_schema.StringSchemarr)rzcore_schema.BytesSchemarr)rzcore_schema.DateSchemarr)rzcore_schema.TimeSchemarr)rzcore_schema.DatetimeSchemarr)rzcore_schema.TimedeltaSchemarr)rzcore_schema.LiteralSchemarr)rz!core_schema.MissingSentinelSchemarr)rzcore_schema.EnumSchemarr)rzcore_schema.IsInstanceSchemarr)rzcore_schema.IsSubclassSchemarr)rrirr)rzcore_schema.ListSchemarr)rzcore_schema.TupleSchemarr)rzcore_schema.SetSchemarr)rzcore_schema.FrozenSetSchemarr)rz3core_schema.SetSchema | core_schema.FrozenSetSchemarr)rzcore_schema.GeneratorSchemarr)rzcore_schema.DictSchemarr)rz)core_schema.BeforeValidatorFunctionSchemarr)rz(core_schema.AfterValidatorFunctionSchemarr)rz(core_schema.PlainValidatorFunctionSchemarr)rz'core_schema.WrapValidatorFunctionSchemarr)rcore_schema.WithDefaultSchemarr)rrrr)rzcore_schema.NullableSchemarr)rzcore_schema.UnionSchemarr)rzlist[JsonSchemaValue]rr)rcore_schema.TaggedUnionSchemarr)rrrlist[JsonDict]rr)rzcore_schema.ChainSchemarr)rzcore_schema.LaxOrStrictSchemarr)rzcore_schema.JsonOrPythonSchemarr)rzcore_schema.TypedDictSchemarr)rzlist[ComputedField]rz1list[tuple[str, bool, core_schema.ComputedField]])rz+Sequence[tuple[str, bool, CoreSchemaField]]rr)rr2rrrr)rzcore_schema.TypedDictFieldrr)rzcore_schema.DataclassFieldrr)rzcore_schema.ModelFieldrr)rzcore_schema.ComputedFieldrr)rzcore_schema.ModelSchemarr)rrrZz type[Any]rr1rr)rrrr)rzcore_schema.ModelFieldsSchemarr)rr2rrR)rzPcore_schema.ModelField | core_schema.DataclassField | core_schema.TypedDictFieldrrRrrR)rzcore_schema.DataclassArgsSchemarr)rzcore_schema.DataclassSchemarr)rzcore_schema.ArgumentsSchemarr)rT$list[core_schema.ArgumentsParameter]rPCoreSchema | Nonerr)rTrrOrrr)r]zAcore_schema.ArgumentsParameter | core_schema.ArgumentsV3Parameterrr)rzcore_schema.ArgumentsV3Schemarr)rzcore_schema.CallSchemarr)rzcore_schema.CustomErrorSchemarr)rzcore_schema.JsonSchemarr)rzcore_schema.UrlSchemarr)rzcore_schema.MultiHostUrlSchemarr)rzcore_schema.UuidSchemarr)rzcore_schema.DefinitionsSchemarr)rz%core_schema.DefinitionReferenceSchemarr)rzVcore_schema.SerSchema | core_schema.IncExSeqSerSchema | core_schema.IncExDictSerSchemarJsonSchemaValue | None)rzcore_schema.ComplexSchemarr)rrrr)rr3rrR)r CoreModeRefrrJ)rrIrztuple[DefsRef, JsonSchemaValue])rrKrr)rrrr)rrrrrzdict[str, str]rr)rrrzdict[JsonRef, int])rr3rrrr)rJsonSchemaWarningKindrrrr)rrrrrr)rrT)rrrr)orBrCrDrEschema_dialectrrDEFAULT_REF_TEMPLATErpropertyr$rrrrrrrr rrrrr!r4r2r?rBrFrHrLrUrXrarergrjrprrr}rr|rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr:rrrBrGrKrRrQr\rhrjrlrrwryr|rjrrrrrrr~rrrrrrrrrdrrrrrFrGrHrrs'RDN:J8J5J0BJ (((@ (  (T//  T4/A]/A l/Ab/&bJX $j    #  IV  4 4 9 8@ "H n  Y Vaef ) g)T_cd ) e)!F / / .` 5 5 54l 0O"42"1H#J+%3+%ES+% +%Z @=& :/bT,T :TT %P 2* 5 5 5 <*E-N(.$$_  >I$<" H$=$Rc$ $L)=)Pa) )V$%N ? 5'"   45$ l 2"$ 6![F I./`)86  : E* E9C EN\ E  E  @ ""H]> $*  arGrTrr8cNddlm}||||}t|jtj r|jj ||ur tdt|jtj rJd|j|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) r"r7r__pydantic_core_schema__r)MockCoreSchemarebuildrr)rZrrrschema_generatorrr7schema_generator_instances rHmodel_json_schemar s@ 0 <!#.. 0L0LM $$,,. istt#66 8T8TUxWxx U $ - -c.J.JQU - VVrG)rr[r\rrrcV|D]D\}}t|jtjs+|jj F||||} |D cgc]\} } | | | jf} } } | j | \} }i}|r||d<|r||d<|r||d<| |fScc} } w)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. rrXr[r\)rrr)rrr)modelsrr[r\rrrrZrinstancemrrrrhrs rHmodels_json_schemar sH3Q c22M4P4P Q  ( ( 0 0 23  [ghH=Cb29!TD!,,-bFb%-$A$A&$I!k"$K* G $ G%0 M" [ ((bsB%)_HashableJsonValue.r.rcnt|Dcic]}t||c}jScc}wru)ra_make_json_hashabler)rrs rHrcrc8 s/ 7K$V,f4KRRT UUKs2ct|tr)ttd|j DSt|t rtd|DS|S)Nc3<K|]\}}|t|fywrur)r\rrs rHr_z&_make_json_hashable..> sRDAqQ 3A 67Rsc32K|]}t|ywrur)r\rs rHr_z&_make_json_hashable..@ s;(+;s)rrrrrra)rs rHrr< sH%VREKKMRRSS E4 ;U;;; rGcFeZdZUdZded<dZded< d dZd dZy) 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'] | Nonerc|jxs |j}||jk7r||S|jt|jjSru)rrrr)rxrhandlerrs rH__get_pydantic_json_schema__z+WithJsonSchema.__get_pydantic_json_schema__X sTyy(GLL 7<< ;' '    # ##((* *rGc>tt|jSruhashrrrs rH__hash__zWithJsonSchema.__hash__d DO$$rGrzcore_schema.CoreSchemar r+rrrr)rBrCrDrErrr rrFrGrHrrE s< (':>D 7> +1 +Using a dict for `examples` is deprecated, use a list instead.rvrw)rrrzr{r"rrrs rHrzExamples.__init__{ s3 h % MMP)  !  rGc |jxs |j}||}||jk7r|S|jd}|t|j|d<t |t rt |jt r[tjdtt|jDcgc] }|D]}| c}}|jz|d<nti||j|d<t |t rt |jt rt||jz|d<|St |jt rZtjdtt||jjDcgc] }|D]}| c}}z|d<|Scc}}wcc}}w)NrzUpdating 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.) rrvrrrrrarzr{ UserWarningr)rxrr rrrrexs rHr z%Examples.__get_pydantic_json_schema__ syy(GLLk* 7<<  ??:.  &8&GK # h %$--. J  +=%-__%6GEG2RGRG$--W+ J'+==Z=ZDMM=Z*[ J' h %$--.*tt|jSrur rs rHrzExamples.__hash__ rrGru)rdict[str, Any]rrrr)rz list[Any]rrrr)rzdict[str, Any] | list[Any]rrrrrr) rBrCrDrErrrr rrFrGrHrrh swx^b&.[ yttko 2 :g   %1%r@se 3 ,88   \\3HH>R5'bbI9J : :K<[<[ [\ sCx.67AHZb1c.c ef  H  )A )S ! )S ! )S !G^+, ):Q8,778MM9M`g#ag#a^G,>F1C' -W 2-W-W-W< -W / -W  -W-Wf",>F1C6) V6)6)  6)  6)  6)<6)/6)u6)x!&T4'@!A5sThOhIiknInCoo!I V8,778%%9%DG%G%T8 ) w|,N[<0;;<9$9$=9$x CrG