Skip to content

Commit f37b8cc

Browse files
authored
Add UUID examples and documentation (#22303)
1 parent 64c8711 commit f37b8cc

File tree

26 files changed

+45
-35
lines changed

26 files changed

+45
-35
lines changed

docs/generators/python-aiohttp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
5555
<ul class="column-ul">
5656
<li>Dict</li>
5757
<li>List</li>
58+
<li>UUID</li>
5859
<li>bool</li>
5960
<li>bytes</li>
6061
<li>date</li>

docs/generators/python-blueplanet.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
5555
<ul class="column-ul">
5656
<li>Dict</li>
5757
<li>List</li>
58+
<li>UUID</li>
5859
<li>bool</li>
5960
<li>bytes</li>
6061
<li>date</li>

docs/generators/python-fastapi.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
5050
<ul class="column-ul">
5151
<li>Dict</li>
5252
<li>List</li>
53+
<li>UUID</li>
5354
<li>bool</li>
5455
<li>bytes</li>
5556
<li>date</li>

docs/generators/python-flask.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
5555
<ul class="column-ul">
5656
<li>Dict</li>
5757
<li>List</li>
58+
<li>UUID</li>
5859
<li>bool</li>
5960
<li>bytes</li>
6061
<li>date</li>

docs/generators/python.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
5353
<ul class="column-ul">
5454
<li>Dict</li>
5555
<li>List</li>
56+
<li>UUID</li>
5657
<li>bool</li>
5758
<li>bytearray</li>
5859
<li>bytes</li>

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public AbstractPythonCodegen() {
108108
// TODO file and binary is mapped as `file`
109109
languageSpecificPrimitives.add("file");
110110
languageSpecificPrimitives.add("bytes");
111+
languageSpecificPrimitives.add("UUID");
111112

112113
typeMapping.clear();
113114
typeMapping.put("integer", "int");
@@ -129,8 +130,7 @@ public AbstractPythonCodegen() {
129130
// mapped to String as a workaround
130131
typeMapping.put("binary", "str");
131132
typeMapping.put("ByteArray", "str");
132-
// map uuid to string for the time being
133-
typeMapping.put("UUID", "str");
133+
typeMapping.put("UUID", "UUID");
134134
typeMapping.put("URI", "str");
135135
typeMapping.put("null", "none_type");
136136

@@ -571,7 +571,12 @@ public void setParameterExampleValue(CodegenParameter p) {
571571
type = p.dataType;
572572
}
573573

574-
if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
574+
if (Boolean.TRUE.equals(p.isUuid)) {
575+
if (example == null) {
576+
example = "38400000-8cf0-11bd-b23e-10b96e4ef00d";
577+
}
578+
example = "UUID('" + escapeTextInSingleQuotes(example) + "')";
579+
} else if ("String".equalsIgnoreCase(type) || "str".equalsIgnoreCase(type)) {
575580
if (example == null) {
576581
example = p.paramName + "_example";
577582
}

samples/openapi3/client/petstore/python-aiohttp/docs/FakeApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ configuration = petstore_api.Configuration(
13281328
async with petstore_api.ApiClient(configuration) as api_client:
13291329
# Create an instance of the API class
13301330
api_instance = petstore_api.FakeApi(api_client)
1331-
uuid_example = '84529ad2-2265-4e15-b76b-c17025d848f6' # str | uuid example
1331+
uuid_example = UUID('84529ad2-2265-4e15-b76b-c17025d848f6') # UUID | uuid example
13321332

13331333
try:
13341334
# test uuid example
@@ -1344,7 +1344,7 @@ async with petstore_api.ApiClient(configuration) as api_client:
13441344

13451345
Name | Type | Description | Notes
13461346
------------- | ------------- | ------------- | -------------
1347-
**uuid_example** | **str**| uuid example |
1347+
**uuid_example** | **UUID**| uuid example |
13481348

13491349
### Return type
13501350

samples/openapi3/client/petstore/python-aiohttp/docs/FormatTest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Name | Type | Description | Notes
1818
**binary** | **bytearray** | | [optional]
1919
**var_date** | **date** | |
2020
**date_time** | **datetime** | | [optional]
21-
**uuid** | **str** | | [optional]
21+
**uuid** | **UUID** | | [optional]
2222
**password** | **str** | |
2323
**pattern_with_digits** | **str** | A string that is a 10 digit number. Can have leading zeros. | [optional]
2424
**pattern_with_digits_and_delimiter** | **str** | A string starting with &#39;image_&#39; (case insensitive) and one to three digits following i.e. Image_01. | [optional]

samples/openapi3/client/petstore/python-aiohttp/docs/MixedPropertiesAndAdditionalPropertiesClass.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
Name | Type | Description | Notes
77
------------ | ------------- | ------------- | -------------
8-
**uuid** | **str** | | [optional]
8+
**uuid** | **UUID** | | [optional]
99
**date_time** | **datetime** | | [optional]
1010
**map** | [**Dict[str, Animal]**](Animal.md) | | [optional]
1111

samples/openapi3/client/petstore/python-aiohttp/docs/Task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Used to test oneOf enums with only one string value.
66

77
Name | Type | Description | Notes
88
------------ | ------------- | ------------- | -------------
9-
**id** | **str** | |
9+
**id** | **UUID** | |
1010
**activity** | [**TaskActivity**](TaskActivity.md) | |
1111

1212
## Example

0 commit comments

Comments
 (0)