@@ -354,58 +354,63 @@ private static void setExamples(MediaType mediaType, ExampleObject[] examples) {
354
354
private static MediaType getMediaType (Schema schema , Components components , JsonView jsonViewAnnotation ,
355
355
io .swagger .v3 .oas .annotations .media .Content annotationContent , boolean openapi31 ) {
356
356
MediaType mediaType = new MediaType ();
357
- if (!annotationContent .schema ().hidden ()) {
358
- if (components != null ) {
359
- try {
360
- getSchema (annotationContent , components , jsonViewAnnotation , openapi31 ).ifPresent (mediaType ::setSchema );
361
- if (annotationContent .schemaProperties ().length > 0 ) {
362
- if (mediaType .getSchema () == null ) {
363
- mediaType .schema (new Schema <Object >().type ("object" ));
364
- }
365
- Schema oSchema = mediaType .getSchema ();
366
- for (SchemaProperty sp : annotationContent .schemaProperties ()) {
367
- Class <?> schemaImplementation = sp .schema ().implementation ();
368
- boolean isArray = isArray (annotationContent );
369
- getSchema (sp .schema (), sp .array (), isArray , schemaImplementation , components , jsonViewAnnotation , openapi31 )
370
- .ifPresent (s -> {
371
- if ("array" .equals (oSchema .getType ())) {
372
- oSchema .getItems ().addProperty (sp .name (), s );
373
- }
374
- else {
375
- oSchema .addProperty (sp .name (), s );
376
- }
377
- });
378
-
357
+ if (annotationContent .schema ().hidden ()) {
358
+ return mediaType ;
359
+ }
360
+ if (components == null ) {
361
+ mediaType .setSchema (schema );
362
+ return mediaType ;
363
+ }
364
+ try {
365
+ getSchema (annotationContent , components , jsonViewAnnotation , openapi31 ).ifPresent (mediaType ::setSchema );
366
+ if (annotationContent .schemaProperties ().length > 0 ) {
367
+ if (mediaType .getSchema () == null ) {
368
+ mediaType .schema (new Schema <Object >().type ("object" ));
369
+ }
370
+ Schema oSchema = mediaType .getSchema ();
371
+ for (SchemaProperty sp : annotationContent .schemaProperties ()) {
372
+ Class <?> schemaImplementation = sp .schema ().implementation ();
373
+ boolean isArray = false ;
374
+ if (schemaImplementation == Void .class ) {
375
+ schemaImplementation = sp .array ().schema ().implementation ();
376
+ if (schemaImplementation != Void .class ) {
377
+ isArray = true ;
379
378
}
380
379
}
381
- if (
382
- hasSchemaAnnotation (annotationContent .additionalPropertiesSchema ()) &&
383
- mediaType .getSchema () != null &&
384
- !Boolean .TRUE .equals (mediaType .getSchema ().getAdditionalProperties ()) &&
385
- !Boolean .FALSE .equals (mediaType .getSchema ().getAdditionalProperties ())) {
386
- getSchemaFromAnnotation (annotationContent .additionalPropertiesSchema (), components , jsonViewAnnotation , openapi31 )
387
- .ifPresent (s -> {
388
- if ("array" .equals (mediaType .getSchema ().getType ())) {
389
- mediaType .getSchema ().getItems ().additionalProperties (s );
390
- }
391
- else {
392
- mediaType .getSchema ().additionalProperties (s );
393
- }
394
- }
395
- );
396
- }
397
- }
398
- catch (Exception e ) {
399
- if (isArray (annotationContent ))
400
- mediaType .setSchema (new ArraySchema ().items (new StringSchema ()));
401
- else
402
- mediaType .setSchema (new StringSchema ());
380
+ getSchema (sp .schema (), sp .array (), isArray , schemaImplementation , components , jsonViewAnnotation , openapi31 )
381
+ .ifPresent (s -> {
382
+ if ("array" .equals (oSchema .getType ())) {
383
+ oSchema .getItems ().addProperty (sp .name (), s );
384
+ }
385
+ else {
386
+ oSchema .addProperty (sp .name (), s );
387
+ }
388
+ });
403
389
}
404
390
}
405
- else {
406
- mediaType .setSchema (schema );
391
+ if (
392
+ hasSchemaAnnotation (annotationContent .additionalPropertiesSchema ()) &&
393
+ mediaType .getSchema () != null &&
394
+ !Boolean .TRUE .equals (mediaType .getSchema ().getAdditionalProperties ()) &&
395
+ !Boolean .FALSE .equals (mediaType .getSchema ().getAdditionalProperties ())) {
396
+ getSchemaFromAnnotation (annotationContent .additionalPropertiesSchema (), components , jsonViewAnnotation , openapi31 )
397
+ .ifPresent (s -> {
398
+ if ("array" .equals (mediaType .getSchema ().getType ())) {
399
+ mediaType .getSchema ().getItems ().additionalProperties (s );
400
+ }
401
+ else {
402
+ mediaType .getSchema ().additionalProperties (s );
403
+ }
404
+ }
405
+ );
407
406
}
408
407
}
408
+ catch (Exception e ) {
409
+ if (isArray (annotationContent ))
410
+ mediaType .setSchema (new ArraySchema ().items (new StringSchema ()));
411
+ else
412
+ mediaType .setSchema (new StringSchema ());
413
+ }
409
414
return mediaType ;
410
415
}
411
416
0 commit comments