Skip to content

Updated references to JsonIgnore - applies to enum members #20

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Indicates that the property should be excluded from generation.

This attribute functions exactly the same as the **System.Text.Json.Serialization.JsonIgnoreAttribute**. It
is included separately to support the case where the model should be serialized with
a property but schema generation should ignore it.
a property or an enum member but schema generation should ignore it.
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's no need to update thes /api docs. These will be rebuilt automatically from the source after the libs merge to master.

You'll need to back out this change and force push. Otherwise, there will be merge conflict (and you'll have to do it anyway).

Copy link
Contributor Author

@2BitSalute 2BitSalute Sep 30, 2024

Choose a reason for hiding this comment

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

Ah, but I didn't update the XML doc comment on JsonExclude. Need to do that, then!

TBH, I didn't carefully read the verbiage saying it only applies to properties (otherwise I wouldn't have expected it to work on enums). I'll go check the code repo for XML comments etc. to see what else I might have missed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

TBH, I didn't carefully read the verbiage saying it only applies to properties (otherwise I wouldn't have expected it to work on enums).

I still think it's an improvement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that. PR: json-everything/json-everything#801

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I still think it's an improvement.

Yeah, that's what I was saying, I was just projecting my assumptions, but the documentation clearly stated the intent


## Properties

Expand Down
4 changes: 2 additions & 2 deletions _docs/schema/schemagen/schema-generation.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ All of these and more are supplied via a set of attributes that can be applied t

\* The `[Obsolete]` attribute is `System.Obsolete`. All of the others have been defined within this library. `System.ComponentModel.DataAnnotations` support is currently [in discussion](https://github.com/gregsdennis/json-everything/issues/143).

\*\* The `[JsonExclude]` attribute functions equivalently to `[JsonIgnore]` (see below). It is included to allow generation to skip a property while allowing serialization to consider it.
\*\* The `[JsonExclude]` attribute functions equivalently to `[JsonIgnore]` (see below). It is included to allow generation to skip a property or an enum member while allowing serialization to consider it.

\*\*\* Even though the `const` and `default` keywords in JSON Schema can accept any JSON value, because they are attributes, `[Const]` and `[Default]` can only accept values which are compile-time constants.

Expand Down Expand Up @@ -119,7 +119,7 @@ The generator also supports these .Net-defined attributes:

- `JsonPropertyName` - supports custom property naming (more on naming below)
- `JsonNumberHandling`\* - supports allowing numeric values in strings or only as numbers as well as allowing the `NaN`, `Infinity`, and `-Infinity` values.
- `JsonIgnore`\* - ignores a property
- `JsonIgnore`\* - ignores a property or an enum member

\* These attributes were introduced with .Net 5. The .Net Standard 2.0 version of the library also provides a definition for them.

Expand Down
Loading