@@ -276,118 +276,31 @@ void shouldGenerateOneOfDiscriminatorAsObjectNotString() throws Exception {
276276 }
277277 }
278278
279- @ Test
280- void shouldGenerateAllOfWithDiscriminatorParentUsingUpperSnakeCaseCasing () throws Exception {
281- OpenAPIParser openAPIV3Parser = new OpenAPIParser ();
282- ParseOptions options = new ParseOptions ();
283- options .setResolve (true );
284- options .setFlatten (true );
285- OpenAPI openAPI = openAPIV3Parser .readContents (Files .readString (Paths .get ("src/test/resources/test-allof-discriminator-schema.yaml" )), null , options ).getOpenAPI ();
286- Map <String , Schema > schemas = OpenApiUtils .getSchemas (openAPI , List .of ("application/json" ));
287- globalContext .getSchemaMap ().putAll (schemas );
288- OpenAPIModelGenerator generator = new OpenAPIModelGenerator (globalContext , validDataFormat , new ProcessingArguments .ExamplesFlags (true , true , true , true ), 3 , true , 2 , "UPPER_SNAKE_CASE" );
289-
290- List <String > decimalExamples = generator .generate ("DecimalValue" );
291-
292- Assertions .assertThat (decimalExamples ).isNotEmpty ();
293- Object kindValue = JsonUtils .getVariableFromJson (decimalExamples .getFirst (), "$.kind" );
294- Assertions .assertThat (kindValue ).isNotNull ();
295- Assertions .assertThat (kindValue .toString ()).isEqualTo ("DECIMAL_VALUE" );
296- }
297-
298- @ Test
299- void shouldGenerateAllOfWithDiscriminatorParentUsingPascalCaseCasing () throws Exception {
300- OpenAPIParser openAPIV3Parser = new OpenAPIParser ();
301- ParseOptions options = new ParseOptions ();
302- options .setResolve (true );
303- options .setFlatten (true );
304- OpenAPI openAPI = openAPIV3Parser .readContents (Files .readString (Paths .get ("src/test/resources/test-allof-discriminator-schema.yaml" )), null , options ).getOpenAPI ();
305- Map <String , Schema > schemas = OpenApiUtils .getSchemas (openAPI , List .of ("application/json" ));
306- globalContext .getSchemaMap ().putAll (schemas );
307- OpenAPIModelGenerator generator = new OpenAPIModelGenerator (globalContext , validDataFormat , new ProcessingArguments .ExamplesFlags (true , true , true , true ), 3 , true , 2 , "PascalCase" );
308-
309- List <String > decimalExamples = generator .generate ("DecimalValue" );
310-
311- Assertions .assertThat (decimalExamples ).isNotEmpty ();
312- Object kindValue = JsonUtils .getVariableFromJson (decimalExamples .getFirst (), "$.kind" );
313- Assertions .assertThat (kindValue ).isNotNull ();
314- Assertions .assertThat (kindValue .toString ()).isEqualTo ("DecimalValue" );
315- }
316-
317- @ Test
318- void shouldGenerateAllOfWithDiscriminatorParentUsingCamelCaseCasing () throws Exception {
319- OpenAPIParser openAPIV3Parser = new OpenAPIParser ();
320- ParseOptions options = new ParseOptions ();
321- options .setResolve (true );
322- options .setFlatten (true );
323- OpenAPI openAPI = openAPIV3Parser .readContents (Files .readString (Paths .get ("src/test/resources/test-allof-discriminator-schema.yaml" )), null , options ).getOpenAPI ();
324- Map <String , Schema > schemas = OpenApiUtils .getSchemas (openAPI , List .of ("application/json" ));
325- globalContext .getSchemaMap ().putAll (schemas );
326- OpenAPIModelGenerator generator = new OpenAPIModelGenerator (globalContext , validDataFormat , new ProcessingArguments .ExamplesFlags (true , true , true , true ), 3 , true , 2 , "camelCase" );
327-
328- List <String > decimalExamples = generator .generate ("DecimalValue" );
329-
330- Assertions .assertThat (decimalExamples ).isNotEmpty ();
331- Object kindValue = JsonUtils .getVariableFromJson (decimalExamples .getFirst (), "$.kind" );
332- Assertions .assertThat (kindValue ).isNotNull ();
333- Assertions .assertThat (kindValue .toString ()).isEqualTo ("decimalValue" );
334- }
335-
336- @ Test
337- void shouldGenerateAllOfWithDiscriminatorParentUsingLowerSnakeCaseCasing () throws Exception {
338- OpenAPIParser openAPIV3Parser = new OpenAPIParser ();
339- ParseOptions options = new ParseOptions ();
340- options .setResolve (true );
341- options .setFlatten (true );
342- OpenAPI openAPI = openAPIV3Parser .readContents (Files .readString (Paths .get ("src/test/resources/test-allof-discriminator-schema.yaml" )), null , options ).getOpenAPI ();
343- Map <String , Schema > schemas = OpenApiUtils .getSchemas (openAPI , List .of ("application/json" ));
344- globalContext .getSchemaMap ().putAll (schemas );
345- OpenAPIModelGenerator generator = new OpenAPIModelGenerator (globalContext , validDataFormat , new ProcessingArguments .ExamplesFlags (true , true , true , true ), 3 , true , 2 , "lower_snake_case" );
346-
347- List <String > decimalExamples = generator .generate ("DecimalValue" );
348-
349- Assertions .assertThat (decimalExamples ).isNotEmpty ();
350- Object kindValue = JsonUtils .getVariableFromJson (decimalExamples .getFirst (), "$.kind" );
351- Assertions .assertThat (kindValue ).isNotNull ();
352- Assertions .assertThat (kindValue .toString ()).isEqualTo ("decimal_value" );
353- }
354-
355- @ Test
356- void shouldGenerateAllOfWithDiscriminatorParentUsingKebabCaseCasing () throws Exception {
357- OpenAPIParser openAPIV3Parser = new OpenAPIParser ();
358- ParseOptions options = new ParseOptions ();
359- options .setResolve (true );
360- options .setFlatten (true );
361- OpenAPI openAPI = openAPIV3Parser .readContents (Files .readString (Paths .get ("src/test/resources/test-allof-discriminator-schema.yaml" )), null , options ).getOpenAPI ();
362- Map <String , Schema > schemas = OpenApiUtils .getSchemas (openAPI , List .of ("application/json" ));
363- globalContext .getSchemaMap ().putAll (schemas );
364- OpenAPIModelGenerator generator = new OpenAPIModelGenerator (globalContext , validDataFormat , new ProcessingArguments .ExamplesFlags (true , true , true , true ), 3 , true , 2 , "kebab-case" );
365-
366- List <String > decimalExamples = generator .generate ("DecimalValue" );
367-
368- Assertions .assertThat (decimalExamples ).isNotEmpty ();
369- Object kindValue = JsonUtils .getVariableFromJson (decimalExamples .getFirst (), "$.kind" );
370- Assertions .assertThat (kindValue ).isNotNull ();
371- Assertions .assertThat (kindValue .toString ()).isEqualTo ("decimal-value" );
372- }
373-
374- @ Test
375- void shouldGenerateAllOfWithDiscriminatorParentUsingLowercaseCasing () throws Exception {
279+ @ ParameterizedTest
280+ @ CsvSource ({
281+ "UPPER_SNAKE_CASE, DECIMAL_VALUE" ,
282+ "PascalCase, DecimalValue" ,
283+ "camelCase, decimalValue" ,
284+ "lower_snake_case, decimal_value" ,
285+ "kebab-case, decimal-value" ,
286+ "lowercase, decimalvalue"
287+ })
288+ void shouldGenerateAllOfWithDiscriminatorParentUsingUpperSnakeCaseCasing (String casing , String expectedKindValue ) throws Exception {
376289 OpenAPIParser openAPIV3Parser = new OpenAPIParser ();
377290 ParseOptions options = new ParseOptions ();
378291 options .setResolve (true );
379292 options .setFlatten (true );
380293 OpenAPI openAPI = openAPIV3Parser .readContents (Files .readString (Paths .get ("src/test/resources/test-allof-discriminator-schema.yaml" )), null , options ).getOpenAPI ();
381294 Map <String , Schema > schemas = OpenApiUtils .getSchemas (openAPI , List .of ("application/json" ));
382295 globalContext .getSchemaMap ().putAll (schemas );
383- OpenAPIModelGenerator generator = new OpenAPIModelGenerator (globalContext , validDataFormat , new ProcessingArguments .ExamplesFlags (true , true , true , true ), 3 , true , 2 , "lowercase" );
296+ OpenAPIModelGenerator generator = new OpenAPIModelGenerator (globalContext , validDataFormat , new ProcessingArguments .ExamplesFlags (true , true , true , true ), 3 , true , 2 , casing );
384297
385298 List <String > decimalExamples = generator .generate ("DecimalValue" );
386299
387300 Assertions .assertThat (decimalExamples ).isNotEmpty ();
388301 Object kindValue = JsonUtils .getVariableFromJson (decimalExamples .getFirst (), "$.kind" );
389302 Assertions .assertThat (kindValue ).isNotNull ();
390- Assertions .assertThat (kindValue . toString ()). isEqualTo ( "decimalvalue" );
303+ Assertions .assertThat (kindValue ). hasToString ( expectedKindValue );
391304 }
392305
393306 private OpenAPIModelGenerator setupPayloadGenerator () throws IOException {
0 commit comments