-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
NSwag 14 swagger spec includes static properties in schemas #4681
Comments
I faced this situation and ended up with ignoring
|
I see that |
This change can cause severe service outages. E.g. if we have a code public class SomeClass If we tried to use generated code for this class, we will end up with a StackOverflow |
@RicoSuter any word on this issue? I am generating TypeScript classes from a 3rd party library and all of the private fields are being included in the output. I cannot apply |
I am using the following schema filter to ignore private properties: private class NSwag4681Fix : ISchemaProcessor
{
public void Process(SchemaProcessorContext context)
{
foreach (ContextualPropertyInfo property in context.ContextualType.Properties)
{
if (!property.PropertyInfo.GetMethod?.IsPublic ?? false)
{
string propertyName = context.Settings.ReflectionService.GetPropertyName(property, context.Settings);
context.Schema.Properties.Remove(propertyName);
}
}
}
} |
Not sure but latest NJS/NSwag version (soon released) might fix that. |
I had the same issue with explicitly implemented interface properties that ended up being included in the schema. Updating from v14.0.7 to v14.0.8 fixed it. Thank you for your time! 😃 |
I can also confirm that the issue is resolved for static properties but it seems to persist for internal properties. |
If I have a class containing a
static
property, such asIn
swagger.json
generated by NSwag 13.20.0, the schema forMyClass
only includesPublicInstanceValue
which is the correct behaviour. In NSwag 14.0.0, the schema includesPublicInstanceValue
,PublicStaticValue
andPrivateStaticValue
unless I mark the static properties with[JsonIgnore]
like thisIs this a bug in NSwag 14.0.0 or is there a new option that needs to be set? I would prefer not to have to annotate all of my static properties with
[JsonIgnore]
.The text was updated successfully, but these errors were encountered: