From 3743824112ecc91e0b04d8ad49a376cfbfa1329e Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Tue, 12 Sep 2023 11:51:27 +0000 Subject: [PATCH] Fix Pydantic URLs --- README.md | 4 ++-- docs/api_reference/bson.md | 2 +- docs/fields.md | 12 ++++++------ docs/modeling.md | 8 ++++---- docs/usage_fastapi.md | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8e990636..fd806740 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Sync and Async ODM (Object Document Mapper) for MongoDB based on standard python type hints. Built on top of pydantic for model +href="https://docs.pydantic.dev/" target="_blank">pydantic for model definition and validation. Core features: @@ -294,7 +294,7 @@ lulu.founded = 1000 This will raise an exception as it's not matching the model definition. The raised exception is actually a `ValidationError` created by from pydantic. ### Next steps diff --git a/docs/api_reference/bson.md b/docs/api_reference/bson.md index 4b18f836..6cc44fd0 100644 --- a/docs/api_reference/bson.md +++ b/docs/api_reference/bson.md @@ -9,7 +9,7 @@ This module provides helpers to build Pydantic Models containing BSON objects. ::: odmantic.bson.BSON_TYPES_ENCODERS -Encoders required to encode BSON fields (can be used in the Pydantic Model's `Config.json_encoders` parameter). See [pydantic: JSON Encoders](https://pydantic-docs.helpmanual.io/usage/exporting_models/#json_encoders){:target=blank_} for more details. +Encoders required to encode BSON fields (can be used in the Pydantic Model's `Config.json_encoders` parameter). See [pydantic: JSON Encoders](https://docs.pydantic.dev/latest/api/config/#pydantic.config.ConfigDict.json_encoders){:target=blank_} for more details. ## Pydantic type helpers diff --git a/docs/fields.md b/docs/fields.md index bf7893d8..206853ad 100644 --- a/docs/fields.md +++ b/docs/fields.md @@ -66,7 +66,7 @@ To define choices, it's possible to use the standard `enum` classes: { "_id" : ObjectId("5f818f2dd5708527282c49b7"), "kind" : "small", "name" : "Spruce" } ``` -If you try to use a value not present in the allowed choices, a [ValidationError](https://pydantic-docs.helpmanual.io/usage/models/#error-handling){:target=blank_} exception will be raised. +If you try to use a value not present in the allowed choices, a [ValidationError](https://docs.pydantic.dev/latest/usage/models/#error-handling){:target=blank_} exception will be raised. !!! warning "Usage of `enum.auto`" If you might add some values to an `Enum`, it's strongly recommended not to use the @@ -158,7 +158,7 @@ Those types can be used directly as field types: ### Pydantic fields Most of the types supported by pydantic are supported by ODMantic. See [pydantic: -Field Types](https://pydantic-docs.helpmanual.io/usage/types){:target=bank_} for more +Field Types](https://docs.pydantic.dev/latest/usage/types/types/){:target=bank_} for more field types. Unsupported fields: @@ -210,7 +210,7 @@ descriptor using the `default` keyword argument. Currently the default values are not validated yet during the model creation. An inconsistent default value might raise a - [ValidationError](https://pydantic-docs.helpmanual.io/usage/models/#error-handling){:target=blank_} + [ValidationError](https://docs.pydantic.dev/latest/usage/models/#error-handling){:target=blank_} while building an instance. ### Document structure @@ -302,13 +302,13 @@ validation features provided by pydantic are available: --8<-- "fields/validation_field_descriptor.py" ``` -- Use strict types to prevent to coercion from compatible types ([pydantic: Strict Types](https://pydantic-docs.helpmanual.io/usage/types/#strict-types){:target=blank_}) +- Use strict types to prevent to coercion from compatible types ([pydantic: Strict Types](https://docs.pydantic.dev/latest/usage/types/strict_types/){:target=blank_}) ```python linenums="1" --8<-- "fields/validation_strict_types.py" ``` - Define custom field validators ([pydantic: - Validators](https://pydantic-docs.helpmanual.io/usage/validators/){:target=blank_}) + Validators](https://docs.pydantic.dev/latest/usage/validators/){:target=blank_}) ```python linenums="1" --8<-- "fields/custom_field_validators.py" ``` @@ -316,7 +316,7 @@ validation features provided by pydantic are available: - Define custom model validators: [more details](modeling.md#custom-model-validators) ## Custom field types -Exactly in the same way pydantic allows it, it's possible to define custom field types as well with ODMantic ([pydantic: Custom data types](https://pydantic-docs.helpmanual.io/usage/types/#custom-data-types){:target=blank_}). +Exactly in the same way pydantic allows it, it's possible to define custom field types as well with ODMantic ([pydantic: Custom data types](https://docs.pydantic.dev/latest/usage/types/types/){:target=blank_}). Sometimes, it might be required to customize as well the field BSON serialization. In order to do this, the field class will have to implement the `__bson__` class method. diff --git a/docs/modeling.md b/docs/modeling.md index bd167abc..6f597ba2 100644 --- a/docs/modeling.md +++ b/docs/modeling.md @@ -121,7 +121,7 @@ For example, defining a [text index](https://www.mongodb.com/docs/manual/core/in Exactly as done with pydantic, it's possible to define custom model validators as described in the [pydantic: Root -Validators](https://pydantic-docs.helpmanual.io/usage/validators/#root-validators){:target=blank_} +Validators](https://docs.pydantic.dev/latest/usage/validators/){:target=blank_} documentation (this apply as well to Embedded Models). In the following example, we will define a rectangle class and add two validators: The @@ -140,7 +140,7 @@ ensure that the area of the rectangle is less or equal to 9. ### Advanced Configuration The model configuration is done in the same way as with Pydantic models: using a [Config -class](https://pydantic-docs.helpmanual.io/usage/model_config/){:target=blank_} defined +class](https://docs.pydantic.dev/latest/usage/model_config/){:target=blank_} defined in the model body. **Available options**: @@ -170,7 +170,7 @@ in the model body. `#!python schema_extra: dict` *(inherited from Pydantic)* : A dict used to extend/update the generated JSON Schema, or a callable to - post-process it. See [Pydantic: Schema customization](https://pydantic-docs.helpmanual.io/usage/schema/#schema-customization){:target=_blank} for more details. + post-process it. See [Pydantic: Schema customization](https://docs.pydantic.dev/latest/usage/json_schema/#schema-customization){:target=_blank} for more details. Default: `#!python {}` @@ -216,7 +216,7 @@ in the model body. For more details and examples about the options inherited from Pydantic, you can have a look to [Pydantic: Model -Config](https://pydantic-docs.helpmanual.io/usage/model_config/){:target=blank_} +Config](https://docs.pydantic.dev/latest/usage/model_config/){:target=blank_} !!! warning Only the options described above are supported and other options from Pydantic can't diff --git a/docs/usage_fastapi.md b/docs/usage_fastapi.md index facede02..d89a5b4d 100644 --- a/docs/usage_fastapi.md +++ b/docs/usage_fastapi.md @@ -278,7 +278,7 @@ the error. {"detail":[{"loc":["body","average_size"],"msg":"field required","type":"value_error.missing"}]}% ``` The validation error structure is the one that is defined by the [Pydantic: - ValidationError](https://pydantic-docs.helpmanual.io/usage/models/#error-handling){:target=blank_} + ValidationError](https://docs.pydantic.dev/latest/usage/models/#error-handling){:target=blank_} exception. Finally, specifying the `response_model` in the `app.put` decorator is not @@ -712,7 +712,7 @@ We can then finish by saving and returning the updated tree. : this field is **required** and an `int` value **must** be provided (More details: [pydantic #1223](https://github.com/samuelcolvin/pydantic/issues/1223#issuecomment-594632324){:target=blank_}, - [pydantic: Required fields](https://pydantic-docs.helpmanual.io/usage/models/#required-fields){:target=blank_}) + [pydantic: Required fields](https://docs.pydantic.dev/latest/usage/models/#required-fields){:target=blank_}) By default [Model.update][odmantic.model._BaseODMModel.update], will not apply values from unset (not explicitely populated) fields. Since we don't want to allow