Generates 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.
(self, schema: core_schema.LaxOrStrictSchema)
| 1421 | return self.generate_inner(schema['steps'][step_index]) |
| 1422 | |
| 1423 | def lax_or_strict_schema(self, schema: core_schema.LaxOrStrictSchema) -> JsonSchemaValue: |
| 1424 | """Generates a JSON schema that matches a schema that allows values matching either the lax schema or the |
| 1425 | strict schema. |
| 1426 | |
| 1427 | Args: |
| 1428 | schema: The core schema. |
| 1429 | |
| 1430 | Returns: |
| 1431 | The generated JSON schema. |
| 1432 | """ |
| 1433 | # TODO: Need to read the default value off of model config or whatever |
| 1434 | use_strict = schema.get('strict', False) # TODO: replace this default False |
| 1435 | # If your JSON schema fails to generate it is probably |
| 1436 | # because one of the following two branches failed. |
| 1437 | if use_strict: |
| 1438 | return self.generate_inner(schema['strict_schema']) |
| 1439 | else: |
| 1440 | return self.generate_inner(schema['lax_schema']) |
| 1441 | |
| 1442 | def json_or_python_schema(self, schema: core_schema.JsonOrPythonSchema) -> JsonSchemaValue: |
| 1443 | """Generates a JSON schema that matches a schema that allows values matching either the JSON schema or the |