diff --git a/play-scala-generator/src/main/resources/generators.mustache b/play-scala-generator/src/main/resources/generators.mustache index 3eba3d30..07f7682c 100644 --- a/play-scala-generator/src/main/resources/generators.mustache +++ b/play-scala-generator/src/main/resources/generators.mustache @@ -16,7 +16,7 @@ object Generators extends JsValueGenerators { {{if test_data_aliases}} {{for alias in test_data_aliases}} - def {{alias.generator}} = {{alias.generator_name}}{{/for}}{{/if}} + def {{alias.generator}}{{if alias.generator_type}}{{alias.generator_type}}{{/if}} = {{alias.generator_name}}{{/for}}{{/if}} {{if test_data_classes}} {{for class in test_data_classes}} diff --git a/play-scala-generator/src/main/scala/de/zalando/apifirst/generators/DataGeneratorsStep.scala b/play-scala-generator/src/main/scala/de/zalando/apifirst/generators/DataGeneratorsStep.scala index b3814497..0026e572 100644 --- a/play-scala-generator/src/main/scala/de/zalando/apifirst/generators/DataGeneratorsStep.scala +++ b/play-scala-generator/src/main/scala/de/zalando/apifirst/generators/DataGeneratorsStep.scala @@ -42,6 +42,7 @@ trait DataGeneratorsStep extends EnrichmentStep[Type] { private def containerGenerator(k: Reference, v: Type)(table: DenotationTable): Map[String, Any] = { Map( GENERATOR_NAME -> generatorNameForType(v, table, k), + "generator_type" -> generatorTypeNameForType(v, table, k), "creator_method" -> prepend("create", generator(k, table)), "generator" -> generator(k, table) ) @@ -67,6 +68,11 @@ trait DataGeneratorsStep extends EnrichmentStep[Type] { } ) + private val generatorTypeNameForType: (Type, DenotationTable, Reference) => String = { + case (c: Container, table, k) => containerTypeName(c, table, k) + case _ => "" + } + private val generatorNameForType: (Type, DenotationTable, Reference) => String = { case (s: PrimitiveType, table, _) => primitiveType(s, table) case (c: Container, table, k) => containerType(c, table, k) @@ -92,6 +98,15 @@ trait DataGeneratorsStep extends EnrichmentStep[Type] { } } + private def containerTypeName(c: Container, t: DenotationTable, ref: Reference): String = { + lazy val className = typeNameDenotation(t, c.tpe.name) + c match { + case ArrResult(_, _) => s": Gen[List[$className]]" + case CatchAll(_, _) => s": Gen[Map[String, $className]]" + case _ => "" + } + } + private def primitiveType(tpe: Type, t: DenotationTable) = s"arbitrary[${typeNameDenotation(t, tpe.name)}]" } \ No newline at end of file diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/additional_properties_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/additional_properties_yaml.scala index 0997fed6..f3ccc7ee 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/additional_properties_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/additional_properties_yaml.scala @@ -16,8 +16,8 @@ object Generators extends JsValueGenerators { - def KeyedArraysAdditionalPropertiesGenerator = _genMap[String,KeyedArraysAdditionalPropertiesCatchAll](arbitrary[String], KeyedArraysAdditionalPropertiesCatchAllGenerator) - def KeyedArraysAdditionalPropertiesCatchAllGenerator = Gen.containerOf[List,BigInt](arbitrary[BigInt]) + def KeyedArraysAdditionalPropertiesGenerator: Gen[Map[String, KeyedArraysAdditionalPropertiesCatchAll]] = _genMap[String,KeyedArraysAdditionalPropertiesCatchAll](arbitrary[String], KeyedArraysAdditionalPropertiesCatchAllGenerator) + def KeyedArraysAdditionalPropertiesCatchAllGenerator: Gen[List[BigInt]] = Gen.containerOf[List,BigInt](arbitrary[BigInt]) def createKeyedArraysGenerator = _generate(KeyedArraysGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/basic_polymorphism_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/basic_polymorphism_yaml.scala index ea952c8e..b496ac4e 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/basic_polymorphism_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/basic_polymorphism_yaml.scala @@ -17,7 +17,7 @@ object Generators extends JsValueGenerators { - def ZooTiersOptGenerator = Gen.containerOf[List,Pet](PetGenerator) + def ZooTiersOptGenerator: Gen[List[Pet]] = Gen.containerOf[List,Pet](PetGenerator) def ZooTiersGenerator = Gen.option(ZooTiersOptGenerator) def CatHuntingSkillGenerator = { import CatHuntingSkill._ ; Gen.oneOf(Seq(Clueless, Lazy, Adventurous, Aggressive)) } def PutDummyGenerator = Gen.option(PetGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/cross_spec_references_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/cross_spec_references_yaml.scala index 4f0612da..ad0d1893 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/cross_spec_references_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/cross_spec_references_yaml.scala @@ -36,12 +36,12 @@ object Generators extends JsValueGenerators { def ModelSchemaRootLinksGenerator = Gen.option(ModelSchemaRootLinksOptGenerator) def PetTagsGenerator = Gen.option(PetTagsOptGenerator) def ModelSchemaSilhouetteIdGenerator = { import ModelSchemaSilhouetteId._ ; Gen.oneOf(Seq(Kitchen, Bikini_top, Toys, Nightwear_combination, Bra, One_piece_underwear, Ball, Cleansing, Skincare, Jewellery, Headgear, Bustier, Beach_trouser, Bedroom, Lounge, Nail, Undershirt, Combination_clothing, Gloves, Fragrance, Other_equipment, Fitness, Bathroom, One_piece_nightwear, Sleeping_bag, Coat, Case, Sandals, Ankle_boots, Stocking, Shirt, Backpack, Face_cosmetic, Travel_equipment, Hair, Sneaker, Beauty_equipment, Bikini_combination, Backless_slipper, Beach_accessoires, Scarf, First_shoe, Voucher, Wallet, Peeling, Glasses, Boards, Sun, Shave, Low_shoe, Underwear_combination, Nightdress, Suit_accessoires, Watch, Headphones, Skates, Boots, Jacket, Etui, Night_shirt, Other_accessoires, Vest, Bag, System, Racket, Trouser, Lip_cosmetic, Keychain, Belt, Ballerina_shoe, One_piece_suit, Night_trouser, Skirt, Tights, Beach_shirt, Dress, Bicycle, Protector, Eye_cosmetic, Bathrobe, Bicycle_equipment, Pullover, One_piece_beachwear, Underpant, Living, Cardigan, Corsage, Shoe_accessoires, Umbrella, Pumps, Tent, T_shirt_top, Ski)) } - def PetPhotoUrlsGenerator = Gen.containerOf[List,String](arbitrary[String]) + def PetPhotoUrlsGenerator: Gen[List[String]] = Gen.containerOf[List,String](arbitrary[String]) def ModelSchemaLengthRegisterGenerator = Gen.option(arbitrary[String]) - def ModelSchemaAgeGroupsGenerator = Gen.containerOf[List,ModelSchemaAgeGroupsArrResult](ModelSchemaAgeGroupsArrResultGenerator) + def ModelSchemaAgeGroupsGenerator: Gen[List[ModelSchemaAgeGroupsArrResult]] = Gen.containerOf[List,ModelSchemaAgeGroupsArrResult](ModelSchemaAgeGroupsArrResultGenerator) def PetCategoryGenerator = Gen.option(PetCategoryOptGenerator) def ModelSchemaAgeGroupsArrResultGenerator = { import ModelSchemaAgeGroupsArrResult._ ; Gen.oneOf(Seq(Baby, Kid, Teen, Adult)) } - def PetTagsOptGenerator = Gen.containerOf[List,PetCategoryOpt](PetCategoryOptGenerator) + def PetTagsOptGenerator: Gen[List[PetCategoryOpt]] = Gen.containerOf[List,PetCategoryOpt](PetCategoryOptGenerator) def ModelSchemaRootMetaGenerator = Gen.option(ModelSchemaRootMetaOptGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/error_in_array_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/error_in_array_yaml.scala index 146e466f..c90373a9 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/error_in_array_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/error_in_array_yaml.scala @@ -27,18 +27,18 @@ object Generators extends JsValueGenerators { - def ModelSchemaSpecialDescriptionsOptGenerator = Gen.containerOf[List,String](arbitrary[String]) + def ModelSchemaSpecialDescriptionsOptGenerator: Gen[List[String]] = Gen.containerOf[List,String](arbitrary[String]) def MetaCopyrightGenerator = Gen.option(arbitrary[String]) def ModelSchemaKeywordsGenerator = Gen.option(arbitrary[String]) def ModelSchemaSpecialDescriptionsGenerator = Gen.option(ModelSchemaSpecialDescriptionsOptGenerator) - def ErrorsErrorsOptGenerator = Gen.containerOf[List,Error](ErrorGenerator) + def ErrorsErrorsOptGenerator: Gen[List[Error]] = Gen.containerOf[List,Error](ErrorGenerator) def ModelSchemaRootDataGenerator = Gen.option(ModelSchemaGenerator) def ErrorSourceGenerator = Gen.option(ErrorSourceNameClashGenerator) def ModelSchemaRootLinksGenerator = Gen.option(LinksGenerator) def ModelSchemaSilhouetteIdGenerator = { import ModelSchemaSilhouetteId._ ; Gen.oneOf(Seq(Kitchen, Bikini_top, Toys, Nightwear_combination, Bra, One_piece_underwear, Ball, Cleansing, Skincare, Jewellery, Headgear, Bustier, Beach_trouser, Bedroom, Lounge, Nail, Undershirt, Combination_clothing, Gloves, Fragrance, Other_equipment, Fitness, Bathroom, One_piece_nightwear, Sleeping_bag, Coat, Case, Sandals, Ankle_boots, Stocking, Shirt, Backpack, Face_cosmetic, Travel_equipment, Hair, Sneaker, Beauty_equipment, Bikini_combination, Backless_slipper, Beach_accessoires, Scarf, First_shoe, Voucher, Wallet, Peeling, Glasses, Boards, Sun, Shave, Low_shoe, Underwear_combination, Nightdress, Suit_accessoires, Watch, Headphones, Skates, Boots, Jacket, Etui, Night_shirt, Other_accessoires, Vest, Bag, System, Racket, Trouser, Lip_cosmetic, Keychain, Belt, Ballerina_shoe, One_piece_suit, Night_trouser, Skirt, Tights, Beach_shirt, Dress, Bicycle, Protector, Eye_cosmetic, Bathrobe, Bicycle_equipment, Pullover, One_piece_beachwear, Underpant, Living, Cardigan, Corsage, Shoe_accessoires, Umbrella, Pumps, Tent, T_shirt_top, Ski)) } def ModelSchemaLengthRegisterGenerator = Gen.option(arbitrary[String]) def ErrorsErrorsGenerator = Gen.option(ErrorsErrorsOptGenerator) - def ModelSchemaAgeGroupsGenerator = Gen.containerOf[List,ModelSchemaAgeGroupsArrResult](ModelSchemaAgeGroupsArrResultGenerator) + def ModelSchemaAgeGroupsGenerator: Gen[List[ModelSchemaAgeGroupsArrResult]] = Gen.containerOf[List,ModelSchemaAgeGroupsArrResult](ModelSchemaAgeGroupsArrResultGenerator) def ModelSchemaAgeGroupsArrResultGenerator = { import ModelSchemaAgeGroupsArrResult._ ; Gen.oneOf(Seq(Baby, Kid, Teen, Adult)) } def ModelSchemaRootMetaGenerator = Gen.option(MetaGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/expanded_polymorphism_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/expanded_polymorphism_yaml.scala index 23dacaa2..ebf07dd6 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/expanded_polymorphism_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/expanded_polymorphism_yaml.scala @@ -25,7 +25,7 @@ object Generators extends JsValueGenerators { def PetsGetLimitGenerator = Gen.option(arbitrary[Int]) def PetsGetTagsOptGenerator = _genList(arbitrary[String], "csv") def NewPetTagGenerator = Gen.option(arbitrary[String]) - def PetsGetResponses200Generator = Gen.containerOf[List,Pet](PetGenerator) + def PetsGetResponses200Generator: Gen[List[Pet]] = Gen.containerOf[List,Pet](PetGenerator) def PetsGetTagsGenerator = Gen.option(PetsGetTagsOptGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/full_petstore_api_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/full_petstore_api_yaml.scala index 88e12b81..19a51b95 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/full_petstore_api_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/full_petstore_api_yaml.scala @@ -38,9 +38,9 @@ object Generators extends JsValueGenerators { def NullGenerator = arbitrary[Null] def OrderStatusGenerator = Gen.option(arbitrary[String]) def PetsFindByStatusGetStatusOptGenerator = _genList(arbitrary[String], "multi") - def UsersCreateWithListPostBodyOptGenerator = Gen.containerOf[List,User](UserGenerator) + def UsersCreateWithListPostBodyOptGenerator: Gen[List[User]] = Gen.containerOf[List,User](UserGenerator) def OrderPetIdGenerator = Gen.option(arbitrary[Long]) - def PetsFindByStatusGetResponses200Generator = Gen.containerOf[List,Pet](PetGenerator) + def PetsFindByStatusGetResponses200Generator: Gen[List[Pet]] = Gen.containerOf[List,Pet](PetGenerator) def PetsPostBodyGenerator = Gen.option(PetGenerator) def OrderShipDateGenerator = Gen.option(arbitrary[ZonedDateTime]) def UsersUsernamePutBodyGenerator = Gen.option(UserGenerator) @@ -49,11 +49,11 @@ object Generators extends JsValueGenerators { def PetTagsGenerator = Gen.option(PetTagsOptGenerator) def LongGenerator = arbitrary[Long] def OrderQuantityGenerator = Gen.option(arbitrary[Int]) - def PetPhotoUrlsGenerator = Gen.containerOf[List,String](arbitrary[String]) + def PetPhotoUrlsGenerator: Gen[List[String]] = Gen.containerOf[List,String](arbitrary[String]) def UsersCreateWithListPostBodyGenerator = Gen.option(UsersCreateWithListPostBodyOptGenerator) def PetsFindByStatusGetStatusGenerator = Gen.option(PetsFindByStatusGetStatusOptGenerator) def PetCategoryGenerator = Gen.option(TagGenerator) - def PetTagsOptGenerator = Gen.containerOf[List,Tag](TagGenerator) + def PetTagsOptGenerator: Gen[List[Tag]] = Gen.containerOf[List,Tag](TagGenerator) def createUserGenerator = _generate(UserGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/hackweek_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/hackweek_yaml.scala index f0511a32..f409da8a 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/hackweek_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/hackweek_yaml.scala @@ -27,18 +27,18 @@ object Generators extends JsValueGenerators { - def ModelSchemaSpecialDescriptionsOptGenerator = Gen.containerOf[List,String](arbitrary[String]) + def ModelSchemaSpecialDescriptionsOptGenerator: Gen[List[String]] = Gen.containerOf[List,String](arbitrary[String]) def MetaCopyrightGenerator = Gen.option(arbitrary[String]) def ModelSchemaKeywordsGenerator = Gen.option(arbitrary[String]) def ModelSchemaSpecialDescriptionsGenerator = Gen.option(ModelSchemaSpecialDescriptionsOptGenerator) - def ErrorsErrorsOptGenerator = Gen.containerOf[List,Error](ErrorGenerator) + def ErrorsErrorsOptGenerator: Gen[List[Error]] = Gen.containerOf[List,Error](ErrorGenerator) def ModelSchemaRootDataGenerator = Gen.option(ModelSchemaGenerator) def ErrorSourceGenerator = Gen.option(ErrorSourceNameClashGenerator) def ModelSchemaRootLinksGenerator = Gen.option(LinksGenerator) def ModelSchemaSilhouetteIdGenerator = { import ModelSchemaSilhouetteId._ ; Gen.oneOf(Seq(Kitchen, Bikini_top, Toys, Nightwear_combination, Bra, One_piece_underwear, Ball, Cleansing, Skincare, Jewellery, Headgear, Bustier, Beach_trouser, Bedroom, Lounge, Nail, Undershirt, Combination_clothing, Gloves, Fragrance, Other_equipment, Fitness, Bathroom, One_piece_nightwear, Sleeping_bag, Coat, Case, Sandals, Ankle_boots, Stocking, Shirt, Backpack, Face_cosmetic, Travel_equipment, Hair, Sneaker, Beauty_equipment, Bikini_combination, Backless_slipper, Beach_accessoires, Scarf, First_shoe, Voucher, Wallet, Peeling, Glasses, Boards, Sun, Shave, Low_shoe, Underwear_combination, Nightdress, Suit_accessoires, Watch, Headphones, Skates, Boots, Jacket, Etui, Night_shirt, Other_accessoires, Vest, Bag, System, Racket, Trouser, Lip_cosmetic, Keychain, Belt, Ballerina_shoe, One_piece_suit, Night_trouser, Skirt, Tights, Beach_shirt, Dress, Bicycle, Protector, Eye_cosmetic, Bathrobe, Bicycle_equipment, Pullover, One_piece_beachwear, Underpant, Living, Cardigan, Corsage, Shoe_accessoires, Umbrella, Pumps, Tent, T_shirt_top, Ski)) } def ModelSchemaLengthRegisterGenerator = Gen.option(arbitrary[String]) def ErrorsErrorsGenerator = Gen.option(ErrorsErrorsOptGenerator) - def ModelSchemaAgeGroupsGenerator = Gen.containerOf[List,ModelSchemaAgeGroupsArrResult](ModelSchemaAgeGroupsArrResultGenerator) + def ModelSchemaAgeGroupsGenerator: Gen[List[ModelSchemaAgeGroupsArrResult]] = Gen.containerOf[List,ModelSchemaAgeGroupsArrResult](ModelSchemaAgeGroupsArrResultGenerator) def ModelSchemaAgeGroupsArrResultGenerator = { import ModelSchemaAgeGroupsArrResult._ ; Gen.oneOf(Seq(Baby, Kid, Teen, Adult)) } def ModelSchemaRootMetaGenerator = Gen.option(MetaGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/heroku_petstore_api_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/heroku_petstore_api_yaml.scala index ffbc0970..78470cd5 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/heroku_petstore_api_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/heroku_petstore_api_yaml.scala @@ -26,7 +26,7 @@ object Generators extends JsValueGenerators { def NullGenerator = arbitrary[Null] def BigIntGenerator = arbitrary[BigInt] def PutPetGenerator = Gen.option(PetGenerator) - def GetResponses200Generator = Gen.containerOf[List,Pet](PetGenerator) + def GetResponses200Generator: Gen[List[Pet]] = Gen.containerOf[List,Pet](PetGenerator) def createPetGenerator = _generate(PetGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/instagram_api_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/instagram_api_yaml.scala index e713f531..abf198f6 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/instagram_api_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/instagram_api_yaml.scala @@ -59,21 +59,21 @@ object Generators extends JsValueGenerators { def MediaIdGenerator = Gen.option(arbitrary[BigInt]) def MediaVideosLow_resolutionGenerator = Gen.option(ImageGenerator) def UsersUser_idRelationshipPostActionGenerator = Gen.option(UsersUser_idRelationshipPostActionOptGenerator) - def MediaTagsOptGenerator = Gen.containerOf[List,Tag](TagGenerator) + def MediaTagsOptGenerator: Gen[List[Tag]] = Gen.containerOf[List,Tag](TagGenerator) def MediaImagesGenerator = Gen.option(MediaImagesOptGenerator) def MediaLikesGenerator = Gen.option(MediaLikesOptGenerator) def BigIntNameClashGenerator = arbitrary[BigInt] - def MediaUsers_in_photoOptGenerator = Gen.containerOf[List,MiniProfile](MiniProfileGenerator) - def MediaMedia_idLikesGetResponses200DataOptGenerator = Gen.containerOf[List,Like](LikeGenerator) + def MediaUsers_in_photoOptGenerator: Gen[List[MiniProfile]] = Gen.containerOf[List,MiniProfile](MiniProfileGenerator) + def MediaMedia_idLikesGetResponses200DataOptGenerator: Gen[List[Like]] = Gen.containerOf[List,Like](LikeGenerator) def LocationsSearchGetResponses200DataGenerator = Gen.option(LocationsSearchGetResponses200DataOptGenerator) def MediaComments_escGenerator = Gen.option(MediaComments_OptGenerator) - def MediaSearchGetResponses200DataOptGenerator = Gen.containerOf[List,MediaSearchGetResponses200DataOptArrResult](MediaSearchGetResponses200DataOptArrResultGenerator) + def MediaSearchGetResponses200DataOptGenerator: Gen[List[MediaSearchGetResponses200DataOptArrResult]] = Gen.containerOf[List,MediaSearchGetResponses200DataOptArrResult](MediaSearchGetResponses200DataOptArrResultGenerator) def CommentFromGenerator = Gen.option(MiniProfileGenerator) - def LocationsSearchGetResponses200DataOptGenerator = Gen.containerOf[List,Location](LocationGenerator) + def LocationsSearchGetResponses200DataOptGenerator: Gen[List[Location]] = Gen.containerOf[List,Location](LocationGenerator) def MediaSearchGetResponses200DataGenerator = Gen.option(MediaSearchGetResponses200DataOptGenerator) - def UsersSelfFeedGetResponses200DataOptGenerator = Gen.containerOf[List,Media](MediaGenerator) + def UsersSelfFeedGetResponses200DataOptGenerator: Gen[List[Media]] = Gen.containerOf[List,Media](MediaGenerator) def UsersUser_idRelationshipPostActionOptGenerator = { import UsersUser_idRelationshipPostActionOpt._ ; Gen.oneOf(Seq(Follow, Approve, Unfollow, Block, Unblock)) } - def MediaComments_DataOptGenerator = Gen.containerOf[List,Comment](CommentGenerator) + def MediaComments_DataOptGenerator: Gen[List[Comment]] = Gen.containerOf[List,Comment](CommentGenerator) def UsersUser_idGetResponses200DataGenerator = Gen.option(UserGenerator) def MediaVideosGenerator = Gen.option(MediaVideosOptGenerator) def MediaLocationGenerator = Gen.option(LocationGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/nakadi_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/nakadi_yaml.scala index ad5e8750..7af0fbe9 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/nakadi_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/nakadi_yaml.scala @@ -31,16 +31,16 @@ object Generators extends JsValueGenerators { def TopicsTopicEventsGetStream_timeoutGenerator = Gen.option(arbitrary[Int]) def IntGenerator = arbitrary[Int] def EventEvent_typeGenerator = Gen.option(arbitrary[String]) - def SimpleStreamEventEventsOptGenerator = Gen.containerOf[List,Event](EventGenerator) + def SimpleStreamEventEventsOptGenerator: Gen[List[Event]] = Gen.containerOf[List,Event](EventGenerator) def EventMetaDataParent_idGenerator = Gen.option(arbitrary[UUID]) def EventMetadataGenerator = Gen.option(EventMetaDataNameClashGenerator) def NullGenerator = arbitrary[Null] - def EventMetaDataScopesOptGenerator = Gen.containerOf[List,String](arbitrary[String]) - def TopicsTopicPartitionsGetResponses200Generator = Gen.containerOf[List,TopicPartition](TopicPartitionGenerator) + def EventMetaDataScopesOptGenerator: Gen[List[String]] = Gen.containerOf[List,String](arbitrary[String]) + def TopicsTopicPartitionsGetResponses200Generator: Gen[List[TopicPartition]] = Gen.containerOf[List,TopicPartition](TopicPartitionGenerator) def TopicsTopicEventsBatchPostEventGenerator = Gen.option(EventGenerator) def SimpleStreamEventEventsGenerator = Gen.option(SimpleStreamEventEventsOptGenerator) def EventMetaDataScopesGenerator = Gen.option(EventMetaDataScopesOptGenerator) - def TopicsGetResponses200Generator = Gen.containerOf[List,Topic](TopicGenerator) + def TopicsGetResponses200Generator: Gen[List[Topic]] = Gen.containerOf[List,Topic](TopicGenerator) def createEventMetaDataNameClashGenerator = _generate(EventMetaDataNameClashGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/nested_arrays_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/nested_arrays_yaml.scala index 295459db..bd0519fd 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/nested_arrays_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/nested_arrays_yaml.scala @@ -21,14 +21,14 @@ object Generators extends JsValueGenerators { - def ExampleNestedArraysOptArrResultArrResultGenerator = Gen.containerOf[List,ExampleNestedArraysOptArrResultArrResultArrResult](ExampleNestedArraysOptArrResultArrResultArrResultGenerator) - def ExampleNestedArraysOptGenerator = Gen.containerOf[List,ExampleNestedArraysOptArrResult](ExampleNestedArraysOptArrResultGenerator) - def ExampleMessagesOptGenerator = Gen.containerOf[List,ExampleMessagesOptArrResult](ExampleMessagesOptArrResultGenerator) + def ExampleNestedArraysOptArrResultArrResultGenerator: Gen[List[ExampleNestedArraysOptArrResultArrResultArrResult]] = Gen.containerOf[List,ExampleNestedArraysOptArrResultArrResultArrResult](ExampleNestedArraysOptArrResultArrResultArrResultGenerator) + def ExampleNestedArraysOptGenerator: Gen[List[ExampleNestedArraysOptArrResult]] = Gen.containerOf[List,ExampleNestedArraysOptArrResult](ExampleNestedArraysOptArrResultGenerator) + def ExampleMessagesOptGenerator: Gen[List[ExampleMessagesOptArrResult]] = Gen.containerOf[List,ExampleMessagesOptArrResult](ExampleMessagesOptArrResultGenerator) def ExampleMessagesGenerator = Gen.option(ExampleMessagesOptGenerator) - def ExampleNestedArraysOptArrResultArrResultArrResultGenerator = Gen.containerOf[List,String](arbitrary[String]) - def ExampleNestedArraysOptArrResultGenerator = Gen.containerOf[List,ExampleNestedArraysOptArrResultArrResult](ExampleNestedArraysOptArrResultArrResultGenerator) + def ExampleNestedArraysOptArrResultArrResultArrResultGenerator: Gen[List[String]] = Gen.containerOf[List,String](arbitrary[String]) + def ExampleNestedArraysOptArrResultGenerator: Gen[List[ExampleNestedArraysOptArrResultArrResult]] = Gen.containerOf[List,ExampleNestedArraysOptArrResultArrResult](ExampleNestedArraysOptArrResultArrResultGenerator) def ExampleNestedArraysGenerator = Gen.option(ExampleNestedArraysOptGenerator) - def ExampleMessagesOptArrResultGenerator = Gen.containerOf[List,Activity](ActivityGenerator) + def ExampleMessagesOptArrResultGenerator: Gen[List[Activity]] = Gen.containerOf[List,Activity](ActivityGenerator) def ActivityActionsGenerator = Gen.option(arbitrary[String]) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/options_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/options_yaml.scala index 29901fc5..6e1f3135 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/options_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/options_yaml.scala @@ -14,7 +14,7 @@ object Generators extends JsValueGenerators { - def BasicRequiredGenerator = Gen.containerOf[List,String](arbitrary[String]) + def BasicRequiredGenerator: Gen[List[String]] = Gen.containerOf[List,String](arbitrary[String]) def BasicOptionalGenerator = Gen.option(BasicRequiredGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/security_api_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/security_api_yaml.scala index 0a67afef..3f9fd067 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/security_api_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/security_api_yaml.scala @@ -17,7 +17,7 @@ object Generators extends JsValueGenerators { def PetsIdGetIdGenerator = _genList(arbitrary[String], "csv") - def PetsIdGetResponses200Generator = Gen.containerOf[List,Pet](PetGenerator) + def PetsIdGetResponses200Generator: Gen[List[Pet]] = Gen.containerOf[List,Pet](PetGenerator) def PetTagGenerator = Gen.option(arbitrary[String]) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/simple_petstore_api_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/simple_petstore_api_yaml.scala index 205cee8d..ea2011b6 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/simple_petstore_api_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/simple_petstore_api_yaml.scala @@ -27,7 +27,7 @@ object Generators extends JsValueGenerators { def PetsGetLimitGenerator = Gen.option(arbitrary[Int]) def NewPetIdGenerator = Gen.option(arbitrary[Long]) def PetsGetTagsOptGenerator = _genList(arbitrary[String], "csv") - def PetsGetResponses200Generator = Gen.containerOf[List,Pet](PetGenerator) + def PetsGetResponses200Generator: Gen[List[Pet]] = Gen.containerOf[List,Pet](PetGenerator) def PetsGetTagsGenerator = Gen.option(PetsGetTagsOptGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/split_petstore_api_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/split_petstore_api_yaml.scala index 47a792ed..a2771ca7 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/split_petstore_api_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/split_petstore_api_yaml.scala @@ -38,9 +38,9 @@ object Generators extends JsValueGenerators { def NullGenerator = arbitrary[Null] def OrderStatusGenerator = Gen.option(arbitrary[String]) def PetsFindByStatusGetStatusOptGenerator = _genList(arbitrary[String], "multi") - def UsersCreateWithListPostBodyOptGenerator = Gen.containerOf[List,User](UserGenerator) + def UsersCreateWithListPostBodyOptGenerator: Gen[List[User]] = Gen.containerOf[List,User](UserGenerator) def OrderPetIdGenerator = Gen.option(arbitrary[Long]) - def PetsFindByStatusGetResponses200Generator = Gen.containerOf[List,Pet](PetGenerator) + def PetsFindByStatusGetResponses200Generator: Gen[List[Pet]] = Gen.containerOf[List,Pet](PetGenerator) def PetsPostBodyGenerator = Gen.option(PetGenerator) def OrderShipDateGenerator = Gen.option(arbitrary[ZonedDateTime]) def UsersUsernamePutBodyGenerator = Gen.option(UserGenerator) @@ -49,11 +49,11 @@ object Generators extends JsValueGenerators { def PetTagsGenerator = Gen.option(PetTagsOptGenerator) def LongGenerator = arbitrary[Long] def OrderQuantityGenerator = Gen.option(arbitrary[Int]) - def PetPhotoUrlsGenerator = Gen.containerOf[List,String](arbitrary[String]) + def PetPhotoUrlsGenerator: Gen[List[String]] = Gen.containerOf[List,String](arbitrary[String]) def UsersCreateWithListPostBodyGenerator = Gen.option(UsersCreateWithListPostBodyOptGenerator) def PetsFindByStatusGetStatusGenerator = Gen.option(PetsFindByStatusGetStatusOptGenerator) def PetCategoryGenerator = Gen.option(PetCategoryOptGenerator) - def PetTagsOptGenerator = Gen.containerOf[List,PetCategoryOpt](PetCategoryOptGenerator) + def PetTagsOptGenerator: Gen[List[PetCategoryOpt]] = Gen.containerOf[List,PetCategoryOpt](PetCategoryOptGenerator) def createPetCategoryOptGenerator = _generate(PetCategoryOptGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/type_deduplication_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/type_deduplication_yaml.scala index 4291c349..c543fed8 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/type_deduplication_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/type_deduplication_yaml.scala @@ -30,13 +30,13 @@ object Generators extends JsValueGenerators { def NullGenerator = arbitrary[Null] def PlantPlant_idGenerator = Gen.option(arbitrary[String]) def PlantsGetLimitGenerator = Gen.option(arbitrary[BigInt]) - def UsersGetResponses200Generator = Gen.containerOf[List,User](UserGenerator) + def UsersGetResponses200Generator: Gen[List[User]] = Gen.containerOf[List,User](UserGenerator) def ErrorCodeGenerator = Gen.option(arbitrary[Int]) - def PlantsGetResponses200Generator = Gen.containerOf[List,Plant](PlantGenerator) - def AreasGetResponses200Generator = Gen.containerOf[List,Area](AreaGenerator) + def PlantsGetResponses200Generator: Gen[List[Plant]] = Gen.containerOf[List,Plant](PlantGenerator) + def AreasGetResponses200Generator: Gen[List[Area]] = Gen.containerOf[List,Area](AreaGenerator) def PlantsGetOffsetGenerator = Gen.option(arbitrary[BigInt]) - def PlantsPlant_idPicturesGetResponses200Generator = Gen.containerOf[List,String](arbitrary[String]) - def PlantsPlant_idWateringsGetResponses200Generator = Gen.containerOf[List,Watering](WateringGenerator) + def PlantsPlant_idPicturesGetResponses200Generator: Gen[List[String]] = Gen.containerOf[List,String](arbitrary[String]) + def PlantsPlant_idWateringsGetResponses200Generator: Gen[List[Watering]] = Gen.containerOf[List,Watering](WateringGenerator) def createSunlightNeedsGenerator = _generate(SunlightNeedsGenerator) diff --git a/play-scala-generator/src/test/resources/expected_results/test_data/uber_api_yaml.scala b/play-scala-generator/src/test/resources/expected_results/test_data/uber_api_yaml.scala index eeffc3e4..71c96478 100644 --- a/play-scala-generator/src/test/resources/expected_results/test_data/uber_api_yaml.scala +++ b/play-scala-generator/src/test/resources/expected_results/test_data/uber_api_yaml.scala @@ -28,10 +28,10 @@ object Generators extends JsValueGenerators { def ProfilePictureGenerator = Gen.option(arbitrary[String]) def ErrorCodeGenerator = Gen.option(arbitrary[Int]) def EstimatesTimeGetCustomer_uuidGenerator = Gen.option(arbitrary[UUID]) - def ProductsGetResponses200Generator = Gen.containerOf[List,Product](ProductGenerator) + def ProductsGetResponses200Generator: Gen[List[Product]] = Gen.containerOf[List,Product](ProductGenerator) def PriceEstimateHigh_estimateGenerator = Gen.option(arbitrary[BigDecimal]) - def EstimatesPriceGetResponses200Generator = Gen.containerOf[List,PriceEstimate](PriceEstimateGenerator) - def ActivitiesHistoryOptGenerator = Gen.containerOf[List,Activity](ActivityGenerator) + def EstimatesPriceGetResponses200Generator: Gen[List[PriceEstimate]] = Gen.containerOf[List,PriceEstimate](PriceEstimateGenerator) + def ActivitiesHistoryOptGenerator: Gen[List[Activity]] = Gen.containerOf[List,Activity](ActivityGenerator) def createActivityGenerator = _generate(ActivityGenerator) diff --git a/play-scala-generator/src/test/scala/de/zalando/apifirst/generators/AstScalaPlayEnricherTest.scala b/play-scala-generator/src/test/scala/de/zalando/apifirst/generators/AstScalaPlayEnricherTest.scala index a2233f10..b456ebd7 100644 --- a/play-scala-generator/src/test/scala/de/zalando/apifirst/generators/AstScalaPlayEnricherTest.scala +++ b/play-scala-generator/src/test/scala/de/zalando/apifirst/generators/AstScalaPlayEnricherTest.scala @@ -77,12 +77,12 @@ class AstScalaPlayEnricherTest extends FunSpec with MustMatchers { val expected = Map( "definitions" / "Cat" / "AllOf1" -> Map("common" -> Map("type_name" -> "CatAllOf1", "fields" -> List(Field("definitions" / "Cat" / "huntingSkill", Str(None, TypeMeta(None, List())))), "member_name" -> "CatAllOf1")), - "definitions" / "Cat" -> Map("common" -> Map("type_name" -> "Cat", "fields" -> List(Field("definitions" / "Pet" / "name", Str(None, TypeMeta(None, List()))), Field("definitions" / "Pet" / "petType", Str(None, TypeMeta(None, List()))), Field("definitions" / "Cat" / "huntingSkill", Str(None, TypeMeta(None, List())))), "member_name" -> "Cat"), "classes" -> Map("name" -> "Cat", "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String"), Map("name" -> "huntingSkill", "type_name" -> "String")), "imports" -> Set(), "trait" -> Some(Map("name" -> "IPet"))), "test_data_classes" -> Map("generator" -> "CatGenerator", "fields" -> List(Map("name" -> "name", "generator" -> "arbitrary[String]"), Map("name" -> "petType", "generator" -> "arbitrary[String]"), Map("name" -> "huntingSkill", "generator" -> "arbitrary[String]")), "class_name" -> "Cat", "generator_name" -> "CatGenerator", "creator_method" -> "createCatGenerator")), + "definitions" / "Cat" -> Map("common" -> Map("type_name" -> "Cat", "fields" -> List(Field("definitions" / "Pet" / "name", Str(None, TypeMeta(None, List()))), Field("definitions" / "Pet" / "petType", Str(None, TypeMeta(None, List()))), Field("definitions" / "Cat" / "huntingSkill", Str(None, TypeMeta(None, List())))), "member_name" -> "Cat"), "classes" -> Map("name" -> "Cat", "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String"), Map("name" -> "huntingSkill", "type_name" -> "String")), "imports" -> Set(), "trait" -> Some(Map("name" -> "IPet"))), "test_data_classes" -> Map("generator" -> "CatGenerator", "generator_type" -> "", "fields" -> List(Map("name" -> "name", "generator" -> "arbitrary[String]"), Map("name" -> "petType", "generator" -> "arbitrary[String]"), Map("name" -> "huntingSkill", "generator" -> "arbitrary[String]")), "class_name" -> "Cat", "generator_name" -> "CatGenerator", "creator_method" -> "createCatGenerator")), "definitions" / "Dog" / "AllOf1" -> Map("common" -> Map("type_name" -> "DogAllOf1", "fields" -> List(Field("definitions" / "Dog" / "packSize", Intgr(TypeMeta(None, List())))), "member_name" -> "DogAllOf1")), - "definitions" / "Dog" -> Map("common" -> Map("type_name" -> "Dog", "fields" -> List(Field("definitions" / "Pet" / "name", Str(None, TypeMeta(None, List()))), Field("definitions" / "Pet" / "petType", Str(None, TypeMeta(None, List()))), Field("definitions" / "Dog" / "packSize", Intgr(TypeMeta(None, List())))), "member_name" -> "Dog"), "classes" -> Map("name" -> "Dog", "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String"), Map("name" -> "packSize", "type_name" -> "Int")), "imports" -> Set(), "trait" -> Some(Map("name" -> "IPet"))), "test_data_classes" -> Map("generator" -> "DogGenerator", "fields" -> List(Map("name" -> "name", "generator" -> "arbitrary[String]"), Map("name" -> "petType", "generator" -> "arbitrary[String]"), Map("name" -> "packSize", "generator" -> "arbitrary[Int]")), "class_name" -> "Dog", "generator_name" -> "DogGenerator", "creator_method" -> "createDogGenerator")), - "definitions" / "CatNDog" -> Map("common" -> Map("type_name" -> "CatNDog", "fields" -> List(Field("definitions" / "Pet" / "name", Str(None, TypeMeta(None, List()))), Field("definitions" / "Pet" / "petType", Str(None, TypeMeta(None, List()))), Field("definitions" / "Dog" / "packSize", Intgr(TypeMeta(None, List()))), Field("definitions" / "Cat" / "huntingSkill", Str(None, TypeMeta(None, List())))), "member_name" -> "CatNDog"), "classes" -> Map("name" -> "CatNDog", "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String"), Map("name" -> "packSize", "type_name" -> "Int"), Map("name" -> "huntingSkill", "type_name" -> "String")), "imports" -> Set(), "trait" -> Some(Map("name" -> "IPet"))), "test_data_classes" -> Map("generator" -> "CatNDogGenerator", "fields" -> List(Map("name" -> "name", "generator" -> "arbitrary[String]"), Map("name" -> "petType", "generator" -> "arbitrary[String]"), Map("name" -> "packSize", "generator" -> "arbitrary[Int]"), Map("name" -> "huntingSkill", "generator" -> "arbitrary[String]")), "class_name" -> "CatNDog", "generator_name" -> "CatNDogGenerator", "creator_method" -> "createCatNDogGenerator")), - "definitions" / "Pet" -> Map("common" -> Map("type_name" -> "Pet", "fields" -> List(Field("definitions" / "Pet" / "name", Str(None, TypeMeta(None, List()))), Field("definitions" / "Pet" / "petType", Str(None, TypeMeta(None, List())))), "member_name" -> "Pet", "abstract_type_name" -> "IPet"), "classes" -> Map("name" -> "Pet", "abstract_name" -> "IPet", "trait" -> Some(Map("name" -> "IPet")), "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String")), "imports" -> Set()), "traits" -> Map("name" -> "Pet", "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String")), "imports" -> Set(), "abstract_name" -> "IPet"), "test_data_classes" -> Map("generator" -> "PetGenerator", "fields" -> List(Map("name" -> "name", "generator" -> "arbitrary[String]"), Map("name" -> "petType", "generator" -> "arbitrary[String]")), "class_name" -> "Pet", "generator_name" -> "PetGenerator", "creator_method" -> "createPetGenerator")), - "definitions" / "Labrador" -> Map("common" -> Map("type_name" -> "Labrador", "fields" -> List(Field("definitions" / "Pet" / "name", Str(None, TypeMeta(None, List()))), Field("definitions" / "Pet" / "petType", Str(None, TypeMeta(None, List()))), Field("definitions" / "Dog" / "packSize", Intgr(TypeMeta(None, List()))), Field("definitions" / "Labrador" / "cuteness", Intgr(TypeMeta(None, List())))), "member_name" -> "Labrador"), "classes" -> Map("name" -> "Labrador", "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String"), Map("name" -> "packSize", "type_name" -> "Int"), Map("name" -> "cuteness", "type_name" -> "Int")), "imports" -> Set(), "trait" -> Some(Map("name" -> "IPet"))), "test_data_classes" -> Map("generator" -> "LabradorGenerator", "fields" -> List(Map("name" -> "name", "generator" -> "arbitrary[String]"), Map("name" -> "petType", "generator" -> "arbitrary[String]"), Map("name" -> "packSize", "generator" -> "arbitrary[Int]"), Map("name" -> "cuteness", "generator" -> "arbitrary[Int]")), "class_name" -> "Labrador", "generator_name" -> "LabradorGenerator", "creator_method" -> "createLabradorGenerator")), + "definitions" / "Dog" -> Map("common" -> Map("type_name" -> "Dog", "fields" -> List(Field("definitions" / "Pet" / "name", Str(None, TypeMeta(None, List()))), Field("definitions" / "Pet" / "petType", Str(None, TypeMeta(None, List()))), Field("definitions" / "Dog" / "packSize", Intgr(TypeMeta(None, List())))), "member_name" -> "Dog"), "classes" -> Map("name" -> "Dog", "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String"), Map("name" -> "packSize", "type_name" -> "Int")), "imports" -> Set(), "trait" -> Some(Map("name" -> "IPet"))), "test_data_classes" -> Map("generator" -> "DogGenerator", "generator_type" -> "", "fields" -> List(Map("name" -> "name", "generator" -> "arbitrary[String]"), Map("name" -> "petType", "generator" -> "arbitrary[String]"), Map("name" -> "packSize", "generator" -> "arbitrary[Int]")), "class_name" -> "Dog", "generator_name" -> "DogGenerator", "creator_method" -> "createDogGenerator")), + "definitions" / "CatNDog" -> Map("common" -> Map("type_name" -> "CatNDog", "fields" -> List(Field("definitions" / "Pet" / "name", Str(None, TypeMeta(None, List()))), Field("definitions" / "Pet" / "petType", Str(None, TypeMeta(None, List()))), Field("definitions" / "Dog" / "packSize", Intgr(TypeMeta(None, List()))), Field("definitions" / "Cat" / "huntingSkill", Str(None, TypeMeta(None, List())))), "member_name" -> "CatNDog"), "classes" -> Map("name" -> "CatNDog", "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String"), Map("name" -> "packSize", "type_name" -> "Int"), Map("name" -> "huntingSkill", "type_name" -> "String")), "imports" -> Set(), "trait" -> Some(Map("name" -> "IPet"))), "test_data_classes" -> Map("generator" -> "CatNDogGenerator", "generator_type" -> "", "fields" -> List(Map("name" -> "name", "generator" -> "arbitrary[String]"), Map("name" -> "petType", "generator" -> "arbitrary[String]"), Map("name" -> "packSize", "generator" -> "arbitrary[Int]"), Map("name" -> "huntingSkill", "generator" -> "arbitrary[String]")), "class_name" -> "CatNDog", "generator_name" -> "CatNDogGenerator", "creator_method" -> "createCatNDogGenerator")), + "definitions" / "Pet" -> Map("common" -> Map("type_name" -> "Pet", "fields" -> List(Field("definitions" / "Pet" / "name", Str(None, TypeMeta(None, List()))), Field("definitions" / "Pet" / "petType", Str(None, TypeMeta(None, List())))), "member_name" -> "Pet", "abstract_type_name" -> "IPet"), "classes" -> Map("name" -> "Pet", "abstract_name" -> "IPet", "trait" -> Some(Map("name" -> "IPet")), "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String")), "imports" -> Set()), "traits" -> Map("name" -> "Pet", "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String")), "imports" -> Set(), "abstract_name" -> "IPet"), "test_data_classes" -> Map("generator" -> "PetGenerator", "generator_type" -> "", "fields" -> List(Map("name" -> "name", "generator" -> "arbitrary[String]"), Map("name" -> "petType", "generator" -> "arbitrary[String]")), "class_name" -> "Pet", "generator_name" -> "PetGenerator", "creator_method" -> "createPetGenerator")), + "definitions" / "Labrador" -> Map("common" -> Map("type_name" -> "Labrador", "fields" -> List(Field("definitions" / "Pet" / "name", Str(None, TypeMeta(None, List()))), Field("definitions" / "Pet" / "petType", Str(None, TypeMeta(None, List()))), Field("definitions" / "Dog" / "packSize", Intgr(TypeMeta(None, List()))), Field("definitions" / "Labrador" / "cuteness", Intgr(TypeMeta(None, List())))), "member_name" -> "Labrador"), "classes" -> Map("name" -> "Labrador", "fields" -> List(Map("name" -> "name", "type_name" -> "String"), Map("name" -> "petType", "type_name" -> "String"), Map("name" -> "packSize", "type_name" -> "Int"), Map("name" -> "cuteness", "type_name" -> "Int")), "imports" -> Set(), "trait" -> Some(Map("name" -> "IPet"))), "test_data_classes" -> Map("generator" -> "LabradorGenerator", "generator_type" -> "", "fields" -> List(Map("name" -> "name", "generator" -> "arbitrary[String]"), Map("name" -> "petType", "generator" -> "arbitrary[String]"), Map("name" -> "packSize", "generator" -> "arbitrary[Int]"), Map("name" -> "cuteness", "generator" -> "arbitrary[Int]")), "class_name" -> "Labrador", "generator_name" -> "LabradorGenerator", "creator_method" -> "createLabradorGenerator")), "definitions" / "Labrador" / "AllOf1" -> Map("common" -> Map("type_name" -> "LabradorAllOf1", "fields" -> List(Field("definitions" / "Labrador" / "cuteness", Intgr(TypeMeta(None, List())))), "member_name" -> "LabradorAllOf1")) ) result mustBe expected diff --git a/play-scala-generator/src/test/scala/de/zalando/apifirst/generators/ScalaGeneratorsTest.scala b/play-scala-generator/src/test/scala/de/zalando/apifirst/generators/ScalaGeneratorsTest.scala index 75dcaea5..52f9231e 100644 --- a/play-scala-generator/src/test/scala/de/zalando/apifirst/generators/ScalaGeneratorsTest.scala +++ b/play-scala-generator/src/test/scala/de/zalando/apifirst/generators/ScalaGeneratorsTest.scala @@ -104,7 +104,7 @@ class ScalaGeneratorsTest extends FunSpec with MustMatchers { |import scala.collection.immutable.Map |object Generators extends JsValueGenerators { | def createAllGenerator = _generate(AllGenerator) - | def AllGenerator = _genMap[String,Boolean](arbitrary[String], arbitrary[Boolean]) + | def AllGenerator: Gen[Map[String, Boolean]] = _genMap[String,Boolean](arbitrary[String], arbitrary[Boolean]) | def _generate[T](gen: Gen[T]) = (count: Int) => for (i <- 1 to count) yield gen.sample | def _genMap[K,V](keyGen: Gen[K], valGen: Gen[V]): Gen[Map[K,V]] = for { | keys <- Gen.containerOf[List,K](keyGen)