@@ -167,13 +167,52 @@ public void doNotGenerateRequestParamForObjectQueryParam() throws IOException {
167
167
checkFileNotContains (generator , outputPath + "/src/main/java/org/openapitools/api/PonyApi.java" , "@RequestParam" );
168
168
}
169
169
170
+ @ Test
171
+ public void generateFormatForDateAndDateTimeQueryParam () throws IOException {
172
+ File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
173
+ output .deleteOnExit ();
174
+ String outputPath = output .getAbsolutePath ().replace ('\\' , '/' );
175
+
176
+ OpenAPI openAPI = new OpenAPIParser ()
177
+ .readLocation ("src/test/resources/3_0/issue_2053.yaml" , null , new ParseOptions ()).getOpenAPI ();
178
+
179
+ SpringCodegen codegen = new SpringCodegen ();
180
+ codegen .setOutputDir (output .getAbsolutePath ());
181
+ codegen .additionalProperties ().put (CXFServerFeatures .LOAD_TEST_DATA_FROM_FILE , "true" );
182
+
183
+ ClientOptInput input = new ClientOptInput ();
184
+ input .openAPI (openAPI );
185
+ input .config (codegen );
186
+
187
+ MockDefaultGenerator generator = new MockDefaultGenerator ();
188
+ generator .opts (input ).generate ();
189
+
190
+ checkFileContains (
191
+ generator ,
192
+ outputPath + "/src/main/java/org/openapitools/api/ElephantsApi.java" ,
193
+ "@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE)"
194
+ );
195
+ checkFileContains (
196
+ generator ,
197
+ outputPath + "/src/main/java/org/openapitools/api/ZebrasApi.java" ,
198
+ "@org.springframework.format.annotation.DateTimeFormat(iso = org.springframework.format.annotation.DateTimeFormat.ISO.DATE_TIME)"
199
+ );
200
+ }
201
+
170
202
private void checkFileNotContains (MockDefaultGenerator generator , String path , String ... lines ) {
171
203
String file = generator .getFiles ().get (path );
172
204
assertNotNull (file );
173
205
for (String line : lines )
174
206
assertFalse (file .contains (line ));
175
207
}
176
208
209
+ private void checkFileContains (MockDefaultGenerator generator , String path , String ... lines ) {
210
+ String file = generator .getFiles ().get (path );
211
+ assertNotNull (file );
212
+ for (String line : lines )
213
+ assertTrue (file .contains (line ));
214
+ }
215
+
177
216
@ Test
178
217
public void clientOptsUnicity () {
179
218
SpringCodegen codegen = new SpringCodegen ();
0 commit comments