@@ -527,14 +527,6 @@ object JsonCodecMaker {
527
527
*/
528
528
def makeCirceLike [A ]: JsonValueCodec [A ] = macro Impl .makeCirceLike[A ]
529
529
530
- /**
531
- * Replacements for the `make` call preconfigured to behave as expected by openapi specifications.
532
- * */
533
- def makeOpenapiLike [A ]: JsonValueCodec [A ] = macro Impl .makeOpenapiLike[A ]
534
- def makeOpenapiEnumLike [A ]: JsonValueCodec [A ] = macro Impl .makeOpenapiEnumLike[A ]
535
- def makeOpenapiADTLikeDefaultMapping [A ](discriminator : String ): JsonValueCodec [A ] = macro Impl .makeOpenapiADTLikeDefaultMapping[A ]
536
- def makeOpenapiADTLike [A ](discriminator : String , mapping : PartialFunction [String , String ]): JsonValueCodec [A ] = macro Impl .makeOpenapiADTLike[A ]
537
-
538
530
/**
539
531
* A replacement for the `make` call with the
540
532
* `CodecMakerConfig.withTransientEmpty(false).withTransientDefault(false).withTransientNone(false).withDiscriminatorFieldName(None).withAdtLeafClassNameMapper(x => enforce_snake_case(simpleClassName(x))).withFieldNameMapper(enforce_snake_case).withJavaEnumValueNameMapper(enforce_snake_case)`
@@ -545,6 +537,49 @@ object JsonCodecMaker {
545
537
*/
546
538
def makeCirceLikeSnakeCased [A ]: JsonValueCodec [A ] = macro Impl .makeCirceLikeSnakeCased[A ]
547
539
540
+ /**
541
+ * Replacements for the `make` call preconfigured to behave as expected by openapi specifications:
542
+ * `CodecMakerConfig.withTransientEmpty(false).withTransientDefault(false).withRequireCollectionFields(true).withAllowRecursiveTypes(true)`
543
+ *
544
+ * @tparam A a type that should be encoded and decoded by the derived codec
545
+ * @return an instance of the derived codec
546
+ */
547
+ def makeOpenapiLike [A ]: JsonValueCodec [A ] = macro Impl .makeOpenapiLike1[A ]
548
+
549
+ /**
550
+ * Replacements for the `make` call preconfigured to behave as expected by openapi specifications:
551
+ * `CodecMakerConfig.withTransientEmpty(false).withTransientDefault(false).withRequireCollectionFields(true).withAllowRecursiveTypes(true)`
552
+ * with a privided discriminator field name.
553
+ *
554
+ * @tparam A a type that should be encoded and decoded by the derived codec
555
+ * @param discriminatorFieldName a name of discriminator field
556
+ * @return an instance of the derived codec
557
+ */
558
+ def makeOpenapiLike [A ](discriminatorFieldName : String ): JsonValueCodec [A ] = macro Impl .makeOpenapiLike2[A ]
559
+
560
+ /**
561
+ * Replacements for the `make` call preconfigured to behave as expected by openapi specifications:
562
+ * `CodecMakerConfig.withTransientEmpty(false).withTransientDefault(false).withRequireCollectionFields(true).withAllowRecursiveTypes(true)`
563
+ * with a privided discriminator field name and an ADT leaf-class name mapper with an applied function
564
+ * that truncates to simple class name
565
+ *
566
+ * @tparam A a type that should be encoded and decoded by the derived codec
567
+ * @param discriminatorFieldName a name of discriminator field
568
+ * @param adtLeafClassNameMapper the function of mapping from string of case class/object full name to string value of
569
+ * discriminator field
570
+ * @return an instance of the derived codec
571
+ */
572
+ def makeOpenapiLike [A ](discriminatorFieldName : String , adtLeafClassNameMapper : PartialFunction [String , String ]): JsonValueCodec [A ] = macro Impl .makeOpenapiLike3[A ]
573
+
574
+ /**
575
+ * Replacements for the `make` call preconfigured to behave as expected by openapi specifications:
576
+ * `CodecMakerConfig.withTransientEmpty(false).withTransientDefault(false).withRequireCollectionFields(true).withAllowRecursiveTypes(true).withDiscriminatorFieldName(scala.None))`
577
+ *
578
+ * @tparam A a type that should be encoded and decoded by the derived codec
579
+ * @return an instance of the derived codec
580
+ */
581
+ def makeOpenapiLikeWithoutDiscriminator [A ]: JsonValueCodec [A ] = macro Impl .makeOpenapiLikeWithoutDiscriminator[A ]
582
+
548
583
/**
549
584
* Derives a codec for JSON values for the specified type `A` and a provided derivation configuration.
550
585
*
@@ -578,23 +613,25 @@ object JsonCodecMaker {
578
613
make(c)(CodecMakerConfig .withTransientEmpty(false ).withTransientDefault(false ).withTransientNone(false )
579
614
.withDiscriminatorFieldName(None ).withCirceLikeObjectEncoding(true ))
580
615
581
- def makeOpenapiLike [A : c.WeakTypeTag ](c : blackbox.Context ): c.Expr [JsonValueCodec [A ]] =
616
+ def makeOpenapiLike1 [A : c.WeakTypeTag ](c : blackbox.Context ): c.Expr [JsonValueCodec [A ]] =
582
617
make(c)(CodecMakerConfig .withTransientEmpty(false ).withTransientDefault(false )
583
618
.withRequireCollectionFields(true ).withAllowRecursiveTypes(true ))
584
619
585
- def makeOpenapiEnumLike [A : c.WeakTypeTag ](c : blackbox.Context ): c.Expr [JsonValueCodec [A ]] =
620
+ def makeOpenapiLike2 [A : c.WeakTypeTag ](c : blackbox.Context )( discriminatorFieldName : c. Expr [ String ] ): c.Expr [JsonValueCodec [A ]] =
586
621
make(c)(CodecMakerConfig .withTransientEmpty(false ).withTransientDefault(false )
587
- .withRequireCollectionFields(true ).withAllowRecursiveTypes(true ).withDiscriminatorFieldName(scala.None ))
622
+ .withRequireCollectionFields(true ).withAllowRecursiveTypes(true )
623
+ .withRequireDiscriminatorFirst(false ).withDiscriminatorFieldName(Some (c.eval(c.Expr [String ](c.untypecheck(discriminatorFieldName.tree.duplicate))))))
588
624
589
- def makeOpenapiADTLikeDefaultMapping [A : c.WeakTypeTag ](c : blackbox.Context )(discriminator : c.Expr [String ]): c.Expr [JsonValueCodec [A ]] =
625
+ def makeOpenapiLike3 [A : c.WeakTypeTag ](c : blackbox.Context )(discriminatorFieldName : c.Expr [String ],
626
+ adtLeafClassNameMapper : c.Expr [PartialFunction [String , String ]]): c.Expr [JsonValueCodec [A ]] =
590
627
make(c)(CodecMakerConfig .withTransientEmpty(false ).withTransientDefault(false )
591
628
.withRequireCollectionFields(true ).withAllowRecursiveTypes(true )
592
- .withRequireDiscriminatorFirst(false ).withDiscriminatorFieldName(Some (c.eval(c.Expr [String ](c.untypecheck(discriminator.tree.duplicate))))))
629
+ .withRequireDiscriminatorFirst(false ).withDiscriminatorFieldName(Some (c.eval(c.Expr [String ](c.untypecheck(discriminatorFieldName.tree.duplicate)))))
630
+ .withAdtLeafClassNameMapper(x => c.eval(c.Expr [PartialFunction [String , String ]](c.untypecheck(adtLeafClassNameMapper.tree.duplicate))).apply(simpleClassName(x))))
593
631
594
- def makeOpenapiADTLike [A : c.WeakTypeTag ](c : blackbox.Context )( discriminator : c. Expr [ String ], mapping : c. Expr [ PartialFunction [ String , String ]] ): c.Expr [JsonValueCodec [A ]] =
632
+ def makeOpenapiLikeWithoutDiscriminator [A : c.WeakTypeTag ](c : blackbox.Context ): c.Expr [JsonValueCodec [A ]] =
595
633
make(c)(CodecMakerConfig .withTransientEmpty(false ).withTransientDefault(false )
596
- .withRequireCollectionFields(true ).withAllowRecursiveTypes(true )
597
- .withRequireDiscriminatorFirst(false ).withDiscriminatorFieldName(Some (c.eval(c.Expr [String ](c.untypecheck(discriminator.tree.duplicate))))).withAdtLeafClassNameMapper(x => c.eval(c.Expr [PartialFunction [String , String ]](c.untypecheck(mapping.tree.duplicate))).apply(com.github.plokhotnyuk.jsoniter_scala.macros.JsonCodecMaker .simpleClassName(x))))
634
+ .withRequireCollectionFields(true ).withAllowRecursiveTypes(true ).withDiscriminatorFieldName(scala.None ))
598
635
599
636
def makeCirceLikeSnakeCased [A : c.WeakTypeTag ](c : blackbox.Context ): c.Expr [JsonValueCodec [A ]] =
600
637
make(c)(CodecMakerConfig .withTransientEmpty(false ).withTransientDefault(false ).withTransientNone(false )
0 commit comments