From 325816ac5e445d32444f13647dc5b3abdef1ef9a Mon Sep 17 00:00:00 2001 From: patrick brisbin Date: Fri, 29 Mar 2024 09:29:39 -0400 Subject: [PATCH] Exercise minItems/NonEmpty in golden tests --- specifications/z_complex_self_made_example.yml | 6 ++++++ testing/golden-output/src/OpenAPI/TypeAlias.hs | 5 +++++ testing/golden-output/src/OpenAPI/Types/CoverType.hs | 6 ++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/specifications/z_complex_self_made_example.yml b/specifications/z_complex_self_made_example.yml index 17c92c9..2ca9a89 100644 --- a/specifications/z_complex_self_made_example.yml +++ b/specifications/z_complex_self_made_example.yml @@ -366,6 +366,11 @@ components: type: string enum: - xxx + Test10: + type: array + items: + type: string + minItems: 1 CoverType: type: object properties: @@ -382,6 +387,7 @@ components: - $ref: '#/components/schemas/Test7' - $ref: '#/components/schemas/Test8' - $ref: '#/components/schemas/Test9' + - $ref: '#/components/schemas/Test10' parameters: PetParameters: name: petId diff --git a/testing/golden-output/src/OpenAPI/TypeAlias.hs b/testing/golden-output/src/OpenAPI/TypeAlias.hs index ab6bffa..1afc55a 100755 --- a/testing/golden-output/src/OpenAPI/TypeAlias.hs +++ b/testing/golden-output/src/OpenAPI/TypeAlias.hs @@ -54,6 +54,11 @@ type Test3 = Data.Aeson.Types.Internal.Object -- type Test2 = [Data.Text.Internal.Text] +-- | Defines an alias for the schema located at @components.schemas.Test10@ in the specification. +-- +-- +type Test10 = GHC.Base.NonEmpty Data.Text.Internal.Text + -- | Defines an alias for the schema located at @components.schemas.Test@ in the specification. -- -- diff --git a/testing/golden-output/src/OpenAPI/Types/CoverType.hs b/testing/golden-output/src/OpenAPI/Types/CoverType.hs index b02f2aa..9d3c525 100755 --- a/testing/golden-output/src/OpenAPI/Types/CoverType.hs +++ b/testing/golden-output/src/OpenAPI/Types/CoverType.hs @@ -70,6 +70,7 @@ data CoverTypeCoverVariants = | CoverTypeCoverTest7 Test7 | CoverTypeCoverTest8 Test8 | CoverTypeCoverTest9 Test9 + | CoverTypeCoverTest10 Test10 deriving (GHC.Show.Show, GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON CoverTypeCoverVariants where {toJSON (CoverTypeCoverPetByAge a) = Data.Aeson.Types.ToJSON.toJSON a; @@ -82,8 +83,9 @@ instance Data.Aeson.Types.ToJSON.ToJSON CoverTypeCoverVariants toJSON (CoverTypeCoverTest6 a) = Data.Aeson.Types.ToJSON.toJSON a; toJSON (CoverTypeCoverTest7 a) = Data.Aeson.Types.ToJSON.toJSON a; toJSON (CoverTypeCoverTest8 a) = Data.Aeson.Types.ToJSON.toJSON a; - toJSON (CoverTypeCoverTest9 a) = Data.Aeson.Types.ToJSON.toJSON a} + toJSON (CoverTypeCoverTest9 a) = Data.Aeson.Types.ToJSON.toJSON a; + toJSON (CoverTypeCoverTest10 a) = Data.Aeson.Types.ToJSON.toJSON a} instance Data.Aeson.Types.FromJSON.FromJSON CoverTypeCoverVariants - where {parseJSON val = case (CoverTypeCoverPetByAge Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverMischling Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest2 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest3 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest4 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest5 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest6 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest7 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest8 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest9 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> Data.Aeson.Types.Internal.Error "No variant matched")))))))))) of + where {parseJSON val = case (CoverTypeCoverPetByAge Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverMischling Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest2 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest3 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest4 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest5 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest6 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest7 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest8 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest9 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> ((CoverTypeCoverTest10 Data.Functor.<$> Data.Aeson.Types.FromJSON.fromJSON val) GHC.Base.<|> Data.Aeson.Types.Internal.Error "No variant matched"))))))))))) of {Data.Aeson.Types.Internal.Success a -> GHC.Base.pure a; Data.Aeson.Types.Internal.Error a -> Control.Monad.Fail.fail a}}