2727package org .springdoc .core .utils ;
2828
2929import java .lang .annotation .Annotation ;
30- import java .nio .charset .Charset ;
31- import java .time .Duration ;
32- import java .time .LocalTime ;
33- import java .time .MonthDay ;
34- import java .time .OffsetTime ;
35- import java .time .Period ;
36- import java .time .Year ;
37- import java .time .YearMonth ;
38- import java .time .ZoneId ;
39- import java .time .ZoneOffset ;
4030import java .util .ArrayList ;
4131import java .util .List ;
42- import java .util .Locale ;
43- import java .util .TimeZone ;
4432import java .util .function .Predicate ;
4533
4634import io .swagger .v3 .core .converter .AnnotatedType ;
35+ import io .swagger .v3 .core .util .PrimitiveType ;
4736import io .swagger .v3 .oas .models .media .ComposedSchema ;
4837import io .swagger .v3 .oas .models .media .Content ;
4938import io .swagger .v3 .oas .models .media .Schema ;
50- import io .swagger .v3 .oas .models .media .StringSchema ;
5139import org .apache .commons .lang3 .ArrayUtils ;
5240import org .apache .commons .lang3 .StringUtils ;
5341import org .jetbrains .annotations .NotNull ;
6452import org .springframework .core .MethodParameter ;
6553import org .springframework .util .CollectionUtils ;
6654
55+ import static io .swagger .v3 .core .util .PrimitiveType .customClasses ;
56+
6757/**
6858 * The type Spring doc utils.
6959 *
@@ -537,18 +527,18 @@ public static void handleSchemaTypes(Content content) {
537527 * Init extra schemas.
538528 */
539529 public SpringDocUtils initExtraSchemas () {
540- replaceWithSchema ( LocalTime . class , new StringSchema (). example ( "14:30:00" ) );
541- replaceWithSchema ( YearMonth . class , new StringSchema (). example ( "2025-03" ) );
542- replaceWithSchema ( MonthDay . class , new StringSchema (). example ( "--03-22" ) );
543- replaceWithSchema ( Year . class , new StringSchema (). example ( "2025" ) );
544- replaceWithSchema ( Duration . class , new StringSchema (). example ( "PT2H30M" ) );
545- replaceWithSchema ( Period . class , new StringSchema (). example ( "P2Y3M" ) );
546- replaceWithSchema ( OffsetTime . class , new StringSchema (). example ( "14:30:00+01:00" ) );
547- replaceWithSchema ( ZoneId . class , new StringSchema (). example ( "Europe/Paris" ) );
548- replaceWithSchema ( ZoneOffset . class , new StringSchema (). example ( "+01:00" ) );
549- replaceWithSchema ( TimeZone . class , new StringSchema (). example ( "GMT" ) );
550- replaceWithSchema ( Charset . class , new StringSchema (). example ( "UTF-8" ) );
551- replaceWithSchema ( Locale . class , new StringSchema (). example ( "en-US" ) );
530+ customClasses (). put ( "java.time.Duration" , PrimitiveType . STRING );
531+ customClasses (). put ( "java.time.LocalTime" , PrimitiveType . STRING );
532+ customClasses (). put ( "java.time.YearMonth" , PrimitiveType . STRING );
533+ customClasses (). put ( "java.time.MonthDay" , PrimitiveType . STRING );
534+ customClasses (). put ( "java.time.Year" , PrimitiveType . STRING );
535+ customClasses (). put ( "java.time.Period" , PrimitiveType . STRING );
536+ customClasses (). put ( "java.time.OffsetTime" , PrimitiveType . STRING );
537+ customClasses (). put ( "java.time.ZoneId" , PrimitiveType . STRING );
538+ customClasses (). put ( "java.time.ZoneOffset" , PrimitiveType . STRING );
539+ customClasses (). put ( "java.util.TimeZone" , PrimitiveType . STRING );
540+ customClasses (). put ( "java.util.Charset" , PrimitiveType . STRING );
541+ customClasses (). put ( "java.util.Locale" , PrimitiveType . STRING );
552542 return this ;
553543 }
554544
@@ -558,10 +548,22 @@ public SpringDocUtils initExtraSchemas() {
558548 * @return the spring doc utils
559549 */
560550 public SpringDocUtils resetExtraSchemas () {
561- SpringDocUtils .getConfig ().removeFromSchemaMap (LocalTime .class , YearMonth .class ,
562- MonthDay .class , Year .class , Duration .class , Period .class , OffsetTime .class ,
563- ZoneId .class , ZoneOffset .class , TimeZone .class , Charset .class , Locale .class );
551+ customClasses ().remove ("java.time.Duration" );
552+ customClasses ().remove ("java.time.LocalTime" );
553+ customClasses ().remove ("java.time.YearMonth" );
554+ customClasses ().remove ("java.time.MonthDay" );
555+ customClasses ().remove ("java.time.Year" );
556+ customClasses ().remove ("java.time.Period" );
557+ customClasses ().remove ("java.time.OffsetTime" );
558+ customClasses ().remove ("java.time.ZoneId" );
559+ customClasses ().remove ("java.time.ZoneOffset" );
560+ customClasses ().remove ("java.util.TimeZone" );
561+ customClasses ().remove ("java.util.Charset" );
562+ customClasses ().remove ("java.util.Locale" );
564563 return this ;
565564 }
565+
566+
566567}
567568
569+
0 commit comments