-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignores additional properties by default
This adds a config field `ignoreAdditionalProperties` which is defaulted to `True`. When code gen encounters `additionalProperties: false`, we now ignore it or produce an error based on the value of that config field.
- Loading branch information
Showing
11 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
json-fleece-openapi3/examples/test-cases/TestCases/Types/MixedInAdditionalPropertiesFalse.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
|
||
module TestCases.Types.MixedInAdditionalPropertiesFalse | ||
( MixedInAdditionalPropertiesFalse(..) | ||
, mixedInAdditionalPropertiesFalseSchema | ||
) where | ||
|
||
import qualified Data.Map as Map | ||
import qualified Data.Text as T | ||
import Fleece.Core ((#*), (#+)) | ||
import qualified Fleece.Core as FC | ||
import Prelude (($), Eq, Maybe, Show) | ||
import qualified TestCases.Types.MixedInAdditionalPropertiesFalse.Bar as Bar | ||
import qualified TestCases.Types.MixedInAdditionalPropertiesFalse.Foo as Foo | ||
|
||
data MixedInAdditionalPropertiesFalse = MixedInAdditionalPropertiesFalse | ||
{ bar :: Maybe Bar.Bar | ||
, foo :: Maybe Foo.Foo | ||
, additionalProperties :: (Map.Map T.Text FC.AnyJSON) | ||
} | ||
deriving (Eq, Show) | ||
|
||
mixedInAdditionalPropertiesFalseSchema :: FC.Fleece schema => schema MixedInAdditionalPropertiesFalse | ||
mixedInAdditionalPropertiesFalseSchema = | ||
FC.object $ | ||
FC.constructor MixedInAdditionalPropertiesFalse | ||
#+ FC.optional "bar" bar Bar.barSchema | ||
#+ FC.optional "foo" foo Foo.fooSchema | ||
#* FC.additionalFields additionalProperties FC.anyJSON |
17 changes: 17 additions & 0 deletions
17
...eece-openapi3/examples/test-cases/TestCases/Types/MixedInAdditionalPropertiesFalse/Bar.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
|
||
module TestCases.Types.MixedInAdditionalPropertiesFalse.Bar | ||
( Bar(..) | ||
, barSchema | ||
) where | ||
|
||
import qualified Data.Text as T | ||
import qualified Fleece.Core as FC | ||
import Prelude (Eq, Show) | ||
|
||
newtype Bar = Bar T.Text | ||
deriving (Show, Eq) | ||
|
||
barSchema :: FC.Fleece schema => schema Bar | ||
barSchema = | ||
FC.coerceSchema FC.text |
17 changes: 17 additions & 0 deletions
17
...eece-openapi3/examples/test-cases/TestCases/Types/MixedInAdditionalPropertiesFalse/Foo.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
|
||
module TestCases.Types.MixedInAdditionalPropertiesFalse.Foo | ||
( Foo(..) | ||
, fooSchema | ||
) where | ||
|
||
import qualified Data.Text as T | ||
import qualified Fleece.Core as FC | ||
import Prelude (Eq, Show) | ||
|
||
newtype Foo = Foo T.Text | ||
deriving (Show, Eq) | ||
|
||
fooSchema :: FC.Fleece schema => schema Foo | ||
fooSchema = | ||
FC.coerceSchema FC.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters