-
-
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
The JSON property 'item' is defined multiple times on type 'System.Collections.ObjectModel.Collection #755
Comments
Hi, is there a known workaround for this problem? I am getting the exact same thing on type 'System.IdentityModel.Tokens.SecurityTokenHandlerCollection'. |
I think this will be fixed with RicoSuter/NJsonSchema#321 |
Can you try with nswag v11 ci artifacts? |
System.InvalidOperationException: The JSON property 'Item' is defined multiple times on type 'System.Web.HttpApplicationStateBase'. Same Problem with NSwag 11.12.16.0 (NSwagStudio) Runtime: WinX64 |
Hi all, having the same issue whenever our controllers return a JArray... |
I've got an similar issue with NSwag Studio v11.17.0.0, trying to generate from a .Net 4.6.1(ASP 4) assembly.
@RSuter The ticket is quite old. Any news on this? |
Somewhere in the public api you expose HttpApplicationStateBase. Either you hide that (make internal), configure it away (eg with SwaggerResponse attribute) or map it to any with a type mapper |
Alright, thanks for the hint. I'll try it tomorrow. |
I'm getting the same error as @johlandabee and I can't find any reference to HttpApplicationStateBase. Is there likely to be a fix? |
Maybe a JArray? If the problem is JArray we should fix that (but its probably already fixed) |
It's a WebAPI controller, there will be collections that might well end up as a JArray once the serializer has finished with it. Trouble is it could be anywhere in the code and there could be multiple occurrences. |
Same issue in webAPI
Causes "The JSON property 'Item' is defined multiple times on type 'Newtonsoft.Json.Linq.JArray'" A fix or workaround would be greatly appreciated :) |
Just tested this and it's indeed because JArray is wrongly processed. |
Can you create a new issue and provide a repro project? |
Moved to AutoRest. Works better then NSwag. |
If you have in your models (request or response) properties of type which inherits/implements types like
Try to ignore this property using In my case i had a getter of type DataTable |
@RicoSuter I am experiencing this exact same issue with a |
Target: .Net Framework 4.5.2
Create a C# class file as below
namespace ClassLibrary1
{
public class StringCollection : System.Collections.ObjectModel.KeyedCollection<string, string>
{
protected override string GetKeyForItem(string item)
{
//return some value
return item;
}
}
}
Compile and create the dll
Run the NSwagStudio and load .Net Assembly (in Windows Machine) will get the exception as follows
The JSON property 'item' is defined multiple times on type 'System.Collections.ObjectModel.Collection`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]'.
Stack Trace
Server stack trace:
at NJsonSchema.Generation.JsonSchemaGenerator.d__24.MoveNext() in C:\projects\njsonschema\src\NJsonSchema\Generation\JsonSchemaGenerator.cs:line 491
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NJsonSchema.Generation.JsonSchemaGenerator.d__16.MoveNext() in C:\projects\njsonschema\src\NJsonSchema\Generation\JsonSchemaGenerator.cs:line 297
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NJsonSchema.Generation.JsonSchemaGenerator.d__19.MoveNext() in C:\projects\njsonschema\src\NJsonSchema\Generation\JsonSchemaGenerator.cs:line 344
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NJsonSchema.Generation.JsonSchemaGenerator.d__16.MoveNext() in C:\projects\njsonschema\src\NJsonSchema\Generation\JsonSchemaGenerator.cs:line 302
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NJsonSchema.Generation.JsonSchemaGenerator.d__19.MoveNext() in C:\projects\njsonschema\src\NJsonSchema\Generation\JsonSchemaGenerator.cs:line 344
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NJsonSchema.Generation.JsonSchemaGenerator.d__16.MoveNext() in C:\projects\njsonschema\src\NJsonSchema\Generation\JsonSchemaGenerator.cs:line 302
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NJsonSchema.Generation.JsonSchemaGenerator.d__15
1.MoveNext() in C:\projects\njsonschema\src\NJsonSchema\Generation\JsonSchemaGenerator.cs:line 268 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NJsonSchema.Generation.JsonSchemaGenerator.<GenerateAsync>d__10
1.MoveNext() in C:\projects\njsonschema\src\NJsonSchema\Generation\JsonSchemaGenerator.cs:line 139--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NJsonSchema.Generation.JsonSchemaGenerator.d__9`1.MoveNext() in C:\projects\njsonschema\src\NJsonSchema\Generation\JsonSchemaGenerator.cs:line 100
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.SwaggerGeneration.AssemblyTypeToSwaggerGenerator.NetAssemblyLoader.d__1.MoveNext() in C:\projects\nswag\src\NSwag.AssemblyLoaderCore\SwaggerGenerators\AssemblyTypeToSwaggerGenerator.cs:line 119
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NSwag.SwaggerGeneration.AssemblyTypeToSwaggerGenerator.NetAssemblyLoader.FromAssemblyType(String[] classNames, String settingsData) in C:\projects\nswag\src\NSwag.AssemblyLoaderCore\SwaggerGenerators\AssemblyTypeToSwaggerGenerator.cs:line 91
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NSwag.SwaggerGeneration.AssemblyTypeToSwaggerGenerator.NetAssemblyLoader.FromAssemblyType(String[] classNames, String settingsData)
at System.Threading.Tasks.Task
1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.SwaggerGeneration.AssemblyTypeToSwaggerGenerator.<GenerateAsync>d__2.MoveNext() in C:\projects\nswag\src\NSwag.AssemblyLoaderCore\SwaggerGenerators\AssemblyTypeToSwaggerGenerator.cs:line 68 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.AssemblyTypeToSwaggerCommandBase.<<RunAsync>b__34_0>d.MoveNext() in C:\projects\nswag\src\NSwag.Commands\Commands\AssemblyTypeToSwaggerCommandBase.cs:line 103 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.AssemblyTypeToSwaggerCommandBase.<RunAsync>d__34.MoveNext() in C:\projects\nswag\src\NSwag.Commands\Commands\AssemblyTypeToSwaggerCommandBase.cs:line 100 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwag.Commands.AssemblyTypeToSwaggerCommandBase.<RunAsync>d__33.MoveNext() in C:\projects\nswag\src\NSwag.Commands\Commands\AssemblyTypeToSwaggerCommandBase.cs:line 93 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwagStudio.ViewModels.SwaggerGenerators.AssemblyTypeToSwaggerGeneratorViewModel.<<GenerateSwaggerAsync>b__34_1>d.MoveNext() in C:\projects\nswag\src\NSwagStudio\ViewModels\SwaggerGenerators\AssemblyTypeToSwaggerGeneratorViewModel.cs:line 150 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NSwagStudio.ViewModels.SwaggerGenerators.AssemblyTypeToSwaggerGeneratorViewModel.<<GenerateSwaggerAsync>b__34_0>d.MoveNext() in C:\projects\nswag\src\NSwagStudio\ViewModels\SwaggerGenerators\AssemblyTypeToSwaggerGeneratorViewModel.cs:line 148 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at MyToolkit.Mvvm.ViewModelBase.<>c__DisplayClass15_0
1.<b__0>d.MoveNext()--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MyToolkit.Mvvm.ViewModelBase.d__12`1.MoveNext()
The text was updated successfully, but these errors were encountered: