Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit a4cf7a0

Browse files
committed
Fixes python regex flags
1 parent 058ad60 commit a4cf7a0

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

modules/openapi-json-schema-generator/src/main/java/org/openapitools/codegen/languages/PythonClientCodegen.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,9 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
10411041
cp.isNullable = false;
10421042
cp.setHasMultipleTypes(true);
10431043
}
1044-
postProcessPattern(cp.pattern, cp.vendorExtensions);
1044+
if (p.getPattern() != null) {
1045+
postProcessPattern(p.getPattern(), cp.vendorExtensions);
1046+
}
10451047
// if we have a property that has a difficult name, either:
10461048
// 1. name is reserved, like class int float
10471049
// 2. name is invalid in python like '3rd' or 'Content-Type'

samples/openapi3/client/petstore/python/petstore_api/model/apple.py

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ class origin(
6363
class MetaOapg:
6464
regex=[{
6565
'pattern': r'^[A-Z\s]*$', # noqa: E501
66+
'flags': (
67+
re.IGNORECASE
68+
)
6669
}]
6770
__annotations__ = {
6871
"cultivar": cultivar,

samples/openapi3/client/petstore/python/petstore_api/model/format_test.py

+6
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ class string(
148148
class MetaOapg:
149149
regex=[{
150150
'pattern': r'[a-z]', # noqa: E501
151+
'flags': (
152+
re.IGNORECASE
153+
)
151154
}]
152155
binary = schemas.BinarySchema
153156
dateTime = schemas.DateTimeSchema
@@ -174,6 +177,9 @@ class pattern_with_digits_and_delimiter(
174177
class MetaOapg:
175178
regex=[{
176179
'pattern': r'^image_\d{1,3}$', # noqa: E501
180+
'flags': (
181+
re.IGNORECASE
182+
)
177183
}]
178184
noneProp = schemas.NoneSchema
179185
__annotations__ = {

samples/openapi3/client/petstore/python/petstore_api/paths/fake/post.py

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class string(
107107
class MetaOapg:
108108
regex=[{
109109
'pattern': r'[a-z]', # noqa: E501
110+
'flags': (
111+
re.IGNORECASE
112+
)
110113
}]
111114

112115

0 commit comments

Comments
 (0)