Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignores additional properties by default #29

Merged
merged 2 commits into from
Apr 10, 2024

Conversation

AugmenTab
Copy link
Contributor

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.

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.
@AugmenTab AugmenTab requested a review from qxjit April 9, 2024 16:54
@@ -34,6 +34,7 @@ let
baseConfig =
{ defaultTypeOptions = TypeOptions.default
, typeOptions = [] : List SpecificTypeOptions
, ignoreAdditionalProperties = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the config name is misleading, and also it should not default to True. The default behavior for fleece should not be a setting that doesn't following the OpenAPI spec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name was changed to strictAdditionalProperties in 0b7d610.

data MixedInAdditionalPropertiesFalse = MixedInAdditionalPropertiesFalse
{ bar :: Maybe Bar.Bar
, foo :: Maybe Foo.Foo
, additionalProperties :: (Map.Map T.Text FC.AnyJSON)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not generate code to process additional properties for an item that has additionalProperties: false

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was fixed in 0b7d610.

This modifies the previous commit to generate no code when the
`additionalProperties` field is set to `false`. The relevavnt
config field has been renamed to `strictAdditionalProperties`, with
the value determining the behavior when the `additionalProperties`
field is `false`:

- `True`: We raise an error.
- `False`: We ignore the field and generate no code for it.
@AugmenTab AugmenTab requested a review from qxjit April 10, 2024 14:33
@AugmenTab AugmenTab merged commit 4f0603c into main Apr 10, 2024
1 check passed
@AugmenTab AugmenTab deleted the tbaum/ingore-additional-properties branch April 10, 2024 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants