Skip to content

Commit 5e96a30

Browse files
committed
Better solution to the allow* field issue: move them from ParameterBase to Parameter.
1 parent b7a118f commit 5e96a30

File tree

2 files changed

+40
-52
lines changed

2 files changed

+40
-52
lines changed

openapi_pydantic/v3/v3_0_3/parameter.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,6 @@ class ParameterBase(BaseModel):
104104
Default value is `false`.
105105
"""
106106

107-
allowEmptyValue: Optional[bool] = None
108-
"""
109-
Sets the ability to pass empty-valued parameters.
110-
This is valid only for `query` parameters and allows sending a parameter with an
111-
empty value. Default value is `false`.
112-
If [`style`](#parameterStyle) is used, and if behavior is `n/a` (cannot be
113-
serialized), the value of `allowEmptyValue` SHALL be ignored.
114-
Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later
115-
revision.
116-
"""
117-
118-
"""
119-
The rules for serialization of the parameter are specified in one of two ways.
120-
For simpler scenarios, a [`schema`](#parameterSchema) and [`style`](#parameterStyle)
121-
can describe the structure and syntax of the parameter.
122-
"""
123-
124107
style: Optional[str] = None
125108
"""
126109
Describes how the parameter value will be serialized depending on the type of the
@@ -141,15 +124,6 @@ class ParameterBase(BaseModel):
141124
For all other styles, the default value is `false`.
142125
"""
143126

144-
allowReserved: Optional[bool] = None
145-
"""
146-
Determines whether the parameter value SHOULD allow reserved characters,
147-
as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2)
148-
`:/?#[]@!$&'()*+,;=` to be included without percent-encoding.
149-
This property only applies to parameters with an `in` value of `query`.
150-
The default value is `false`.
151-
"""
152-
153127
param_schema: Optional[Union[Reference, Schema]] = Field(
154128
default=None, alias="schema"
155129
)
@@ -238,3 +212,23 @@ class Parameter(ParameterBase):
238212
**REQUIRED**. The location of the parameter. Possible values are `"query"`,
239213
`"header"`, `"path"` or `"cookie"`.
240214
"""
215+
216+
allowEmptyValue: bool = False
217+
"""
218+
Sets the ability to pass empty-valued parameters.
219+
This is valid only for `query` parameters and allows sending a parameter with an
220+
empty value. Default value is `false`.
221+
If [`style`](#parameterStyle) is used, and if behavior is `n/a` (cannot be
222+
serialized), the value of `allowEmptyValue` SHALL be ignored.
223+
Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later
224+
revision.
225+
"""
226+
227+
allowReserved: bool = False
228+
"""
229+
Determines whether the parameter value SHOULD allow reserved characters,
230+
as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2)
231+
`:/?#[]@!$&'()*+,;=` to be included without percent-encoding.
232+
This property only applies to parameters with an `in` value of `query`.
233+
The default value is `false`.
234+
"""

openapi_pydantic/v3/v3_1_0/parameter.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -104,23 +104,6 @@ class ParameterBase(BaseModel):
104104
Default value is `false`.
105105
"""
106106

107-
allowEmptyValue: Optional[bool] = None
108-
"""
109-
Sets the ability to pass empty-valued parameters.
110-
This is valid only for `query` parameters and allows sending a parameter with an
111-
empty value. Default value is `false`.
112-
If [`style`](#parameterStyle) is used, and if behavior is `n/a` (cannot be
113-
serialized), the value of `allowEmptyValue` SHALL be ignored.
114-
Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later
115-
revision.
116-
"""
117-
118-
"""
119-
The rules for serialization of the parameter are specified in one of two ways.
120-
For simpler scenarios, a [`schema`](#parameterSchema) and [`style`](#parameterStyle)
121-
can describe the structure and syntax of the parameter.
122-
"""
123-
124107
style: Optional[str] = None
125108
"""
126109
Describes how the parameter value will be serialized depending on the type of the
@@ -141,15 +124,6 @@ class ParameterBase(BaseModel):
141124
For all other styles, the default value is `false`.
142125
"""
143126

144-
allowReserved: Optional[bool] = None
145-
"""
146-
Determines whether the parameter value SHOULD allow reserved characters,
147-
as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2)
148-
`:/?#[]@!$&'()*+,;=` to be included without percent-encoding.
149-
This property only applies to parameters with an `in` value of `query`.
150-
The default value is `false`.
151-
"""
152-
153127
param_schema: Optional[Union[Schema, Reference]] = Field(
154128
default=None, alias="schema"
155129
)
@@ -239,3 +213,23 @@ class Parameter(ParameterBase):
239213
**REQUIRED**. The location of the parameter. Possible values are `"query"`,
240214
`"header"`, `"path"` or `"cookie"`.
241215
"""
216+
217+
allowEmptyValue: bool = False
218+
"""
219+
Sets the ability to pass empty-valued parameters.
220+
This is valid only for `query` parameters and allows sending a parameter with an
221+
empty value. Default value is `false`.
222+
If [`style`](#parameterStyle) is used, and if behavior is `n/a` (cannot be
223+
serialized), the value of `allowEmptyValue` SHALL be ignored.
224+
Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later
225+
revision.
226+
"""
227+
228+
allowReserved: bool = False
229+
"""
230+
Determines whether the parameter value SHOULD allow reserved characters,
231+
as defined by [RFC3986](https://tools.ietf.org/html/rfc3986#section-2.2)
232+
`:/?#[]@!$&'()*+,;=` to be included without percent-encoding.
233+
This property only applies to parameters with an `in` value of `query`.
234+
The default value is `false`.
235+
"""

0 commit comments

Comments
 (0)