Open dula85 opened 6 years ago
The url does not serve a JSON Schema but a Swagger specification, use http://nswag.org to load and generate code with it...
thank you for the reply and I tried with nswag as bellow,
string path = @"c:\temp\generated_code_json.txt";
var task = SwaggerYamlDocument.FromUrlAsync("http://petstore.swagger.io/v2/swagger.json");
task.Wait();
var document = task.Result;
var schema = JsonSchema4.FromJsonAsync(document.ToJson());
var settings = new CSharpGeneratorSettings { ClassStyle = CSharpClassStyle.Poco, Namespace = "ns" };
var generator = new CSharpGenerator(schema.Result, settings);
var code = generator.GenerateFile();
File.WriteAllText(path, code);
Console.Write(code);
Console.ReadKey();
but still I am getting same output. am I doing something incorrectly ? what I really want is that generate the classes using swagger url and Csharp DTO templates. Is it possible to achieve ?
Try SwaggerDocument.FromUrlAsync and use SwaggerToCSharpClientGenerator with the document
I used SwaggerYamlDocument and SwaggerToCSharpControllerGenerator and get code generated successfuly, but I don't want client code but only need POCO classes and need to add some custom code. Would you recommend some approaches ?
There’s a setting to disable client generation. GenerateClients?
Is that setting is ClientGeneratorOutputType ?
I am trying out the NJsonSchema as bellow to generate the POCO classes with http://petstore.swagger.io/v2/swagger.json
My code is as bellow,
but output is as bellow,
//---------------------- //
// Generated using the NJsonSchema v9.10.45.0 (Newtonsoft.Json v9.0.0.0) (http://NJsonSchema.org)
//
//----------------------
namespace ns {
pragma warning disable // Disable all warnings
}
I am wondering what is the reason for not generating POCO classes