Skip to content

Commit e925336

Browse files
authored
remove allowStringInDateTimeParameters option (#15046)
1 parent 18e28ab commit e925336

5 files changed

Lines changed: 4 additions & 35 deletions

File tree

bin/configs/python-nextgen-echo-api.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ inputSpec: modules/openapi-generator/src/test/resources/3_0/echo_api.yaml
44
templateDir: modules/openapi-generator/src/main/resources/python-nextgen
55
additionalProperties:
66
hideGenerationTimestamp: "true"
7-
allowStringInDateTimeParameters: true

docs/generators/python-nextgen.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
1919

2020
| Option | Description | Values | Default |
2121
| ------ | ----------- | ------ | ------- |
22-
|allowStringInDateTimeParameters|Allow string as input to datetime/date parameters for backward compartibility.| |false|
2322
|dateFormat|date format for query parameters| |%Y-%m-%d|
2423
|datetimeFormat|datetime format for query parameters| |%Y-%m-%dT%H:%M:%S%z|
2524
|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|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonNextgenClientCodegen.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
4747
public static final String PACKAGE_URL = "packageUrl";
4848
public static final String DEFAULT_LIBRARY = "urllib3";
4949
public static final String RECURSION_LIMIT = "recursionLimit";
50-
public static final String ALLOW_STRING_IN_DATETIME_PARAMETERS = "allowStringInDateTimeParameters";
5150
public static final String FLOAT_STRICT_TYPE = "floatStrictType";
5251
public static final String DATETIME_FORMAT = "datetimeFormat";
5352
public static final String DATE_FORMAT = "dateFormat";
@@ -57,7 +56,6 @@ public class PythonNextgenClientCodegen extends AbstractPythonCodegen implements
5756
protected String modelDocPath = "docs" + File.separator;
5857
protected boolean hasModelsToImport = Boolean.FALSE;
5958
protected boolean useOneOfDiscriminatorLookup = false; // use oneOf discriminator's mapping for model lookup
60-
protected boolean allowStringInDateTimeParameters = false; // use StrictStr instead of datetime in parameters
6159
protected boolean floatStrictType = true;
6260
protected String datetimeFormat = "%Y-%m-%dT%H:%M:%S.%f%z";
6361
protected String dateFormat = "%Y-%m-%d";
@@ -172,8 +170,6 @@ public PythonNextgenClientCodegen() {
172170
cliOptions.add(new CliOption(CodegenConstants.SOURCECODEONLY_GENERATION, CodegenConstants.SOURCECODEONLY_GENERATION_DESC)
173171
.defaultValue(Boolean.FALSE.toString()));
174172
cliOptions.add(new CliOption(RECURSION_LIMIT, "Set the recursion limit. If not set, use the system default value."));
175-
cliOptions.add(new CliOption(ALLOW_STRING_IN_DATETIME_PARAMETERS, "Allow string as input to datetime/date parameters for backward compartibility.")
176-
.defaultValue(Boolean.FALSE.toString()));
177173
cliOptions.add(new CliOption(FLOAT_STRICT_TYPE, "Use strict type for float, i.e. StrictFloat or confloat(strict=true, ...)")
178174
.defaultValue(Boolean.TRUE.toString()));
179175
cliOptions.add(new CliOption(DATETIME_FORMAT, "datetime format for query parameters")
@@ -278,10 +274,6 @@ public void processOpts() {
278274
additionalProperties.put(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, useOneOfDiscriminatorLookup);
279275
}
280276

281-
if (additionalProperties.containsKey(ALLOW_STRING_IN_DATETIME_PARAMETERS)) {
282-
setAllowStringInDateTimeParameters(convertPropertyToBooleanAndWriteBack(ALLOW_STRING_IN_DATETIME_PARAMETERS));
283-
}
284-
285277
if (additionalProperties.containsKey(FLOAT_STRICT_TYPE)) {
286278
setFloatStrictType(convertPropertyToBooleanAndWriteBack(FLOAT_STRICT_TYPE));
287279
}
@@ -602,13 +594,7 @@ private String getPydanticType(CodegenParameter cp,
602594
datetimeImports.add("datetime");
603595
}
604596

605-
if (allowStringInDateTimeParameters) {
606-
pydanticImports.add("StrictStr");
607-
typingImports.add("Union");
608-
return String.format(Locale.ROOT, "Union[StrictStr, %s]", cp.dataType);
609-
} else {
610-
return cp.dataType;
611-
}
597+
return cp.dataType;
612598
} else if (cp.isUuid) {
613599
return cp.dataType;
614600
} else if (cp.isFreeFormObject) { // type: object
@@ -1409,10 +1395,6 @@ public String escapeReservedWord(String name) {
14091395
return "var_" + name;
14101396
}
14111397

1412-
public void setAllowStringInDateTimeParameters(boolean allowStringInDateTimeParameters) {
1413-
this.allowStringInDateTimeParameters = allowStringInDateTimeParameters;
1414-
}
1415-
14161398
public void setFloatStrictType(boolean floatStrictType) {
14171399
this.floatStrictType = floatStrictType;
14181400
}

samples/client/echo_api/python-nextgen/openapi_client/api/query_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
from pydantic import StrictBool, StrictInt, StrictStr
2626

27-
from typing import Any, Dict, Optional, Union
27+
from typing import Any, Dict, Optional
2828

2929

3030
from openapi_client.api_client import ApiClient
@@ -47,7 +47,7 @@ def __init__(self, api_client=None):
4747
self.api_client = api_client
4848

4949
@validate_arguments
50-
def test_query_datetime_date_string(self, datetime_query : Optional[Union[StrictStr, datetime]] = None, date_query : Optional[Union[StrictStr, date]] = None, string_query : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501
50+
def test_query_datetime_date_string(self, datetime_query : Optional[datetime] = None, date_query : Optional[date] = None, string_query : Optional[StrictStr] = None, **kwargs) -> str: # noqa: E501
5151
"""Test query parameter(s) # noqa: E501
5252
5353
Test query parameter(s) # noqa: E501
@@ -82,7 +82,7 @@ def test_query_datetime_date_string(self, datetime_query : Optional[Union[Strict
8282
return self.test_query_datetime_date_string_with_http_info(datetime_query, date_query, string_query, **kwargs) # noqa: E501
8383

8484
@validate_arguments
85-
def test_query_datetime_date_string_with_http_info(self, datetime_query : Optional[Union[StrictStr, datetime]] = None, date_query : Optional[Union[StrictStr, date]] = None, string_query : Optional[StrictStr] = None, **kwargs): # noqa: E501
85+
def test_query_datetime_date_string_with_http_info(self, datetime_query : Optional[datetime] = None, date_query : Optional[date] = None, string_query : Optional[StrictStr] = None, **kwargs): # noqa: E501
8686
"""Test query parameter(s) # noqa: E501
8787
8888
Test query parameter(s) # noqa: E501

samples/client/echo_api/python-nextgen/test/test_manual.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ def testDateTimeQueryWithDateTime(self):
5151
e = EchoServerResponseParser(api_response)
5252
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")
5353

54-
def testDateTimeQueryWithString(self):
55-
api_instance = openapi_client.QueryApi()
56-
datetime_query = '19:20:30 2013-10-20' # datetime | (optional)
57-
date_query = '2013-10-20' # date | (optional)
58-
string_query = 'string_query_example' # str | (optional)
59-
60-
# Test query parameter(s)
61-
api_response = api_instance.test_query_datetime_date_string(datetime_query=datetime_query, date_query=date_query, string_query=string_query)
62-
e = EchoServerResponseParser(api_response)
63-
self.assertEqual(e.path, "/query/datetime/date/string?datetime_query=19%3A20%3A30%202013-10-20&date_query=2013-10-20&string_query=string_query_example")
64-
6554
class EchoServerResponseParser():
6655
def __init__(self, http_response):
6756
if http_response is None:

0 commit comments

Comments
 (0)