From 31fc2d6218adf67739d49cce6ab560034ff8b407 Mon Sep 17 00:00:00 2001 From: Dan Fithian Date: Fri, 24 May 2024 12:04:19 -0400 Subject: [PATCH] Add an example for a newtype in the schema, and output all schemas from the spec in the test --- nix/tests.nix | 2 +- specifications/z_complex_self_made_example.yml | 2 ++ testing/golden-output/src/OpenAPI/TypeAlias.hs | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nix/tests.nix b/nix/tests.nix index 8ea2853..37c2f62 100644 --- a/nix/tests.nix +++ b/nix/tests.nix @@ -11,7 +11,7 @@ let extraFlags = extraFlags; }; }; - goldenTestCode = generateCode { fileName = "z_complex_self_made_example.yml"; }; + goldenTestCode = generateCode { fileName = "z_complex_self_made_example.yml"; extraFlags = [ "--output-all-schemas" ]; }; exampleGeneratedCode = generateCode { fileName = "petstore.yaml"; }; codeForSpecsLevelOne = [ (generateCode { fileName = "google-payment.json"; }) diff --git a/specifications/z_complex_self_made_example.yml b/specifications/z_complex_self_made_example.yml index f14d84c..1d0b173 100644 --- a/specifications/z_complex_self_made_example.yml +++ b/specifications/z_complex_self_made_example.yml @@ -393,6 +393,8 @@ components: - $ref: '#/components/schemas/Test9' - $ref: '#/components/schemas/Test10' - $ref: '#/components/schemas/Value' + CatWrapper: + $ref: '#/components/schemas/Cat' parameters: PetParameters: name: petId diff --git a/testing/golden-output/src/OpenAPI/TypeAlias.hs b/testing/golden-output/src/OpenAPI/TypeAlias.hs index 1afc55a..6617aae 100755 --- a/testing/golden-output/src/OpenAPI/TypeAlias.hs +++ b/testing/golden-output/src/OpenAPI/TypeAlias.hs @@ -31,6 +31,7 @@ import qualified GHC.Int import qualified GHC.Show import qualified GHC.Types import qualified OpenAPI.Common +import {-# SOURCE #-} OpenAPI.Types.Cat import {-# SOURCE #-} OpenAPI.Types.Dog @@ -63,3 +64,8 @@ type Test10 = GHC.Base.NonEmpty Data.Text.Internal.Text -- -- type Test = Data.Text.Internal.Text + +-- | Defines an alias for the schema located at @components.schemas.CatWrapper@ in the specification. +-- +-- +type CatWrapper = Cat