-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Properties for a class that extends Dictionary are not present in the JSON schema #56707
Comments
@eiriktsarpalis It strikes me that this is something that we might want to resolve in the
Here's the behavior I am seeing:
You can find a repro with the current behavior over at https://github.com/captainsafia/tests/tree/jschema-addl-props. |
Isn't this just reflecting the behaviour of the serializer though? Properties on types implementing |
I suppose that makes sense for the |
What would be the expected schema for types defining extension data? It's just a property bag accumulating unbounded properties so it shouldn't have any impact from a schematization perspective. |
Mmmm...I think I've realized the gap for me here. I had assumed that |
It's the same reason why a |
Please excuse the newbie question, but why? This is clearly losing data. Don't we want the serialized form to contain all the information from the C# object? |
That's almost never the case. For example, STJ doesn't serialize non-public members and it doesn't members defined on the runtime type. This is simply a matter of what view is being adopted when deriving a contract for a particular type. Arrays,
This is reflected by the JsonTypeInfoKind enumeration. Every nontrivial JSON contract can either be an object, enumerable or dictionary and these kinds are discrete. |
I guess this is "working as designed". I will check the docs to make sure it's clear there and open an issue if not. |
Is there an existing issue for this?
Describe the bug
The JSON schema produced for a class typically has properties for each public class property. But if the class is defined to extend a Dictionary, then the schema only defines the
additionalProperties
and not the named properties.Expected Behavior
Class properties should be represented in the JSON schema for a class as properties even if the class extends a Dictionary.
Steps To Reproduce
The "extends-dict" request and response body of my aspnet-openapi-examples project illustrate the problem.
Use branch bug-56707.
Exceptions (if any)
No response
.NET Version
9.0.100-preview.7.24358.8
Anything else?
No response
The text was updated successfully, but these errors were encountered: