Error: Unexpected character '«' when generate client API using CSharpClientGenerator
See original GitHub issue
Project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NSwag.CodeGeneration.CSharp" Version="13.6.0" />
</ItemGroup>
</Project>
Source
public static class Program {
private static async Task<OpenApiDocument> FromUrl() {
const string url = "https://activiti.alfresco.com/activiti-app/api/v2/api-docs?group=enterprise";
return await OpenApiDocument.FromUrlAsync(url).ConfigureAwait(false);
}
private static async Task<OpenApiDocument> FromFile() {
const string input = "resource/api.json";
var json = File.ReadAllText(input);
return await OpenApiDocument.FromJsonAsync(json).ConfigureAwait(false);
}
public static async Task Main(string[] _) {
const string output = "src/ProcessApi/ProcessClient.cs";
// var single = new SingleClientFromPathSegmentsOperationNameGenerator();
var settings = new CSharpClientGeneratorSettings {
ClassName = "ProcessClient",
ExposeJsonSerializerSettings = true,
InjectHttpClient = true,
// OperationNameGenerator = single,
CSharpGeneratorSettings = {
Namespace = "ProcessApi",
},
};
var document = await FromUrl();
var generator = new CSharpClientGenerator(document, settings);
var code = generator.GenerateFile();
File.WriteAllText(output, code);
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Unexpected character encountered while parsing value
This is throwing the error: Unexpected character encountered while parsing value: [. when trying to deserialize it in my code: //Create the ...
Read more >Issues with Swagger-codegen for C#
I am trying to generate client-side code using Swagger-codegen [java ... and do a 'mvn clean install` before generating the C# API client?...
Read more >Automatically generating C# API clients on build with NSwag
The NSwag target is configured to log the output of nswag.exe as MSBuild messages. If the exit code is anything but 0 and...
Read more >C# Json.net Unexpected character encountered while parsing ...
C# Xamarin Android Rest call in PCL error "Unexpected character ... Error converting value to type while posting data in Asp.net Core API...
Read more >The 10 Most Common Mistakes in C# Programming
This tutorial describes 10 of the most common C# programming mistakes made, or problems to be avoided, by C# programmers and provide them...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Best option is to preprocess the spec and remove these…
Will be fixed by: https://github.com/RicoSuter/NSwag/pull/2989