You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to #514, I should be able to use GenerateTypes() instead of GenerateFile(). I have noticed, using version 9.10.42 9.10.45, that the first doesn't work without calling the latter. In that case, the list of artifacts is empty.
This is the piece of code I am using. It works whenever I uncomment generator.GenerateFile().
// Generate class from schema file.varschema=await JsonSchema4.FromFileAsync(options.Schema);varsettings=new CSharpGeneratorSettings
{ArrayType="System.Collections.Generic.IEnumerable",ClassStyle= CSharpClassStyle.Poco,Namespace= options.Namespace,TypeNameGenerator=new TypeNameGenerator(),GenerateJsonMethods=!options.Cleanup
};vargenerator=new CSharpGenerator(schema, settings);// generator.GenerateFile();vartypes= generator.GenerateTypes();// Generate code for each artifact. However, types.Artifacts is empty if GenerateFile isn't invoked first.foreach(var artifact in types.Artifacts){// Something with artifact.Code.}
The text was updated successfully, but these errors were encountered:
basilfx
changed the title
GenerateTypes() not working without GenerateFile() first
GenerateTypes() not working without calling GenerateFile() first
Apr 23, 2018
So, I discovered this issue while looking into another issue I'm having. It turns out if you write the code using JsonSchema4, then you have this issue. If, instead, you use a SwaggerDocument, the code generation works properly for GenerateTypes(), while GenerateFile() fails with a cast exception. There is an issue with the signature of the constructor for CSharpGenerator in that it accepts an object type rather than something a little more specific.
According to #514, I should be able to use
GenerateTypes()
instead ofGenerateFile()
. I have noticed, using version9.10.429.10.45, that the first doesn't work without calling the latter. In that case, the list of artifacts is empty.This is the piece of code I am using. It works whenever I uncomment
generator.GenerateFile()
.The text was updated successfully, but these errors were encountered: