File: allof_root_model_constraints_merge.py

package info (click to toggle)
python-datamodel-code-generator 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,052 kB
  • sloc: python: 29,621; makefile: 15
file content (162 lines) | stat: -rw-r--r-- 4,140 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# generated by datamodel-codegen:
#   filename:  allof_root_model_constraints.json
#   timestamp: 2019-07-26T00:00:00+00:00

from __future__ import annotations

from typing import Any, Dict, List, Optional

from pydantic import BaseModel, EmailStr, Field, conint, constr


class StringDatatype(BaseModel):
    __root__: constr(regex=r'^\S(.*\S)?$') = Field(
        ..., description='A base string type.'
    )


class ConstrainedStringDatatype(BaseModel):
    __root__: constr(regex=r'(?=^\S(.*\S)?$)(?=^[A-Z].*)', min_length=1) = Field(
        ..., description='A constrained string.'
    )


class IntegerDatatype(BaseModel):
    __root__: int = Field(..., description='A whole number.')


class NonNegativeIntegerDatatype(BaseModel):
    __root__: conint(ge=0) = Field(..., description='Non-negative integer.')


class BoundedIntegerDatatype(BaseModel):
    __root__: conint(ge=0, le=100) = Field(
        ..., description='Integer between 0 and 100.'
    )


class EmailDatatype(BaseModel):
    __root__: EmailStr = Field(..., description='Email with format.')


class FormattedStringDatatype(BaseModel):
    __root__: EmailStr = Field(..., description='A string with email format.')


class ObjectBase(BaseModel):
    id: Optional[int] = None


class ObjectWithAllOf(ObjectBase):
    name: Optional[str] = None


class MultiRefAllOf(BaseModel):
    pass


class NoConstraintAllOf(BaseModel):
    pass


class IncompatibleTypeAllOf(BaseModel):
    pass


class ConstraintWithProperties(BaseModel):
    extra: Optional[str] = None


class ConstraintWithItems(BaseModel):
    pass


class NumberIntegerCompatible(BaseModel):
    __root__: conint(ge=0) = Field(
        ..., description='Number and integer are compatible.'
    )


class RefWithSchemaKeywords(BaseModel):
    __root__: constr(regex=r'^\S(.*\S)?$', min_length=5, max_length=100) = Field(
        ..., description='Ref with additional schema keywords.'
    )


class ArrayDatatype(BaseModel):
    __root__: List[str]


class RefToArrayAllOf(BaseModel):
    pass


class ObjectNoPropsDatatype(BaseModel):
    pass


class RefToObjectNoPropsAllOf(ObjectNoPropsDatatype):
    pass


class PatternPropsDatatype(BaseModel):
    __root__: Dict[constr(regex=r'^S_'), str]


class RefToPatternPropsAllOf(BaseModel):
    pass


class NestedAllOfDatatype(BaseModel):
    pass


class RefToNestedAllOfAllOf(NestedAllOfDatatype):
    pass


class ConstraintsOnlyDatatype(BaseModel):
    __root__: Any = Field(..., description='Constraints only, no type.')


class RefToConstraintsOnlyAllOf(BaseModel):
    __root__: Any = Field(..., description='Ref to constraints-only schema.')


class NoDescriptionAllOf(BaseModel):
    __root__: constr(regex=r'^\S(.*\S)?$', min_length=5) = Field(
        ..., description='A base string type.'
    )


class EmptyConstraintItemAllOf(BaseModel):
    __root__: constr(regex=r'^\S(.*\S)?$', max_length=50) = Field(
        ..., description='AllOf with empty constraint item.'
    )


class ConflictingFormatAllOf(BaseModel):
    pass


class Model(BaseModel):
    name: Optional[ConstrainedStringDatatype] = None
    count: Optional[NonNegativeIntegerDatatype] = None
    percentage: Optional[BoundedIntegerDatatype] = None
    email: Optional[EmailDatatype] = None
    obj: Optional[ObjectWithAllOf] = None
    multi: Optional[MultiRefAllOf] = None
    noconstraint: Optional[NoConstraintAllOf] = None
    incompatible: Optional[IncompatibleTypeAllOf] = None
    withprops: Optional[ConstraintWithProperties] = None
    withitems: Optional[ConstraintWithItems] = None
    numint: Optional[NumberIntegerCompatible] = None
    refwithkw: Optional[RefWithSchemaKeywords] = None
    refarr: Optional[RefToArrayAllOf] = None
    refobjnoprops: Optional[RefToObjectNoPropsAllOf] = None
    refpatternprops: Optional[RefToPatternPropsAllOf] = None
    refnestedallof: Optional[RefToNestedAllOfAllOf] = None
    refconstraintsonly: Optional[RefToConstraintsOnlyAllOf] = None
    nodescription: Optional[NoDescriptionAllOf] = None
    emptyconstraint: Optional[EmptyConstraintItemAllOf] = None
    conflictingformat: Optional[ConflictingFormatAllOf] = None