question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected initial token 'String' when populating object

See original GitHub issue

I get the following error when trying to generate .net core code from swagger specifications .yml

Newtonsoft.Json.JsonSerializationException: Unexpected initial token ‘String’ when populating object. Expected JSON object or array. Path ‘paths[’/api/acceptatie/scenario/foobar/v1’].__referencePath’, line 1, position 592.

Runtime: NetCore21 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target) at NJsonSchema.ExtensionDataDeserializationConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at NSwag.SwaggerPathItem.SwaggerPathItemConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) in C:\projects\nswag\src\NSwag.Core\SwaggerPathItem.cs:line 89 at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateDictionary(IDictionary dictionary, JsonReader reader, JsonDictionaryContract contract, JsonProperty containerProperty, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Populate(JsonReader reader, Object target) at NJsonSchema.ExtensionDataDeserializationConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings) at NJsonSchema.Infrastructure.JsonSchemaSerialization.FromJsonAsync[T](String json, SchemaType schemaType, String documentPath, Func2 referenceResolverFactory, IContractResolver contractResolver) at NSwag.SwaggerDocument.FromJsonAsync(String data, String documentPath, SchemaType expectedSchemaType, Func2 referenceResolverFactory) in C:\projects\nswag\src\NSwag.Core\SwaggerDocument.cs:line 187 at NSwag.SwaggerYamlDocument.FromYamlAsync(String data, String documentPath, SchemaType expectedSchemaType, Func`2 referenceResolverFactory) in C:\projects\nswag\src\NSwag.Core.Yaml\SwaggerYamlDocument.cs:line 70 at NSwag.Commands.OutputCommandBase.ReadSwaggerDocumentAsync(String input) in C:\projects\nswag\src\NSwag.Commands\Commands\OutputCommandBase.cs:line 52 at NSwag.Commands.SwaggerGeneration.FromSwaggerCommand.RunAsync() in C:\projects\nswag\src\NSwag.Commands\Commands\SwaggerGeneration\FromSwaggerCommand.cs:line 62 at NSwag.Commands.SwaggerGeneration.FromSwaggerCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\SwaggerGeneration\FromSwaggerCommand.cs:line 53 at NSwag.Commands.NSwagDocumentBase.GenerateSwaggerDocumentAsync() in C:\projects\nswag\src\NSwag.Commands\NSwagDocumentBase.cs:line 268 at NSwag.Commands.NSwagDocument.ExecuteAsync() in C:\projects\nswag\src\NSwag.Commands\NSwagDocument.cs:line 81 at NSwag.Commands.Document.ExecuteDocumentCommand.ExecuteDocumentAsync(IConsoleHost host, String filePath) in C:\projects\nswag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommand.cs:line 77 at NSwag.Commands.Document.ExecuteDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommand.cs:line 31 at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input) at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input) at NConsole.CommandLineProcessor.Process(String[] args, Object input) at NSwag.Commands.NSwagCommandProcessor.Process(String[] args) in C:\projects\nswag\src\NSwag.Commands\NSwagCommandProcessor.cs:line 54

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Zoxivecommented, Apr 23, 2019

Turns out my issued was caused by a bug with dotnet core preview 3… https://github.com/aspnet/AspNetCore/pull/8837

When i save my swagger.json file to a file first and use that it generates fine…

0reactions
alexmartinezmcommented, Oct 8, 2019

This package becomes unusable due this bug…

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Unexpected initial token 'EndObject' when populating ...
I wrote a custom JSON converter class in json.net and cannot figure out why I am getting the following exception when I deserialize...
Read more >
Errors Creating C# Client with OpenAPI specification
Unexpected initial token 'String' when populating object. Expected JSON object or array. Path 'paths['/label/{label_id}/raw/'].get.responses.200 ...
Read more >
Unexpected initial token 'EndObject' when populating object ...
[Solved]-Unexpected initial token 'EndObject' when populating object exception deserializing abstract class-C# ... You need to pass the jsonReader to serializer.
Read more >
unexpected initial token 'string' when populating object. ...
这个错误通常发生在尝试解析JSON数据的时候,表明传入的JSON格式不正确,无法被正确解析。 这个错误信息意味着代码期望获得一个JSON 对象或者数组,但是实际上获得的是 ...
Read more >
Multiselect Category Picker for 7.5
Throws a [JsonSerializationException: Unexpected initial token 'Null' when populating object. Expected JSON object or array.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found