Skip to content

Commit c77f131

Browse files
authored
Query Parameters for unencoded date/times (#69)
DateTimes and Dates in Query parameters should not be url encoded as Dio is also doing this, which is double encoding them. 5.2.1 of OpenAPI has also introduced some issues.
1 parent 841729a commit c77f131

File tree

16 files changed

+85
-54
lines changed

16 files changed

+85
-54
lines changed

README.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ The source for the tests is located in src/k8s** folders. The generated test out
267267

268268
==== Changelog
269269

270+
- 5.11 - fix date/datetime strings in queries to not be encoded. Updated to use 5.2.1 of OpenAPI. Fixed a bunch
271+
of templating issues that arose because of it.
270272
- 5.10 - removal of an unnecessary date/time typecast for null safety
271273
- 5.9 - fix for null safe 2d APIs (via PiotrMitkowski)
272274
- 5.8 - slew of different fixes for the generator from different people, particular thanks to NANASHI0X74 for sticky ones!

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
</scm>
3535

3636
<properties>
37-
<openapi-codegen-version>5.1.0</openapi-codegen-version>
37+
<openapi-codegen-version>5.2.1</openapi-codegen-version>
3838
<maven.compiler.target>1.8</maven.compiler.target>
3939
<maven.compiler.source>1.8</maven.compiler.source>
4040
</properties>

src/it/k8s/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<plugin>
5252
<groupId>org.openapitools</groupId>
5353
<artifactId>openapi-generator-maven-plugin</artifactId>
54-
<version>5.1.0</version>
54+
<version>5.2.1</version>
5555
<dependencies>
5656
<dependency>
5757
<groupId>com.bluetrainsoftware.maven</groupId>

src/it/k8s/test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ paths:
6868
schema:
6969
type: string
7070
format: date-time
71+
- name: queryDateTime
72+
in: query
73+
required: false
74+
schema:
75+
type: string
76+
format: date-time
7177
operationId: getSampleWithAllTypes
7278
tags:
7379
- ControlService

src/it/k8s_null/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<plugin>
5252
<groupId>org.openapitools</groupId>
5353
<artifactId>openapi-generator-maven-plugin</artifactId>
54-
<version>5.1.0</version>
54+
<version>5.2.1</version>
5555
<dependencies>
5656
<dependency>
5757
<groupId>com.bluetrainsoftware.maven</groupId>

src/it/k8s_null/test.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ paths:
6868
schema:
6969
type: string
7070
format: date-time
71+
- name: queryDateTime
72+
in: query
73+
required: false
74+
schema:
75+
type: string
76+
format: date-time
7177
operationId: getSampleWithAllTypes
7278
tags:
7379
- ControlService

src/main/java/cd/connect/openapi/DartV3ApiGenerator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ private String listOrMapSuffix(CodegenProperty cp) {
216216
}
217217

218218
private void correctInternals(CodegenModel model, CodegenProperty cp, boolean classLevelField) {
219+
if ("otherDeps".equals(cp.baseName)) {
220+
System.out.println("here");
221+
}
222+
219223
if ("DateTime".equals(cp.complexType) || "Date".equals(cp.complexType)) {
220224
cp.isDateTime = "date-time".equals(cp.getDataFormat());
221225
cp.isDate = "date".equals(cp.getDataFormat());

src/main/resources/dart2-v3template/_array_from_json.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@
2626
(data as List<dynamic>?)?.cast<{{{dataType}}}>() ?? <{{{dataType}}}>[]
2727
{{/nullSafe}}
2828
{{/isPrimitiveType}}
29+
{{#isAnyType}}data{{/isAnyType}}
2930
{{/items}}
3031
{{/items}}

src/main/resources/dart2-v3template/_copy.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
{{^vendorExtensions.x-not-nullable}}data == null ? null : data.copyWith(){{/vendorExtensions.x-not-nullable}}
1414
{{/isModel}}
1515
{{#isPrimitiveType}}data{{/isPrimitiveType}}
16+
{{#isAnyType}}data{{/isAnyType}}
1617
{{/items}}

src/main/resources/dart2-v3template/_from_json.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@
4747
{{#isPrimitiveType}}
4848
data as {{{dataType}}}
4949
{{/isPrimitiveType}}
50+
{{#isAnyType}}data{{/isAnyType}}
5051
{{/items}}

0 commit comments

Comments
 (0)