diff --git a/docs/generators/python-aiohttp.md b/docs/generators/python-aiohttp.md
index b99acea11527..4c4392712b7f 100644
--- a/docs/generators/python-aiohttp.md
+++ b/docs/generators/python-aiohttp.md
@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- Dict
- List
+- UUID
- bool
- bytes
- date
diff --git a/docs/generators/python-blueplanet.md b/docs/generators/python-blueplanet.md
index 2702fd49c5fe..d1359dca28a0 100644
--- a/docs/generators/python-blueplanet.md
+++ b/docs/generators/python-blueplanet.md
@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- Dict
- List
+- UUID
- bool
- bytes
- date
diff --git a/docs/generators/python-fastapi.md b/docs/generators/python-fastapi.md
index 0beee68d757d..7510e0426a62 100644
--- a/docs/generators/python-fastapi.md
+++ b/docs/generators/python-fastapi.md
@@ -50,6 +50,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- Dict
- List
+- UUID
- bool
- bytes
- date
diff --git a/docs/generators/python-flask.md b/docs/generators/python-flask.md
index 81be38100b7e..91fd95fc2ca3 100644
--- a/docs/generators/python-flask.md
+++ b/docs/generators/python-flask.md
@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- Dict
- List
+- UUID
- bool
- bytes
- date
diff --git a/docs/generators/python.md b/docs/generators/python.md
index 10a032dadacb..ec2ed3f9daa2 100644
--- a/docs/generators/python.md
+++ b/docs/generators/python.md
@@ -53,6 +53,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- Dict
- List
+- UUID
- bool
- bytearray
- bytes
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java
index bf984a30aa4b..3fa9880532b6 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java
@@ -108,6 +108,7 @@ public AbstractPythonCodegen() {
// TODO file and binary is mapped as `file`
languageSpecificPrimitives.add("file");
languageSpecificPrimitives.add("bytes");
+ languageSpecificPrimitives.add("UUID");
typeMapping.clear();
typeMapping.put("integer", "int");
@@ -129,8 +130,7 @@ public AbstractPythonCodegen() {
// mapped to String as a workaround
typeMapping.put("binary", "str");
typeMapping.put("ByteArray", "str");
- // map uuid to string for the time being
- typeMapping.put("UUID", "str");
+ typeMapping.put("UUID", "UUID");
typeMapping.put("URI", "str");
typeMapping.put("null", "none_type");
@@ -571,7 +571,12 @@ public void setParameterExampleValue(CodegenParameter p) {
type = p.dataType;
}
- if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
+ if (Boolean.TRUE.equals(p.isUuid)) {
+ if (example == null) {
+ example = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
+ }
+ example = "UUID('" + escapeTextInSingleQuotes(example) + "')";
+ } else if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
if (example == null) {
example = p.paramName + "_example";
}
diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md b/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md
index c843e3940d27..843b8f246632 100644
--- a/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md
@@ -1328,7 +1328,7 @@ configuration = petstore_api.Configuration(
async with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
- uuid_example = '84529ad2-2265-4e15-b76b-c17025d848f6' # str | uuid example
+ uuid_example = UUID('84529ad2-2265-4e15-b76b-c17025d848f6') # UUID | uuid example
try:
# test uuid example
@@ -1344,7 +1344,7 @@ async with petstore_api.ApiClient(configuration) as api_client:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **uuid_example** | **str**| uuid example |
+ **uuid_example** | **UUID**| uuid example |
### Return type
diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/FormatTest.md b/samples/openapi3/client/petstore/python-aiohttp/docs/FormatTest.md
index 6be7fc017577..714d2401bbae 100644
--- a/samples/openapi3/client/petstore/python-aiohttp/docs/FormatTest.md
+++ b/samples/openapi3/client/petstore/python-aiohttp/docs/FormatTest.md
@@ -18,7 +18,7 @@ Name | Type | Description | Notes
**binary** | **bytearray** | | [optional]
**var_date** | **date** | |
**date_time** | **datetime** | | [optional]
-**uuid** | **str** | | [optional]
+**uuid** | **UUID** | | [optional]
**password** | **str** | |
**pattern_with_digits** | **str** | A string that is a 10 digit number. Can have leading zeros. | [optional]
**pattern_with_digits_and_delimiter** | **str** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional]
diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-aiohttp/docs/MixedPropertiesAndAdditionalPropertiesClass.md
index 0dc994275d1e..84134317aefc 100644
--- a/samples/openapi3/client/petstore/python-aiohttp/docs/MixedPropertiesAndAdditionalPropertiesClass.md
+++ b/samples/openapi3/client/petstore/python-aiohttp/docs/MixedPropertiesAndAdditionalPropertiesClass.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**uuid** | **str** | | [optional]
+**uuid** | **UUID** | | [optional]
**date_time** | **datetime** | | [optional]
**map** | [**Dict[str, Animal]**](Animal.md) | | [optional]
diff --git a/samples/openapi3/client/petstore/python-aiohttp/docs/Task.md b/samples/openapi3/client/petstore/python-aiohttp/docs/Task.md
index 211ce76cdfeb..85fa2776a059 100644
--- a/samples/openapi3/client/petstore/python-aiohttp/docs/Task.md
+++ b/samples/openapi3/client/petstore/python-aiohttp/docs/Task.md
@@ -6,7 +6,7 @@ Used to test oneOf enums with only one string value.
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**id** | **str** | |
+**id** | **UUID** | |
**activity** | [**TaskActivity**](TaskActivity.md) | |
## Example
diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py
index bafaa8698d60..3bb7f0218ef8 100644
--- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py
+++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/api/fake_api.py
@@ -4932,7 +4932,7 @@ async def fake_uuid_example(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -4998,7 +4998,7 @@ async def fake_uuid_example_with_http_info(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -5064,7 +5064,7 @@ async def fake_uuid_example_without_preload_content(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
diff --git a/samples/openapi3/client/petstore/python-httpx/docs/FakeApi.md b/samples/openapi3/client/petstore/python-httpx/docs/FakeApi.md
index c843e3940d27..843b8f246632 100644
--- a/samples/openapi3/client/petstore/python-httpx/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/python-httpx/docs/FakeApi.md
@@ -1328,7 +1328,7 @@ configuration = petstore_api.Configuration(
async with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
- uuid_example = '84529ad2-2265-4e15-b76b-c17025d848f6' # str | uuid example
+ uuid_example = UUID('84529ad2-2265-4e15-b76b-c17025d848f6') # UUID | uuid example
try:
# test uuid example
@@ -1344,7 +1344,7 @@ async with petstore_api.ApiClient(configuration) as api_client:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **uuid_example** | **str**| uuid example |
+ **uuid_example** | **UUID**| uuid example |
### Return type
diff --git a/samples/openapi3/client/petstore/python-httpx/docs/FormatTest.md b/samples/openapi3/client/petstore/python-httpx/docs/FormatTest.md
index 6be7fc017577..714d2401bbae 100644
--- a/samples/openapi3/client/petstore/python-httpx/docs/FormatTest.md
+++ b/samples/openapi3/client/petstore/python-httpx/docs/FormatTest.md
@@ -18,7 +18,7 @@ Name | Type | Description | Notes
**binary** | **bytearray** | | [optional]
**var_date** | **date** | |
**date_time** | **datetime** | | [optional]
-**uuid** | **str** | | [optional]
+**uuid** | **UUID** | | [optional]
**password** | **str** | |
**pattern_with_digits** | **str** | A string that is a 10 digit number. Can have leading zeros. | [optional]
**pattern_with_digits_and_delimiter** | **str** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional]
diff --git a/samples/openapi3/client/petstore/python-httpx/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-httpx/docs/MixedPropertiesAndAdditionalPropertiesClass.md
index 0dc994275d1e..84134317aefc 100644
--- a/samples/openapi3/client/petstore/python-httpx/docs/MixedPropertiesAndAdditionalPropertiesClass.md
+++ b/samples/openapi3/client/petstore/python-httpx/docs/MixedPropertiesAndAdditionalPropertiesClass.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**uuid** | **str** | | [optional]
+**uuid** | **UUID** | | [optional]
**date_time** | **datetime** | | [optional]
**map** | [**Dict[str, Animal]**](Animal.md) | | [optional]
diff --git a/samples/openapi3/client/petstore/python-httpx/docs/Task.md b/samples/openapi3/client/petstore/python-httpx/docs/Task.md
index 211ce76cdfeb..85fa2776a059 100644
--- a/samples/openapi3/client/petstore/python-httpx/docs/Task.md
+++ b/samples/openapi3/client/petstore/python-httpx/docs/Task.md
@@ -6,7 +6,7 @@ Used to test oneOf enums with only one string value.
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**id** | **str** | |
+**id** | **UUID** | |
**activity** | [**TaskActivity**](TaskActivity.md) | |
## Example
diff --git a/samples/openapi3/client/petstore/python-httpx/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-httpx/petstore_api/api/fake_api.py
index bafaa8698d60..3bb7f0218ef8 100644
--- a/samples/openapi3/client/petstore/python-httpx/petstore_api/api/fake_api.py
+++ b/samples/openapi3/client/petstore/python-httpx/petstore_api/api/fake_api.py
@@ -4932,7 +4932,7 @@ async def fake_uuid_example(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -4998,7 +4998,7 @@ async def fake_uuid_example_with_http_info(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -5064,7 +5064,7 @@ async def fake_uuid_example_without_preload_content(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
diff --git a/samples/openapi3/client/petstore/python-lazyImports/docs/FakeApi.md b/samples/openapi3/client/petstore/python-lazyImports/docs/FakeApi.md
index 16bce5a2b491..8adef01f88e6 100644
--- a/samples/openapi3/client/petstore/python-lazyImports/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/python-lazyImports/docs/FakeApi.md
@@ -1328,7 +1328,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
- uuid_example = '84529ad2-2265-4e15-b76b-c17025d848f6' # str | uuid example
+ uuid_example = UUID('84529ad2-2265-4e15-b76b-c17025d848f6') # UUID | uuid example
try:
# test uuid example
@@ -1344,7 +1344,7 @@ with petstore_api.ApiClient(configuration) as api_client:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **uuid_example** | **str**| uuid example |
+ **uuid_example** | **UUID**| uuid example |
### Return type
diff --git a/samples/openapi3/client/petstore/python-lazyImports/docs/FormatTest.md b/samples/openapi3/client/petstore/python-lazyImports/docs/FormatTest.md
index 6be7fc017577..714d2401bbae 100644
--- a/samples/openapi3/client/petstore/python-lazyImports/docs/FormatTest.md
+++ b/samples/openapi3/client/petstore/python-lazyImports/docs/FormatTest.md
@@ -18,7 +18,7 @@ Name | Type | Description | Notes
**binary** | **bytearray** | | [optional]
**var_date** | **date** | |
**date_time** | **datetime** | | [optional]
-**uuid** | **str** | | [optional]
+**uuid** | **UUID** | | [optional]
**password** | **str** | |
**pattern_with_digits** | **str** | A string that is a 10 digit number. Can have leading zeros. | [optional]
**pattern_with_digits_and_delimiter** | **str** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional]
diff --git a/samples/openapi3/client/petstore/python-lazyImports/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python-lazyImports/docs/MixedPropertiesAndAdditionalPropertiesClass.md
index 0dc994275d1e..84134317aefc 100644
--- a/samples/openapi3/client/petstore/python-lazyImports/docs/MixedPropertiesAndAdditionalPropertiesClass.md
+++ b/samples/openapi3/client/petstore/python-lazyImports/docs/MixedPropertiesAndAdditionalPropertiesClass.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**uuid** | **str** | | [optional]
+**uuid** | **UUID** | | [optional]
**date_time** | **datetime** | | [optional]
**map** | [**Dict[str, Animal]**](Animal.md) | | [optional]
diff --git a/samples/openapi3/client/petstore/python-lazyImports/docs/Task.md b/samples/openapi3/client/petstore/python-lazyImports/docs/Task.md
index 211ce76cdfeb..85fa2776a059 100644
--- a/samples/openapi3/client/petstore/python-lazyImports/docs/Task.md
+++ b/samples/openapi3/client/petstore/python-lazyImports/docs/Task.md
@@ -6,7 +6,7 @@ Used to test oneOf enums with only one string value.
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**id** | **str** | |
+**id** | **UUID** | |
**activity** | [**TaskActivity**](TaskActivity.md) | |
## Example
diff --git a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/fake_api.py
index c3eb9df64399..17761ab9bd0e 100644
--- a/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/fake_api.py
+++ b/samples/openapi3/client/petstore/python-lazyImports/petstore_api/api/fake_api.py
@@ -4932,7 +4932,7 @@ def fake_uuid_example(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -4998,7 +4998,7 @@ def fake_uuid_example_with_http_info(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -5064,7 +5064,7 @@ def fake_uuid_example_without_preload_content(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
diff --git a/samples/openapi3/client/petstore/python/docs/FakeApi.md b/samples/openapi3/client/petstore/python/docs/FakeApi.md
index 16bce5a2b491..8adef01f88e6 100644
--- a/samples/openapi3/client/petstore/python/docs/FakeApi.md
+++ b/samples/openapi3/client/petstore/python/docs/FakeApi.md
@@ -1328,7 +1328,7 @@ configuration = petstore_api.Configuration(
with petstore_api.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = petstore_api.FakeApi(api_client)
- uuid_example = '84529ad2-2265-4e15-b76b-c17025d848f6' # str | uuid example
+ uuid_example = UUID('84529ad2-2265-4e15-b76b-c17025d848f6') # UUID | uuid example
try:
# test uuid example
@@ -1344,7 +1344,7 @@ with petstore_api.ApiClient(configuration) as api_client:
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
- **uuid_example** | **str**| uuid example |
+ **uuid_example** | **UUID**| uuid example |
### Return type
diff --git a/samples/openapi3/client/petstore/python/docs/FormatTest.md b/samples/openapi3/client/petstore/python/docs/FormatTest.md
index 6be7fc017577..714d2401bbae 100644
--- a/samples/openapi3/client/petstore/python/docs/FormatTest.md
+++ b/samples/openapi3/client/petstore/python/docs/FormatTest.md
@@ -18,7 +18,7 @@ Name | Type | Description | Notes
**binary** | **bytearray** | | [optional]
**var_date** | **date** | |
**date_time** | **datetime** | | [optional]
-**uuid** | **str** | | [optional]
+**uuid** | **UUID** | | [optional]
**password** | **str** | |
**pattern_with_digits** | **str** | A string that is a 10 digit number. Can have leading zeros. | [optional]
**pattern_with_digits_and_delimiter** | **str** | A string starting with 'image_' (case insensitive) and one to three digits following i.e. Image_01. | [optional]
diff --git a/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md b/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md
index 0dc994275d1e..84134317aefc 100644
--- a/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md
+++ b/samples/openapi3/client/petstore/python/docs/MixedPropertiesAndAdditionalPropertiesClass.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**uuid** | **str** | | [optional]
+**uuid** | **UUID** | | [optional]
**date_time** | **datetime** | | [optional]
**map** | [**Dict[str, Animal]**](Animal.md) | | [optional]
diff --git a/samples/openapi3/client/petstore/python/docs/Task.md b/samples/openapi3/client/petstore/python/docs/Task.md
index 211ce76cdfeb..85fa2776a059 100644
--- a/samples/openapi3/client/petstore/python/docs/Task.md
+++ b/samples/openapi3/client/petstore/python/docs/Task.md
@@ -6,7 +6,7 @@ Used to test oneOf enums with only one string value.
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**id** | **str** | |
+**id** | **UUID** | |
**activity** | [**TaskActivity**](TaskActivity.md) | |
## Example
diff --git a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py
index c3eb9df64399..17761ab9bd0e 100755
--- a/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py
+++ b/samples/openapi3/client/petstore/python/petstore_api/api/fake_api.py
@@ -4932,7 +4932,7 @@ def fake_uuid_example(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -4998,7 +4998,7 @@ def fake_uuid_example_with_http_info(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
@@ -5064,7 +5064,7 @@ def fake_uuid_example_without_preload_content(
:param uuid_example: uuid example (required)
- :type uuid_example: str
+ :type uuid_example: UUID
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of