diff --git a/specifications/z_complex_self_made_example.yml b/specifications/z_complex_self_made_example.yml index 2ca9a89..f14d84c 100644 --- a/specifications/z_complex_self_made_example.yml +++ b/specifications/z_complex_self_made_example.yml @@ -371,6 +371,10 @@ components: items: type: string minItems: 1 + Value: + type: string + enum: + - yyy CoverType: type: object properties: @@ -388,6 +392,7 @@ components: - $ref: '#/components/schemas/Test8' - $ref: '#/components/schemas/Test9' - $ref: '#/components/schemas/Test10' + - $ref: '#/components/schemas/Value' parameters: PetParameters: name: petId diff --git a/testing/golden-output/openapi.cabal b/testing/golden-output/openapi.cabal index a855e75..8aa500c 100755 --- a/testing/golden-output/openapi.cabal +++ b/testing/golden-output/openapi.cabal @@ -26,6 +26,7 @@ library OpenAPI.Types.Test7 OpenAPI.Types.Test8 OpenAPI.Types.Test9 + OpenAPI.Types.Value OpenAPI.Configuration OpenAPI.SecuritySchemes OpenAPI.Common diff --git a/testing/golden-output/src/OpenAPI.hs b/testing/golden-output/src/OpenAPI.hs index 8bf8e6f..5b10b94 100755 --- a/testing/golden-output/src/OpenAPI.hs +++ b/testing/golden-output/src/OpenAPI.hs @@ -21,6 +21,7 @@ module OpenAPI ( module OpenAPI.Types.Test7, module OpenAPI.Types.Test8, module OpenAPI.Types.Test9, + module OpenAPI.Types.Value, module OpenAPI.Configuration, module OpenAPI.SecuritySchemes, module OpenAPI.Common, @@ -45,6 +46,7 @@ import OpenAPI.Types.Test6 import OpenAPI.Types.Test7 import OpenAPI.Types.Test8 import OpenAPI.Types.Test9 +import OpenAPI.Types.Value import OpenAPI.Configuration import OpenAPI.SecuritySchemes import OpenAPI.Common diff --git a/testing/golden-output/src/OpenAPI/Types.hs b/testing/golden-output/src/OpenAPI/Types.hs index 0313139..d77d335 100755 --- a/testing/golden-output/src/OpenAPI/Types.hs +++ b/testing/golden-output/src/OpenAPI/Types.hs @@ -13,6 +13,7 @@ module OpenAPI.Types ( module OpenAPI.Types.Test7, module OpenAPI.Types.Test8, module OpenAPI.Types.Test9, + module OpenAPI.Types.Value, ) where import OpenAPI.TypeAlias @@ -26,3 +27,4 @@ import OpenAPI.Types.Test6 import OpenAPI.Types.Test7 import OpenAPI.Types.Test8 import OpenAPI.Types.Test9 +import OpenAPI.Types.Value diff --git a/testing/golden-output/src/OpenAPI/Types/CoverType.hs b/testing/golden-output/src/OpenAPI/Types/CoverType.hs index 9d3c525..5eb3353 100755 --- a/testing/golden-output/src/OpenAPI/Types/CoverType.hs +++ b/testing/golden-output/src/OpenAPI/Types/CoverType.hs @@ -38,6 +38,7 @@ import {-# SOURCE #-} OpenAPI.Types.Test6 import {-# SOURCE #-} OpenAPI.Types.Test7 import {-# SOURCE #-} OpenAPI.Types.Test8 import {-# SOURCE #-} OpenAPI.Types.Test9 +import {-# SOURCE #-} OpenAPI.Types.Value -- | Defines the object schema located at @components.schemas.CoverType@ in the specification. -- @@ -71,6 +72,7 @@ data CoverTypeCoverVariants = | CoverTypeCoverTest8 Test8 | CoverTypeCoverTest9 Test9 | CoverTypeCoverTest10 Test10 + | CoverTypeCoverValue Value deriving (GHC.Show.Show, GHC.Classes.Eq) instance Data.Aeson.Types.ToJSON.ToJSON CoverTypeCoverVariants where {toJSON (CoverTypeCoverPetByAge a) = Data.Aeson.Types.ToJSON.toJSON a; @@ -84,8 +86,9 @@ instance Data.Aeson.Types.ToJSON.ToJSON CoverTypeCoverVariants 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 (CoverTypeCoverTest10 a) = Data.Aeson.Types.ToJSON.toJSON a} + toJSON (CoverTypeCoverTest10 a) = Data.Aeson.Types.ToJSON.toJSON a; + toJSON (CoverTypeCoverValue 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.<|> ((CoverTypeCoverTest10 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.<|> ((CoverTypeCoverValue 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}} diff --git a/testing/golden-output/src/OpenAPI/Types/Value.hs b/testing/golden-output/src/OpenAPI/Types/Value.hs new file mode 100755 index 0000000..0f11e8b --- /dev/null +++ b/testing/golden-output/src/OpenAPI/Types/Value.hs @@ -0,0 +1,50 @@ +-- CHANGE WITH CAUTION: This is a generated code file generated by https://github.com/Haskell-OpenAPI-Code-Generator/Haskell-OpenAPI-Client-Code-Generator. + +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE MultiWayIf #-} + +-- | Contains the types generated from the schema Value +module OpenAPI.Types.Value where + +import qualified Prelude as GHC.Integer.Type +import qualified Prelude as GHC.Maybe +import qualified Control.Monad.Fail +import qualified Data.Aeson +import qualified Data.Aeson as Data.Aeson.Encoding.Internal +import qualified Data.Aeson as Data.Aeson.Types +import qualified Data.Aeson as Data.Aeson.Types.FromJSON +import qualified Data.Aeson as Data.Aeson.Types.ToJSON +import qualified Data.Aeson as Data.Aeson.Types.Internal +import qualified Data.ByteString +import qualified Data.ByteString as Data.ByteString.Internal +import qualified Data.Foldable +import qualified Data.Functor +import qualified Data.Maybe +import qualified Data.Scientific +import qualified Data.Text +import qualified Data.Text as Data.Text.Internal +import qualified Data.Time.Calendar as Data.Time.Calendar.Days +import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime +import qualified GHC.Base +import qualified GHC.Classes +import qualified GHC.Int +import qualified GHC.Show +import qualified GHC.Types +import qualified OpenAPI.Common +import OpenAPI.TypeAlias + +-- | Defines the enum schema located at @components.schemas.Value@ in the specification. +-- +-- +data Value = + ValueOther Data.Aeson.Types.Internal.Value -- ^ This case is used if the value encountered during decoding does not match any of the provided cases in the specification. + | ValueTyped Data.Text.Internal.Text -- ^ This constructor can be used to send values to the server which are not present in the specification yet. + | ValueEnumYyy -- ^ Represents the JSON value @"yyy"@ + deriving (GHC.Show.Show, GHC.Classes.Eq) +instance Data.Aeson.Types.ToJSON.ToJSON Value + where {toJSON (ValueOther val) = val; + toJSON (ValueTyped val) = Data.Aeson.Types.ToJSON.toJSON val; + toJSON (ValueEnumYyy) = "yyy"} +instance Data.Aeson.Types.FromJSON.FromJSON Value + where {parseJSON val = GHC.Base.pure (if | val GHC.Classes.== "yyy" -> ValueEnumYyy + | GHC.Base.otherwise -> ValueOther val)} diff --git a/testing/golden-output/src/OpenAPI/Types/Value.hs-boot b/testing/golden-output/src/OpenAPI/Types/Value.hs-boot new file mode 100755 index 0000000..435a53d --- /dev/null +++ b/testing/golden-output/src/OpenAPI/Types/Value.hs-boot @@ -0,0 +1,8 @@ +module OpenAPI.Types.Value where +import qualified Data.Aeson +import qualified OpenAPI.Common +data Value +instance Show Value +instance Eq Value +instance Data.Aeson.FromJSON Value +instance Data.Aeson.ToJSON Value