@@ -354,64 +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 = false ;
369
- if (schemaImplementation == Void .class ) {
370
- schemaImplementation = sp .array ().schema ().implementation ();
371
- if (schemaImplementation != Void .class ) {
372
- isArray = true ;
373
- }
374
- }
375
- getSchema (sp .schema (), sp .array (), isArray , schemaImplementation , components , jsonViewAnnotation , openapi31 )
376
- .ifPresent (s -> {
377
- if ("array" .equals (oSchema .getType ())) {
378
- oSchema .getItems ().addProperty (sp .name (), s );
379
- }
380
- else {
381
- oSchema .addProperty (sp .name (), s );
382
- }
383
- });
384
-
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 ;
385
378
}
386
379
}
387
- if (
388
- hasSchemaAnnotation (annotationContent .additionalPropertiesSchema ()) &&
389
- mediaType .getSchema () != null &&
390
- !Boolean .TRUE .equals (mediaType .getSchema ().getAdditionalProperties ()) &&
391
- !Boolean .FALSE .equals (mediaType .getSchema ().getAdditionalProperties ())) {
392
- getSchemaFromAnnotation (annotationContent .additionalPropertiesSchema (), components , jsonViewAnnotation , openapi31 )
393
- .ifPresent (s -> {
394
- if ("array" .equals (mediaType .getSchema ().getType ())) {
395
- mediaType .getSchema ().getItems ().additionalProperties (s );
396
- }
397
- else {
398
- mediaType .getSchema ().additionalProperties (s );
399
- }
400
- }
401
- );
402
- }
403
- }
404
- catch (Exception e ) {
405
- if (isArray (annotationContent ))
406
- mediaType .setSchema (new ArraySchema ().items (new StringSchema ()));
407
- else
408
- 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
+ });
409
389
}
410
390
}
411
- else {
412
- 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
+ );
413
406
}
414
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
+ }
415
414
return mediaType ;
416
415
}
417
416
0 commit comments