Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/generators/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|buildSystem|Build system to use in pyproject.toml (setuptools, hatchling).| |setuptools|
|compatibleWithPythonLegacy|Enable compatibility with python-legacy. Currently, generated model field aliases preserve normalized Python constructor names while accepting wire names, and to_dict() emits every declared field, using None for missing attributes, under public names by default and wire names with serialize=True. Generic models expose openapi_types and attribute_map, reject unknown constructor keys, and use legacy display and equality helpers. Container conversion is limited to immediate list elements and dictionary values, matching python-legacy. Synchronous urllib3 operations keep async_req, _preload_content, tuple with_http_info() behavior, and integer _request_timeout inputs. JSON and request serialization remain unchanged.| |false|
|dateFormat|date format for query parameters| |%Y-%m-%d|
|datetimeFormat|datetime format for query parameters| |%Y-%m-%dT%H:%M:%S%z|
|datetimeFormat|datetime format for query parameters. If not set, datetime.isoformat() is used, which is RFC 3339 compliant.| |null|
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
|generateSourceCodeOnly|Specifies that only a library source code is to be generated.| |false|
|hideGenerationTimestamp|Hides the generation timestamp when files are generated.| |true|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
protected String apiDocPath = "docs/";
protected String modelDocPath = "docs/";
@Setter protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
@Setter protected String datetimeFormat = "%Y-%m-%dT%H:%M:%S.%f%z";
@Setter protected String datetimeFormat = null;
@Setter protected String dateFormat = "%Y-%m-%d";
@Setter protected boolean setEnsureAsciiToFalse = false;
@Setter protected boolean useIndependentImplicitClients = false;
Expand Down Expand Up @@ -221,8 +221,7 @@ public PythonClientCodegen() {
cliOptions.add(new CliOption(RECURSION_LIMIT, "Set the recursion limit. If not set, use the system default value."));
cliOptions.add(new CliOption(MAP_NUMBER_TO, "Map number to Union[StrictFloat, StrictInt], StrictFloat, float or Decimal.")
.defaultValue("Union[StrictFloat, StrictInt]"));
cliOptions.add(new CliOption(DATETIME_FORMAT, "datetime format for query parameters")
.defaultValue("%Y-%m-%dT%H:%M:%S%z"));
cliOptions.add(new CliOption(DATETIME_FORMAT, "datetime format for query parameters. If not set, datetime.isoformat() is used, which is RFC 3339 compliant."));
cliOptions.add(new CliOption(DATE_FORMAT, "date format for query parameters")
.defaultValue("%Y-%m-%d"));
cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC).defaultValue("false"));
Expand Down Expand Up @@ -356,7 +355,7 @@ public void processOpts() {

if (additionalProperties.containsKey(DATETIME_FORMAT)) {
setDatetimeFormat((String) additionalProperties.get(DATETIME_FORMAT));
} else {
} else if (datetimeFormat != null) {
additionalProperties.put(DATETIME_FORMAT, datetimeFormat);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb
_query_params.append(
(
'{{baseName}}',
{{paramName}}.strftime(
{{paramName}}.isoformat()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Naive datetime arguments reach this branch and isoformat() omits their offset, so the default still emits a non-RFC 3339 value. Require timezone-aware datetimes before serialization.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/resources/python/api.mustache, line 328:

<comment>Naive datetime arguments reach this branch and `isoformat()` omits their offset, so the default still emits a non-RFC 3339 value. Require timezone-aware datetimes before serialization.</comment>

<file context>
@@ -325,7 +325,9 @@ https://github.com/OpenAPITools/openapi-generator/blob/c84b949df1a9ec04ba75989cb
                     (
                         '{{baseName}}',
-                        {{paramName}}.strftime(
+                        {{paramName}}.isoformat()
+                        if self.api_client.configuration.datetime_format is None
+                        else {{paramName}}.strftime(
</file context>

if self.api_client.configuration.datetime_format is None
else {{paramName}}.strftime(
self.api_client.configuration.datetime_format
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class Configuration:
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
If None, datetime.isoformat() is used, which is RFC 3339 compliant.
:param date_format: Date format string for serialization.

{{#hasAuthMethods}}
Expand Down Expand Up @@ -373,7 +374,7 @@ conf = {{{packageName}}}.Configuration(
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
datetime_format: str="{{{datetimeFormat}}}",
datetime_format: Optional[str]={{#datetimeFormat}}"{{{.}}}"{{/datetimeFormat}}{{^datetimeFormat}}None{{/datetimeFormat}},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The default isoformat() path does not guarantee RFC 3339: naive datetimes omit the required UTC offset. Require or normalize timezone-aware values before serialization, or document the limitation.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At modules/openapi-generator/src/main/resources/python/configuration.mustache, line 377:

<comment>The default `isoformat()` path does not guarantee RFC 3339: naive datetimes omit the required UTC offset. Require or normalize timezone-aware values before serialization, or document the limitation.</comment>

<file context>
@@ -373,7 +374,7 @@ conf = {{{packageName}}}.Configuration(
         client_side_validation: bool=True,
         socket_options: Optional[Any]=None,
-        datetime_format: str="{{{datetimeFormat}}}",
+        datetime_format: Optional[str]={{#datetimeFormat}}"{{{.}}}"{{/datetimeFormat}}{{^datetimeFormat}}None{{/datetimeFormat}},
         date_format: str="{{{dateFormat}}}",
         *,
</file context>

date_format: str="{{{dateFormat}}}",
*,
debug: Optional[bool] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,40 @@ public void testHttpx2Generation(boolean sync, Object poetry1, String backend) t
Assert.assertFalse(Files.readString(Paths.get(output, "requirements.txt")).contains("httpx >="));
}

@Test
public void testDatetimeQueryParamDefaultsToIsoformat() throws IOException {
final PythonClientCodegen codegen = new PythonClientCodegen();
final String output = generateFiles(codegen, "src/test/resources/3_0/echo_api.yaml");

// strftime's %z renders +0000; RFC 3339 requires +00:00, which isoformat() emits.
assertFileContains(Paths.get(output, "openapi_client/configuration.py"),
"datetime_format: Optional[str]=None,");
assertFileContains(Paths.get(output, "openapi_client/api/query_api.py"),
"datetime_query.isoformat()",
"if self.api_client.configuration.datetime_format is None");
Assert.assertNull(codegen.additionalProperties().get(PythonClientCodegen.DATETIME_FORMAT));
}

@Test
public void testDatetimeFormatSetterIsStillHonoured() throws IOException {
final PythonClientCodegen codegen = new PythonClientCodegen();
codegen.setDatetimeFormat("%Y-%m-%dT%H:%M:%SZ");
final String output = generateFiles(codegen, "src/test/resources/3_0/echo_api.yaml");

assertFileContains(Paths.get(output, "openapi_client/configuration.py"),
"datetime_format: Optional[str]=\"%Y-%m-%dT%H:%M:%SZ\",");
}

@Test
public void testDatetimeFormatOptionIsStillHonoured() throws IOException {
final PythonClientCodegen codegen = new PythonClientCodegen();
codegen.additionalProperties().put(PythonClientCodegen.DATETIME_FORMAT, "%Y-%m-%dT%H:%M:%SZ");
final String output = generateFiles(codegen, "src/test/resources/3_0/echo_api.yaml");

assertFileContains(Paths.get(output, "openapi_client/configuration.py"),
"datetime_format: Optional[str]=\"%Y-%m-%dT%H:%M:%SZ\",");
}

@Test
public void testInitialConfigValues() throws Exception {
final PythonClientCodegen codegen = new PythonClientCodegen();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,9 @@ def _test_query_datetime_date_string_serialize(
_query_params.append(
(
'datetime_query',
datetime_query.strftime(
datetime_query.isoformat()
if self.api_client.configuration.datetime_format is None
else datetime_query.strftime(
self.api_client.configuration.datetime_format
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class Configuration:
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
If None, datetime.isoformat() is used, which is RFC 3339 compliant.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: datetime.isoformat() omits the UTC offset for naive datetimes, so this default does not always produce RFC 3339; the query serializer accepts naive values without validation. Require timezone-aware values or qualify/handle the naive case instead of promising RFC 3339 compliance.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/openapi_client/configuration.py, line 184:

<comment>`datetime.isoformat()` omits the UTC offset for naive datetimes, so this default does not always produce RFC 3339; the query serializer accepts naive values without validation. Require timezone-aware values or qualify/handle the naive case instead of promising RFC 3339 compliance.</comment>

<file context>
@@ -181,6 +181,7 @@ class Configuration:
     :param client_side_validation: Enable client-side validation. Default True.
     :param socket_options: Options to pass down to the underlying urllib3 socket.
     :param datetime_format: Datetime format string for serialization.
+      If None, datetime.isoformat() is used, which is RFC 3339 compliant.
     :param date_format: Date format string for serialization.
 
</file context>

:param date_format: Date format string for serialization.

:Example:
Expand Down Expand Up @@ -233,7 +234,7 @@ def __init__(
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
datetime_format: Optional[str]=None,
date_format: str="%Y-%m-%d",
*,
debug: Optional[bool] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def testDateTimeQueryWithDateTime(self):
# Test query parameter(s)
api_response = api_instance.test_query_datetime_date_string(datetime_query=datetime_query, date_query=date_query, string_query=string_query)
e = EchoServerResponseParser(api_response)
self.assertEqual(e.path, "/query/datetime/date/string?datetime_query=2013-10-20T19%3A20%3A30.000000-0500&date_query=2013-10-20&string_query=string_query_example")
self.assertEqual(e.path, "/query/datetime/date/string?datetime_query=2013-10-20T19%3A20%3A30-05%3A00&date_query=2013-10-20&string_query=string_query_example")

def testBinaryGif(self):
api_instance = openapi_client.BodyApi()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,9 @@ def _test_query_datetime_date_string_serialize(
_query_params.append(
(
'datetime_query',
datetime_query.strftime(
datetime_query.isoformat()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Naive datetime inputs are accepted here, but isoformat() emits them without a timezone offset, so the default is not RFC 3339 for those values. Require timezone-aware inputs or define an explicit timezone policy before serializing them.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/echo_api/python/openapi_client/api/query_api.py, line 576:

<comment>Naive `datetime` inputs are accepted here, but `isoformat()` emits them without a timezone offset, so the default is not RFC 3339 for those values. Require timezone-aware inputs or define an explicit timezone policy before serializing them.</comment>

<file context>
@@ -573,7 +573,9 @@ def _test_query_datetime_date_string_serialize(
                     (
                         'datetime_query',
-                        datetime_query.strftime(
+                        datetime_query.isoformat()
+                        if self.api_client.configuration.datetime_format is None
+                        else datetime_query.strftime(
</file context>

if self.api_client.configuration.datetime_format is None
else datetime_query.strftime(
self.api_client.configuration.datetime_format
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class Configuration:
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
If None, datetime.isoformat() is used, which is RFC 3339 compliant.
:param date_format: Date format string for serialization.

:Example:
Expand Down Expand Up @@ -233,7 +234,7 @@ def __init__(
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
datetime_format: Optional[str]=None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The new default does not guarantee RFC 3339 for naive datetime values: datetime.isoformat() emits no UTC offset, and the generated query method accepts naive datetimes. Reject naive values or define an explicit timezone policy before treating this serialization as RFC-compliant.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/client/echo_api/python/openapi_client/configuration.py, line 237:

<comment>The new default does not guarantee RFC 3339 for naive `datetime` values: `datetime.isoformat()` emits no UTC offset, and the generated query method accepts naive datetimes. Reject naive values or define an explicit timezone policy before treating this serialization as RFC-compliant.</comment>

<file context>
@@ -233,7 +234,7 @@ def __init__(
         client_side_validation: bool=True,
         socket_options: Optional[Any]=None,
-        datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
+        datetime_format: Optional[str]=None,
         date_format: str="%Y-%m-%d",
         *,
</file context>

date_format: str="%Y-%m-%d",
*,
debug: Optional[bool] = None,
Expand Down
2 changes: 1 addition & 1 deletion samples/client/echo_api/python/tests/test_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def testDateTimeQueryWithDateTime(self):
# Test query parameter(s)
api_response = api_instance.test_query_datetime_date_string(datetime_query=datetime_query, date_query=date_query, string_query=string_query)
e = EchoServerResponseParser(api_response)
self.assertEqual(e.path, "/query/datetime/date/string?datetime_query=2013-10-20T19%3A20%3A30.000000-0500&date_query=2013-10-20&string_query=string_query_example")
self.assertEqual(e.path, "/query/datetime/date/string?datetime_query=2013-10-20T19%3A20%3A30-05%3A00&date_query=2013-10-20&string_query=string_query_example")

def testStringEnum(self):
api_instance = openapi_client.BodyApi()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class Configuration:
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
If None, datetime.isoformat() is used, which is RFC 3339 compliant.
:param date_format: Date format string for serialization.

"""
Expand Down Expand Up @@ -213,7 +214,7 @@ def __init__(
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
datetime_format: Optional[str]=None,
date_format: str="%Y-%m-%d",
*,
debug: Optional[bool] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6777,7 +6777,9 @@ def _test_date_time_query_parameter_serialize(
_query_params.append(
(
'date_time_query',
date_time_query.strftime(
date_time_query.isoformat()
if self.api_client.configuration.datetime_format is None
else date_time_query.strftime(
self.api_client.configuration.datetime_format
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class Configuration:
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
If None, datetime.isoformat() is used, which is RFC 3339 compliant.
:param date_format: Date format string for serialization.

:Example:
Expand Down Expand Up @@ -304,7 +305,7 @@ def __init__(
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
datetime_format: Optional[str]=None,
date_format: str="%Y-%m-%d",
*,
debug: Optional[bool] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9375,7 +9375,9 @@ def _test_date_time_query_parameter_serialize(
_query_params.append(
(
'date_time_query',
date_time_query.strftime(
date_time_query.isoformat()
if self.api_client.configuration.datetime_format is None
else date_time_query.strftime(
self.api_client.configuration.datetime_format
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class Configuration:
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
If None, datetime.isoformat() is used, which is RFC 3339 compliant.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Naive datetime values still serialize without a UTC offset, so this default does not produce RFC 3339 timestamps for those callers. Reject naive values or normalize them to an explicit timezone before serialization.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/openapi3/client/petstore/python-httpx-sync/petstore_api/configuration.py, line 184:

<comment>Naive `datetime` values still serialize without a UTC offset, so this default does not produce RFC 3339 timestamps for those callers. Reject naive values or normalize them to an explicit timezone before serialization.</comment>

<file context>
@@ -181,6 +181,7 @@ class Configuration:
     :param client_side_validation: Enable client-side validation. Default True.
     :param socket_options: Options to pass down to the underlying urllib3 socket.
     :param datetime_format: Datetime format string for serialization.
+      If None, datetime.isoformat() is used, which is RFC 3339 compliant.
     :param date_format: Date format string for serialization.
 
</file context>

:param date_format: Date format string for serialization.

:Example:
Expand Down Expand Up @@ -290,7 +291,7 @@ def __init__(
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
datetime_format: Optional[str]=None,
date_format: str="%Y-%m-%d",
*,
debug: Optional[bool] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6758,7 +6758,9 @@ def _test_date_time_query_parameter_serialize(
_query_params.append(
(
'date_time_query',
date_time_query.strftime(
date_time_query.isoformat()
if self.api_client.configuration.datetime_format is None
else date_time_query.strftime(
self.api_client.configuration.datetime_format
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class Configuration:
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
If None, datetime.isoformat() is used, which is RFC 3339 compliant.
:param date_format: Date format string for serialization.

:Example:
Expand Down Expand Up @@ -290,7 +291,7 @@ def __init__(
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
datetime_format: Optional[str]=None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Naive datetime values still serialize without a timezone offset, so the new default does not always produce RFC 3339. Reject naive values or document that callers must supply timezone-aware datetimes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/openapi3/client/petstore/python-httpx/petstore_api/configuration.py, line 294:

<comment>Naive `datetime` values still serialize without a timezone offset, so the new default does not always produce RFC 3339. Reject naive values or document that callers must supply timezone-aware datetimes.</comment>

<file context>
@@ -290,7 +291,7 @@ def __init__(
         client_side_validation: bool=True,
         socket_options: Optional[Any]=None,
-        datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
+        datetime_format: Optional[str]=None,
         date_format: str="%Y-%m-%d",
         *,
</file context>

date_format: str="%Y-%m-%d",
*,
debug: Optional[bool] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9375,7 +9375,9 @@ def _test_date_time_query_parameter_serialize(
_query_params.append(
(
'date_time_query',
date_time_query.strftime(
date_time_query.isoformat()
if self.api_client.configuration.datetime_format is None
else date_time_query.strftime(
self.api_client.configuration.datetime_format
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class Configuration:
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
If None, datetime.isoformat() is used, which is RFC 3339 compliant.
:param date_format: Date format string for serialization.

:Example:
Expand Down Expand Up @@ -290,7 +291,7 @@ def __init__(
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
datetime_format: Optional[str]=None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The None default routes naive datetime values through isoformat(), which emits no UTC offset and is not RFC 3339. Reject or normalize naive values before enabling this default.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/openapi3/client/petstore/python-httpx2-sync/petstore_api/configuration.py, line 294:

<comment>The `None` default routes naive `datetime` values through `isoformat()`, which emits no UTC offset and is not RFC 3339. Reject or normalize naive values before enabling this default.</comment>

<file context>
@@ -290,7 +291,7 @@ def __init__(
         client_side_validation: bool=True,
         socket_options: Optional[Any]=None,
-        datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
+        datetime_format: Optional[str]=None,
         date_format: str="%Y-%m-%d",
         *,
</file context>

date_format: str="%Y-%m-%d",
*,
debug: Optional[bool] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6758,7 +6758,9 @@ def _test_date_time_query_parameter_serialize(
_query_params.append(
(
'date_time_query',
date_time_query.strftime(
date_time_query.isoformat()
if self.api_client.configuration.datetime_format is None
else date_time_query.strftime(
self.api_client.configuration.datetime_format
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class Configuration:
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
If None, datetime.isoformat() is used, which is RFC 3339 compliant.
:param date_format: Date format string for serialization.

:Example:
Expand Down Expand Up @@ -290,7 +291,7 @@ def __init__(
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
datetime_format: Optional[str]=None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The new default does not produce RFC 3339 for naive datetimes: isoformat() omits their UTC offset. Ensure naive values are handled or rejected before serialization, rather than describing this as RFC 3339-compliant by default.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/openapi3/client/petstore/python-httpx2/petstore_api/configuration.py, line 294:

<comment>The new default does not produce RFC 3339 for naive datetimes: `isoformat()` omits their UTC offset. Ensure naive values are handled or rejected before serialization, rather than describing this as RFC 3339-compliant by default.</comment>

<file context>
@@ -290,7 +291,7 @@ def __init__(
         client_side_validation: bool=True,
         socket_options: Optional[Any]=None,
-        datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
+        datetime_format: Optional[str]=None,
         date_format: str="%Y-%m-%d",
         *,
</file context>

date_format: str="%Y-%m-%d",
*,
debug: Optional[bool] = None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6778,7 +6778,9 @@ def _test_date_time_query_parameter_serialize(
_query_params.append(
(
'date_time_query',
date_time_query.strftime(
date_time_query.isoformat()
if self.api_client.configuration.datetime_format is None
else date_time_query.strftime(
self.api_client.configuration.datetime_format
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class Configuration:
:param client_side_validation: Enable client-side validation. Default True.
:param socket_options: Options to pass down to the underlying urllib3 socket.
:param datetime_format: Datetime format string for serialization.
If None, datetime.isoformat() is used, which is RFC 3339 compliant.
:param date_format: Date format string for serialization.

:Example:
Expand Down Expand Up @@ -298,7 +299,7 @@ def __init__(
safe_chars_for_path_param: str='',
client_side_validation: bool=True,
socket_options: Optional[Any]=None,
datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
datetime_format: Optional[str]=None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The new default accepts naive datetimes, but isoformat() emits them without a timezone offset, so the result is not RFC 3339. Require timezone-aware values before serialization rather than silently emitting an invalid date-time.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At samples/openapi3/client/petstore/python-lazyImports/petstore_api/configuration.py, line 302:

<comment>The new default accepts naive datetimes, but `isoformat()` emits them without a timezone offset, so the result is not RFC 3339. Require timezone-aware values before serialization rather than silently emitting an invalid date-time.</comment>

<file context>
@@ -298,7 +299,7 @@ def __init__(
         client_side_validation: bool=True,
         socket_options: Optional[Any]=None,
-        datetime_format: str="%Y-%m-%dT%H:%M:%S.%f%z",
+        datetime_format: Optional[str]=None,
         date_format: str="%Y-%m-%d",
         *,
</file context>

date_format: str="%Y-%m-%d",
*,
debug: Optional[bool] = None,
Expand Down
Loading