Xj UdZddlmZddlZddlZddlZddlZddl Z ddl Z ddl Z ddlm Z m Z ddlmZmZmZddlmZddlmZddl mZdd 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:m;Z;ddlm?Z?m@Z@ddlAmBZBmCZCmDZDer ddlEmFZFddlGmHZHmIZIddlJmKZKddlLmMZMddlNmOZOee%je%jfZR eSeTefZU edZV dddZWdeXd<edZY Gdd eZZ[e\Z] d!Z^ ed"eTZ_ed#eTZ`ed$eTZaebe_eVfZced%e&Zdd'ZeejdBie8jGd(d)ZhGd*d+Zid,e^d-eid.f dCd/Zjd,dde^d-eid0 dDd1ZkeelemeTendebd2ebebeTd3fd4ffZod5eXd3<dEd6ZpdFd7ZqejdBie8jGd8d9ZrGd:d;ZsdGd<Zted=Zuereeud4fZvn)ejdBie8jGd>d?ZvdHd@ZwdIdAZxy)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 _typing_extra)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__h/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/pydantic/json_schema.pyrBrBgsrHrBz#/$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]F} || }t fd|D} | | | <|j| } || dD] }|| | ||<Ht| | }|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 rI zA_DefinitionsRemapping.from_prioritized_choices..s%(jqCH`abHcDdhiDi(js!!Nz.Failed to simplify the JSON schema definitions) r rangerlistappend_deduplicate_schemasnextindexrUremap_json_schemar/)prioritized_choices defs_to_json definitionscopied_definitionsdefinitions_schema_iterdefs_ref alternatives alternativerVrWoriginal_defs_refremapped_defs_refremapped_indexalt remappingnew_definitions_schemar_s @rIfrom_prioritized_choicesz._DefinitionsRemapping.from_prioritized_choicessz&k2%'9:3Z 8EMXY]M^ $. _28< #/_K,[9@@AST\A]^_ _5 n5IJbckJl5m(2 n68N57N%0 X!23DE $((jL(j$j!4E01".!3!34E!F'8XC8DEV8WN<#45X X.nnMI%.%@%@'K]A^%_ "!%;;  !7 A 8D++[\\rHc:|jj||SN)rVgetselfrefs rIremap_defs_refz$_DefinitionsRemapping.remap_defs_ref""&&sC00rHc:|jj||Sry)rWrzr{s rIremap_json_refz$_DefinitionsRemapping.remap_json_refrrHc 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 $refrY) isinstancestrrrLrbrgdictitemsr~rK)r|schemaitemkeyvalues rIrgz'_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)rhzdict[DefsRef, list[DefsRef]]rizdict[DefsRef, JsonRef]rjzdict[DefsRef, JsonSchemaValue]returnrU)r}rKrrK)r}rLrrL)rrrr) rCrDrE__annotations__ staticmethodrwr~rrgrGrHrIrUrUsZ****1]91],1]41]  1]1]f11rHrUc0eZdZUdZdZdhZded<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)Nr9F)by_alias ref_template union_formatcore_to_json_refscore_to_defs_refsdefs_to_core_refsjson_to_defs_refsrjr$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 rI__init__zGenerateJsonSchema.__init__s ! (GS=?=?=?9;;=%,%?%?@U@UVX@Y%Z"%1 KM)2=c2B02&*&F&F&H#`b/ rHc.|jjSry)rtailr|s rIr$zGenerateJsonSchema._config;s))...rHcr|jj|jjS|jSry)r$json_schema_mode_overriderrs rImodezGenerateJsonSchema.mode?s, << 1 1 =<<99 9:: rHc :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: .)) rbr CoreSchemaOrFieldTypereplacegetattrAttributeErrorosgetenv TypeErrortyperC)r|mappingcore_schema_typesr method_namees rIrz.GenerateJsonSchema.build_schema_type_to_methodFs`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-usedcoderYT) rr1rrCrgenerate_inner_build_definitions_remappingrgrjsort) r|inputsrrrdefinitions_remappingjson_schemas_mapr json_schemas rIgenerate_definitionsz'GenerateJsonSchema.generate_definitions`s2 ::#559$Z5H5H4IIhj/  & (OAtVDJ    ' (!% A A CQS!' a CvDJ--f5K,A,S,ST_,` c4[ ) a  0 01 +==kJ  ;w+?!@@@rHc||_|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#rYT)rrr1rrCrget_json_ref_countsrrLrzget_schema_from_definitionsr\copy_garbage_collect_definitionsrrjrgr)r|rrrjson_ref_countsr}ref_json_schemars rIgeneratezGenerateJsonSchema.generatesK ::#559$Z5H5H4IIhj/  (,':':6'B 22;?7KOOF34o">>sCOs#q(_-HSQ\M]abMb-224 $)$7KOOF$;<Co ))+6 $ A A C   #'#3#3K +==kJ  yy%%rHcn 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. r}rcd|vrrt|d}j|\}}t|d}|jdd|k7r+|j|<j j |d|}|S)Nr}r)rJget_cache_defs_ref_schemarLrzrjrpop)rrcore_refrnrjson_refr|s rI 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 rHmetadatapydantic_js_updatesc i||}|SryrG)rcurrent_handlerr js_updatess rIjs_updates_handler_funczBGenerateJsonSchema.generate_inner..js_updates_handler_funcs Q!APZP ""rHpydantic_js_extrac||}ttr|jt|St r||Sry)rrupdatercallable)rrrjs_extras rIjs_extra_handler_funcz@GenerateJsonSchema.generate_inner..js_extra_handler_funcsM.o> h-&&'9('CD#"h'[)""rHpydantic_js_functionsrGc|||}tj|r ||}|j|}|jdd}|r|r|j ||S)Nr)r&rresolve_ref_schemarr)rrjs_modify_functionroriginal_schemar}rs rInew_handler_funcz;GenerateJsonSchema.generate_inner..new_handler_func.sd 1/R --o>"/"MK"1"D"D["Q!oofd3;#**;7&&rH pydantic_js_annotation_functionsc|||SryrG)rrrs rIrz;GenerateJsonSchema.generate_inner..new_handler_func@s */?KKrH)rrrJsonSchemaValuerr)rr4rr)rr4rr,rr)rr4rr,rr6rr) rJrrrjrr*GenerateJsonSchemaHandlerrr% CoreMetadatarzr&r)r|rr core_mode_refrrrrrrrrrrrs` @@@rIrz!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=(NrH)r+r9 multiple_oflegeltgtanyOf allow_inf_nanN)r4r.r/r0r1r2)rcore_schema.DecimalSchemarr) str_schemarrrzr%float) r|rr-rr.r/r0r1r2s rIdecimal_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. rrs rImissing_sentinel_schemaz*GenerateJsonSchema.missing_sentinel_schemafs rHc|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 descriptionmembersrTrOrrRrSrPrU)rFinspectcleandocrCrrrrrrrr7rVrb) r|r enum_typer`rWr r!rRrrXs rI enum_schemazGenerateJsonSchema.enum_schemaqs_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 (r^rhandle_invalid_for_json_schemars rIis_instance_schemaz%GenerateJsonSchema.is_instance_schemas*226=[\bch\i[jjk;lmmrHciS)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. rGrs rIis_subclass_schemaz%GenerateJsonSchema.is_subclass_schemas  rHc&|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.CallableSchemargrs rIcallable_schemaz"GenerateJsonSchema.callable_schemas226;WXXrHcd|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_schemarUrrrrrrUr|rrprs rI list_schemazGenerateJsonSchema.list_schemaR,69rt?R?RSYZhSi?j &>  $$[&$:Q:Q:W:WXrHD`tuple_positional_schema` is deprecated. Use `tuple_schema` instead.)categoryc\tjdtd|j|S)Replaced by `tuple_schema`.rv stacklevelwarningswarnr! tuple_schemars rItuple_positional_schemaz*GenerateJsonSchema.tuple_positional_schemas,  R %   ((rHB`tuple_variable_schema` is deprecated. Use `tuple_schema` instead.c\tjdtd|j|S)ryrrzr{r}rs rItuple_variable_schemaz(GenerateJsonSchema.tuple_variable_schemas,  P %   ((rHcddi}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. rrUvariadic_item_indexrminItemsrpN prefixItemsr#rTmaxItems)rr\rrrU)r|rrrrrs rIrzGenerateJsonSchema.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_schemars rI set_schemazGenerateJsonSchema.set_schema&&v..rHc$|j|S)zGenerates a JSON schema that matches a frozenset schema. Args: schema: The core schema. Returns: The generated JSON schema. rrs rIfrozenset_schemaz#GenerateJsonSchema.frozenset_schemarrHcd|vrin|j|d}dd|d}|j|||jj|S)NrprUT)r uniqueItemsrrrrss rIrz%GenerateJsonSchema._common_set_schemasR+69rt?R?RSYZhSi?j &tlS  $$[&$:Q:Q:W:WXrHcd|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. rprUrqrrrss rIgenerator_schemaz#GenerateJsonSchema.generator_schema rurHc"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_schemaadditionalPropertiespatternPropertiesTrOr# propertyNames)rrrrzr\rrr)r|rrr keys_patternrs rI 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:XYrHc|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. r9json_schema_input_schemarrrzrr|r input_schemas rIfunction_before_schemaz)GenerateJsonSchema.function_before_schema^K 99 $&**E_:`*`,*`&&|4 4""6(#344rHc*|j|dS)zGenerates a JSON schema that matches a function-after schema. Args: schema: The core schema. Returns: The generated JSON schema. rrrs rIfunction_after_schemaz(GenerateJsonSchema.function_after_schemal""6(#344rHc|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. r9rz*core_schema.PlainValidatorFunctionSchema (functionr)rrzrrhrs rIfunction_plain_schemaz(GenerateJsonSchema.function_plain_schemaws^ 99 $&**E_:`*`,*`&&|4 422 @ AS@TTUV  rHc|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. r9rrrrs rIfunction_wrap_schemaz'GenerateJsonSchema.function_wrap_schemarrHc|j|d}|j|}|tus|tur|S|jdk(rAt |d}|1|j dx}r||j ddvs ||}t|tjjrt|d kDr t|} |j!|}||d <|S#t$r|jdd|d|cYSwxYw#t$rYKwxYw#t"j$$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. rr:rrrr?zUnable to serialize value z> with the plain serializer; excluding default from JSON schemar#zDefault value z= is not JSON serializable; excluding default from JSON schemar)rget_default_value NoDefaultrr!_get_ser_schema_for_default_valuerz Exception emit_warningr collectionsabcSetr\r rencode_default pydantic_corePydanticSerializationError)r|rrrrser_funcencoded_defaults rIdefault_schemaz!GenerateJsonSchema.default_schemasy))&*:; ((0 i 7g#5  99 ':6(;KLJ&!+ !;;X; Z^^K-HLo-o '&w/G g{22 3G q8H  /  "11':O"1 IC! '%%24WK?}~'& '$   77    *  )fg     s6C; DD!DD DD+EEc.|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)rzrrs rIrz$GenerateJsonSchema.get_default_valueszz)Y//rHcfddi}|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. rrQr)rr)r|r null_schemainner_json_schemas rInullable_schemaz"GenerateJsonSchema.nullable_schemasIv&  //x0@A  + ,,.?-MN NrHc<g}tj|D]#} |j|j|%t|dk(r|dS|j|S#t$rYUt $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. r>Nr#r) riter_union_choicesrcrrr/rmessager\r)r|r generatedchoiceexcs rI union_schemazGenerateJsonSchema.union_schemas,. !44V< AF A  !4!4V!<= A y>Q Q< ((33   / A!!"2CKK@@ As A"" B-B5BBcN|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|] }|tvywry)_PRIMITIVE_JSON_SCHEMA_TYPES)r]ts rIr`z:GenerateJsonSchema.get_union_of_schemas..sS1 <<Ssr#) rrzrrballr\extendrfromkeysget_flattened_anyof)r|schemasrXr schema_typess rIrz'GenerateJsonSchema.get_union_of_schemas s    6 6!E! <7=zz&7I '!,5$0>LSlSSv;!#  \*! <&T]]5%9 :;;''00rHc *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. choicesr>NoneOfr) propertyNamer discriminator)rrr rrrrrr/rrrdvalues_extract_discriminatorrz) r|rrr r!rone_of_choicesropenapi_discriminators rItagged_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??rHcz|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)rzr)r|r use_stricts rIlax_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-fieldrr9validation_aliasserialization_aliaszlist[str] | strr#r)rzrrrrbrr\r)r|rrrpaths rIr z"GenerateJsonSchema._get_alias_names =, ,7D1E YY, &II0$7EII3T:E eS !D t $*E2E dD)c$i1nDQRGUXAY 7D      rHc*|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. rrrs rItyped_dict_field_schemaz*GenerateJsonSchema.typed_dict_field_schemarrHc*|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. rrrs rIdataclass_field_schemaz)GenerateJsonSchema.dataclass_field_schema#rrHc*|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. rrrs rImodel_field_schemaz%GenerateJsonSchema.model_field_schema.rrHc*|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_schemarrs rIcomputed_field_schemaz(GenerateJsonSchema.computed_field_schema9s""6/#:;;rHctd|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]r^rN)r model_configrrrrr|rr^rrs rI model_schemazGenerateJsonSchema.model_schemaDs|$fUm4!!  ' ' , ,V 4 @--fX.>?K @ !!+sF;  @ @s A))A2c ddlm}ddlm}|j dx}|j d|nX|j dx}rE||}t |tstd|d|j|j d|d|vr|j|d<||urd} nE||r1|j} | | j|jd rdn| } n |j} | r%|j d tj| |j d } d |vr| d k(rd|d <n | dk(rd|d <|j d} t||r8|j r,|j"dj$} | r | r t'd| r| } t | t(t*fr| j-|} t | t.r|j1| nt3| r~t5t7j8| j:dkDr0t=t>t@tBtDgdf| } | ||n4t=t>t@gdf| } | |n| t'd| dtG|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#)is_stdlib_dataclassr7r_Nmodel_title_generatorzmodel_title_generator z must return str, not (r`rrrTrFjson_schema_extrarootzz"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)$_internal._dataclassesr$mainr8rz setdefaultrrr __class__rCrF startswithrbrc issubclass__pydantic_root_model__ model_fieldsr' ValueErrorr classmethod__get__rrrr\r+signature_no_eval parametersrrr-rrhasattr)r|rr^rr$r8 config_titler%r_ docstringdocrr'root_json_schema_extras rIrz'GenerateJsonSchema._update_class_schemaYs @#"JJw/ /L <  " "7L 9&,jj1H&I I " I)#.EeS)"89N8OOefkfufuev wxx  " "7E 2 + %#&<P/QWZI I   " "='2B2B92M N 7# ! 46: 23("6; 23"JJ':; c9 %#*E*E%(%5%5f%=%O%O " %; <&$:! ', )D E 1 9 9# >  ' .   0 1 ' (=223DEPPQTUU$(8T#Y2G2M)NPa$b!!+s3$(8*d2B)CEV$W!!+.  *45F4GGkl  3( )(,K % *rHczd|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=)rrLr)r|rr}schema_to_updates rIrz%GenerateJsonSchema.resolve_ref_schemas[ #f%C#?? M '"%McU#STT*K  # rHc |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. rTrr:rrNr) rrrrrrrzrrr)r|rrrrrrr=s rImodel_fields_schemaz&GenerateJsonSchema.model_fields_schemas &h/557J e$$U+4))%t)?DDFK G !!+sF;  G Gs #A88Bc^|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)rzp_arguments_schemakw_arguments_schemar/) r|rprefer_positional argumentsakw_only_argumentskw_or_p_argumentsp_only_argumentsrSrTpositional_possiblekeyword_possibles rIrOz#GenerateJsonSchema.arguments_schema,sg#JJz26::;de-. (1U1QUU6]n5TQUU(1f1QUU6]Fe5eQff'0W!AEE&MEV4VAWW **%67"JJ':; &7"7"Q@Q+>?P+Q (+6R 2338K. /rHcg}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#rUrrrr)r`rrr r rcr\) r|rXrS prefix_items min_itemsrarrbrrps rIrUz%GenerateJsonSchema.p_arguments_schemavs /1  ! H))(3D"11(82DEJJLOo-$2P2PQYZbQc2d+/+C+CD+I(    0!&)Y6Q  )/'8 )5K & &/K # ..?L'3 G$'*,&7K #rHct|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)rrzrr)r|rarrs rIr`z$GenerateJsonSchema.get_argument_namesC ==LL)E%%  rHc|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)rMrOrrQrvar_argsrUrqvar_kwargs_uniformr)rrr_var_kwargs_unpacked_typed_dictr >rirjrkrrr )rzr`rrr,r rc) r|rrXrr rarrrbrs rIarguments_v3_schemaz&GenerateJsonSchema.arguments_v3_schemas -. 13  ! &H<<(?@D))(3D"11(82DEJJLOz!+2_"M--+3_"]  & &w0H0H0N O.Jt 99jO>[ccX&v.); %) &,19 'S &.K #rHc*|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. rOrrs rI call_schemazGenerateJsonSchema.call_schemas""6*<#=>>rHc*|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. rrrs rIcustom_error_schemaz&GenerateJsonSchema.custom_error_schemarrHc|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. rr9rOzapplication/json)rcontentMediaType contentSchema)rzrrrr)r|rcontent_core_schemacontent_json_schemas rIrzGenerateJsonSchema.json_schemasV%jj2Nk6L6L6N"112EF 99 $$:L_rs s' &rHc`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. rOurir#rr@ minLengthrrrOr:s rI url_schemazGenerateJsonSchema.url_schemas4 (5qI  $$[&$:Q:Q:X:XYrHc`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. rOzmulti-host-urir#rxrzr:s rImulti_host_url_schemaz(GenerateJsonSchema.multi_host_url_schemas6 (3CRST  $$[&$:Q:Q:X:XYrHc dddS)zGenerates a JSON schema that matches a UUID. Args: schema: The core schema. Returns: The generated JSON schema. rOuuidr?rGrs rI uuid_schemazGenerateJsonSchema.uuid_schemarGrHc|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. rjr}Nr)rr/rJr get_defs_refr)r|r definitionrrs rIrlz%GenerateJsonSchema.definitions_schema's!/ 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)rJr)r|rrrrs rIdefinition_ref_schemaz(GenerateJsonSchema.definition_ref_schema9s.6,/0!;;HE?rHc|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)rzrr6r)r|r schema_typers rIrzGenerateJsonSchema.ser_schemaFsVn * *k_.L"JJ7M(**=99 H $ {(B??;#9#9#;< < F^w &&&vh'78 8rHc 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. rrOrGrs rIcomplex_schemaz!GenerateJsonSchema.complex_schema_s!!rHc^|jjddjS)zRetrieves a title from a name. Args: name: The name to retrieve a title from. Returns: The title. r )r_rstripr|rs rIr z&GenerateJsonSchema.get_title_from_nameqs&zz|##C-3355rHcztj|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. rrrrr}F>rrrjzdefinition-refTr)r&rr rrzis_function_with_inner_schemar/)r|r field_schemas rIr z,GenerateJsonSchema.field_title_should_be_set|s  + +F 3f~!11%o6 %h/ 11,? ?  ' ' /zz% f~!GG55fX6FGG88@55fX6FGGf~!11/1PQWPX/YZ ZrHcPtjdd|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 rInormalize_namez!GenerateJsonSchema.normalize_names%vv)35==c4HHrHc<|\}}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=rKrrrzrr)r|rrr componentsr^core_ref_no_id short_ref mode_titler name_modemodule_qualnamemodule_qualname_modemodule_qualname_idoccurrence_indexmodule_qualname_occurrencemodule_qualname_occurrence_modes rIrzGenerateJsonSchema.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) rrrzrrrrLrr@r)r|rrmaybe_defs_refrrnrs rIrz,GenerateJsonSchema.get_cache_defs_ref_schemas"499- //33MB  %--mGenerateJsonSchema.get_json_ref_counts.._add_json_refsx 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)r|rrrs` @@rIrz&GenerateJsonSchema.get_json_ref_countst s(/  &: {#rHctd|)Nz!Cannot generate a JsonSchema for )r/)r|r error_infos rIrhz1GenerateJsonSchema.handle_invalid_for_json_schema s*-Nzl+[\\rHcb|j||}|tj|tyy)zfThis method simply emits PydanticJsonSchemaWarnings based on handling in the `warning_message` method.N)render_warning_messager~rrB)r|kinddetailrs rIrzGenerateJsonSchema.emit_warning s.--dF;   MM'#< = rHc0||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)r|rrs rIrz)GenerateJsonSchema.render_warning_message s(" 4-- -D6##rHci}|jjD]3}|D],}t|jj |}|||<.5t j |j||jS)Nr)rrrLrr@rUrwrj)r|ri defs_refsrnrs rIrz/GenerateJsonSchema._build_definitions_remapping s/1 ::AAC 2I% 2"4#4#4#;#;(#;#KL)1 X& 2 2 %==  - -|T=M=M  rHct}t|}|r`|j} |j|}||vr'|j ||j t|j ||r`|j jDcic] \}}||vs ||c}}|_y#t$r|jdsYYwxYwcc}}wr) set_get_all_json_refsrraddrrjrr.r)r|rvisited_defs_refsunvisited_json_refs next_json_ref next_defs_refr r!s rIrz/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)rrVrrr)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]])r9)rrrrrr)rr4rrry)rrr str | Nonerr)rrrrrr)rzcore_schema.InvalidSchemarr)rzcore_schema.AnySchemarr)rzcore_schema.NoneSchemarr)rzcore_schema.BoolSchemarr)rzcore_schema.IntSchemarr)rzcore_schema.FloatSchemarr)rr5rr)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)rrmrr)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)rr3rrrr)rzcore_schema.TypedDictFieldrr)rzcore_schema.DataclassFieldrr)rzcore_schema.ModelFieldrr)rzcore_schema.ComputedFieldrr)rzcore_schema.ModelSchemarr)rrr^z type[Any]rr2rr)rrrr)rzcore_schema.ModelFieldsSchemarr)rr3rrV)rzPcore_schema.ModelField | core_schema.DataclassField | core_schema.TypedDictFieldrrVrrV)rzcore_schema.DataclassArgsSchemarr)rzcore_schema.DataclassSchemarr)rzcore_schema.ArgumentsSchemarr)rX$list[core_schema.ArgumentsParameter]rTCoreSchema | Nonerr)rXrrSrrr)razAcore_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)rr4rrV)r CoreModeRefrrK)rrJrztuple[DefsRef, JsonSchemaValue])rrLrr)rrrr)rrrrrzdict[str, str]rr)rrrzdict[JsonRef, int])rr4rrrr)rJsonSchemaWarningKindrrrr)rrrrrr)rrU)rrrr)orCrDrErFschema_dialectrrDEFAULT_REF_TEMPLATErpropertyr$rrrrrrr rrrrr"r%r8r6rCrFrJrLrPrYr\rerirkrnrtrrrrrrrrrrrrrrrrrrrrrrrrrrrrr rrrrr"rrr@rrrHrKrOrVrUr`rlrnrprr{r}rrlrrrr r rrrrrrrrrrrhrrrrrGrHrIrrs'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 5=~ 0O"4,"1H#J+%3+%ES+% +%Z @=& :1fT,T :TT %P 2* 5 5 5 <*O-b(.$$_  >I$(" H$=$Rc$ $L)=)Pa) )V$%N ? 5'"   45$ l 2"$ 6![F I./`)86  : E* E9C EN\ E  E  @ ""H]> $*  arHrTrr9cNddlm}||||}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#r7rrrzTmodel_json_schema() must be called on a subclass of BaseModel, not BaseModel itself.zthis is a bug! please report it)r) r+r8r__pydantic_core_schema__r)MockCoreSchemarebuildrr)r^rrrschema_generatorrr8schema_generator_instances rImodel_json_schemar s@ 0 <!#.. 0L0LM $$,,. istt#66 8T8TUxWxx U $ - -c.J.JQU - VVrH)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. rrYr_r`)rrr)rrr)modelsrr_r`rrrr^rinstancemrrrrjrs rImodels_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}wry)rb_make_json_hashabler)rrs rIrdrdG s/ 7K$V,f4KRRT UUKs2ct|tr)ttd|j DSt|t rtd|DS|S)Nc3<K|]\}}|t|fywryr)r]r r!s rIr`z&_make_json_hashable..M sRDAqQ 3A 67Rsc32K|]}t|ywryr)r]r!s rIr`z&_make_json_hashable..O s;(+;s)rrtupler rrb)rs rIrrK sH%VREKKMRRSS E4 ;U;;; rHcFeZdZUdZded<dZded< d dZd dZy) WithJsonSchemaac !!! abstract "Usage Documentation" [`WithJsonSchema` Annotation](../concepts/json_schema.md#withjsonschema-annotation) An annotation used to override the JSON Schema for a type. This is useful when you want to set a JSON Schema for a type that don't produce any JSON Schemas by default (e.g. [`Callable`][collections.abc.Callable]). If `mode` is set this will only apply to that schema generation mode, allowing you to set different JSON Schemas for validation and serialization. !!! note If the `WithJsonSchema` annotation is coupled with the [`Field()`][pydantic.Field] function, the behavior overriding will vary depending on the location: * If the [`Annotated`][typing.Annotated] metadata is specified at the "top-level" field, `Field()` metadata arguments (excluding [constraints](../concepts/fields.md#field-constraints)) such as `title` and `description` will be applied on top of the `WithJsonSchema`, no matter the order: ```python from typing import Annotated from pydantic import BaseModel, Field, WithJsonSchema class Model(BaseModel): field: Annotated[ int, Field(title='My Field'), WithJsonSchema({'type': 'integer', 'extra': 'data'}), ] Model.model_json_schema()['properties']['field'] #> {'type': 'integer', 'extra': 'data', 'title': 'My Field'} ``` * If the [`Annotated`][typing.Annotated] metadata is specified on a specific inner type, `WithJsonSchema` will unconditionally override the JSON Schema: ```python from typing import Annotated from pydantic import BaseModel, Field, WithJsonSchema class Model(BaseModel): field: list[ Annotated[ int, Field(title='My Field'), WithJsonSchema({'type': 'integer', 'extra': 'data'}), ] ] Model.model_json_schema()['properties']['field'] #> {'items': {'extra': 'data', 'type': 'integer'}, 'title': 'Field', 'type': 'array'} ``` See also the documentation about [the annotated pattern](../concepts/fields.md#the-annotated-pattern). rrN-Literal['validation', 'serialization'] | Nonerc|j!|j|jk7r||S|jt|jjSry)rrrrr|rhandlers rI__get_pydantic_json_schema__z+WithJsonSchema.__get_pydantic_json_schema__ sO 99 TYY',,%>;' '    # ##((* *rHc>tt|jSryhashrrrs rI__hash__zWithJsonSchema.__hash__ DO$$rHrzcore_schema.CoreSchemarr,rrrr)rCrDrErFrrrrrGrHrIr r T s=7r(':>D 7> +1 +Using a dict for `examples` is deprecated, use a list instead.rzr{)rrr~rr"rrrs rIrzExamples.__init__ s3 h % MMP)  !  rHc |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.) rrzrrrrrbr~r UserWarningr)r|rrrrrrexs rIrz%Examples.__get_pydantic_json_schema__ syy(GLLk* 7<<  ??:.  &8&GK # h %$--. J  +=%-__%6GEG2RGRG$--W+ J'+==Z=ZDMM=Z*[ J' h %$--.*tt|jSryrrs rIrzExamples.__hash__ rrHry)rdict[str, Any]rr rr)rz list[Any]rr rr)rzdict[str, Any] | list[Any]rr rrrr) rCrDrErFrrrrrrGrHrIrr swx^b&.[ yttko 2 :g   %1% sT35[) )rHctryr[rs rIrz+SkipJsonSchema.__get_pydantic_json_schema__A s  rHc*tt|Sry)rrrs rIrzSkipJsonSchema.__hash__F sT # #rHN)rr'rr')rrrr,rrr)rCrDrErFr+rrrGrHrIr)r) s/- ^ * ) 4H     $rHr)cX| tj|dSiS#t$rYiSwxYw)NrJ)r'get_attribute_from_basesr)r^s rIrrJ s@  77=RS S I   I s  ))c|jdx}r|ddk(r|jds|Stj|rt|dSy)zGet a `'function-plain'` serialization schema that can be used to serialize a default value. This takes into account having the serialization schema nested under validation schema(s). r:rrinfo_argrN)rzr&rr)rrs rIrrS s[ zz/2 2 2 v "2 2z*00801ABB9rHrG)r^z)type[BaseModel] | type[PydanticDataclass]rrVrrrrrtype[GenerateJsonSchema]rrrr")rzJSequence[tuple[type[BaseModel] | type[PydanticDataclass], JsonSchemaMode]]rrVr_rr`rrrrrrr2rzotuple[dict[tuple[type[BaseModel] | type[PydanticDataclass], JsonSchemaMode], JsonSchemaValue], JsonSchemaValue])rzIterable[JsonDict]rr)rr.rr)rrrz set[JsonRef])r^ztype[Any] | Nonerr2)rrrz3core_schema.PlainSerializerFunctionSerSchema | None)yrF __future__r _annotationscollections.abcr dataclassesrbrrrr~rrrrrrr rTr r typingr r rrrrrrrrrrrrrrpydantic_core.core_schemartyping_extensionsrrrrtyping_inspection.introspectionr pydantic.warningsr!r" _internalr$r%r&r'r(r)r*r+annotated_handlersr,rr-r.errorsr/r0r1rr2_internal._core_utilsr3r4r*r5#_internal._schema_generation_sharedr6r+r8CoreSchemaTypeCoreSchemaFieldTyperrrrrr=rrrrBrrrrJrKrLr rrMr dataclass slots_truerUrrrrr7rVrrdrr rrr'r)rrrGrHrIrEsk 3 ,88   \\3HH>R   5'bbI9J : :K<[<[ [\ sCx.67AHZb1c.c ef  H  )A )S ! )S ! )S !G^+, ):Q8,778RR9Rjo#ao#anG,>F1C' -W 2-W-W-W< -W / -W  -W-Wf",>F1C6) V6)6)  6)  6)  6)<6)/6)u6)x!&T4'@!A5sThOhIiknInCoo!I V8,778I%I%9I%XG%G%T8 ) w|,N[<0;;<9$9$=9$x CrH