-
-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add duplicate field constraints test case
- Loading branch information
Showing
6 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/data/expected/main/duplicate_field_constraints/common.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# generated by datamodel-codegen: | ||
# filename: common.yml | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Any | ||
|
||
from pydantic import RootModel | ||
|
||
|
||
class Model(RootModel[Any]): | ||
root: Any |
15 changes: 15 additions & 0 deletions
15
tests/data/expected/main/duplicate_field_constraints/test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# generated by datamodel-codegen: | ||
# filename: test.yml | ||
# timestamp: 2019-07-26T00:00:00+00:00 | ||
|
||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel, Field, constr | ||
|
||
from . import common | ||
|
||
|
||
class Test(BaseModel): | ||
uid: constr(pattern=r'[0-9ABCDEFGHJKMNPQRSTVWXYZ]{26,26}') = Field( | ||
..., description='ulid of this object' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
$schema: https://json-schema.org/draft/2020-12/schema | ||
$id: common.yml | ||
definitions: | ||
ulid: | ||
type: string | ||
pattern: '[0-9ABCDEFGHJKMNPQRSTVWXYZ]{26,26}' |
10 changes: 10 additions & 0 deletions
10
tests/data/jsonschema/duplicate_field_constraints/test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
$schema: https://json-schema.org/draft/2020-12/schema | ||
$id: test.yml | ||
title: test | ||
required: | ||
- uid | ||
properties: | ||
uid: | ||
description: ulid of this object | ||
$ref: ./common.yml#/definitions/ulid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters