Open packe100 opened 2 years ago
Same when property has DateTime
type. _schema
is null in TypeScriptParameterModel.cs
If method param has attribute [FromQuery]
and SomeType
has property with DateTime
or DateOnly
types, then throw exception
[HttpGet]
public Task<object> Get([FromQuery] SomeType someParam)
{
//code
}
Changing to [FromBody]
fix the problem
[HttpGet]
public Task<object> Get([FromBody] SomeType someParam)
{
//code
}
Anybody has a workaround for this, besides changing the parameters to be obtained FromBody?
With latest version of NSwagStudio 13.15.10.0 I get a runtime exception when I click on "Generate Outputs" with TypeScript Client and Web Api via Reflection. With the previous version (13.15.9) does not occour.
Here is the exception stack trace:
` System.InvalidOperationException: Error while rendering Liquid template TypeScript/AngularClient: Error while rendering Liquid template TypeScript/Client.RequestUrl: Object reference not set to an instance of an object. ---> System.InvalidOperationException: Error while rendering Liquid template TypeScript/Client.RequestUrl: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
Runtime: Net50 at NSwag.CodeGeneration.TypeScript.Models.TypeScriptParameterModel.getGetDateTimeToString() in //src/NSwag.CodeGeneration.TypeScript/Models/TypeScriptParameterModel.cs:line 78 at Fluid.Accessors.PropertyInfoAccessor.Invokerb_0>d.MoveNext() in //src/NSwag.Commands/NSwagDocument.cs:line 95
--- End of stack trace from previous location ---
at NSwag.Commands.NSwagDocument.ExecuteAsync() in //src/NSwag.Commands/NSwagDocument.cs:line 100
at NSwag.Commands.Document.ExecuteDocumentCommand.ExecuteDocumentAsync(IConsoleHost host, String filePath) in //src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs:line 85
at NSwag.Commands.Document.ExecuteDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in //src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs:line 32
at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
at NSwag.Commands.NSwagCommandProcessor.ProcessAsync(String[] args) in //src/NSwag.Commands/NSwagCommandProcessor.cs:line 61
2.Invoke(Object target) at Fluid.Accessors.PropertyInfoAccessor.Get(Object obj, String name, TemplateContext ctx) at Fluid.Values.ObjectValueBase.GetValueAsync(String name, TemplateContext context) at Fluid.Ast.IdentifierSegment.ResolveAsync(FluidValue value, TemplateContext context) at Fluid.Ast.MemberExpression.EvaluateAsync(TemplateContext context) at Fluid.Ast.OutputStatement.WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context) at Fluid.Ast.ElseIfStatement.WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context) at Fluid.Ast.IfStatement.WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context) at Fluid.Ast.ForStatement.WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context) at Fluid.Parser.FluidTemplate.Awaited(ValueTask
1 task, TextWriter writer, TextEncoder encoder, TemplateContext context, IReadOnlyList1 statements, Int32 startIndex) at Fluid.FluidTemplateExtensions.RenderAsync(IFluidTemplate template, TemplateContext context, TextEncoder encoder) at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate.Render() --- End of inner exception stack trace --- at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate.Render() at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidParser.RenderTemplate(List
1 arguments, TextWriter writer, TextEncoder encoder, TemplateContext context) at Fluid.Parser.ParserTagStatement1.WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context) at Fluid.Ast.ForStatement.WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context) at Fluid.Ast.IfStatement.Awaited(ValueTask
1 conditionTask, ValueTask1 incompleteStatementTask, TextWriter writer, TextEncoder encoder, TemplateContext context, Int32 statementStartIndex) at Fluid.Parser.FluidTemplate.Awaited(ValueTask
1 task, TextWriter writer, TextEncoder encoder, TemplateContext context, IReadOnlyList1 statements, Int32 startIndex) at Fluid.FluidTemplateExtensions.RenderAsync(IFluidTemplate template, TemplateContext context, TextEncoder encoder) at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate.Render() --- End of inner exception stack trace --- at NJsonSchema.CodeGeneration.DefaultTemplateFactory.LiquidTemplate.Render() at NJsonSchema.CodeGeneration.CodeArtifact..ctor(String typeName, CodeArtifactType type, CodeArtifactLanguage language, CodeArtifactCategory category, ITemplate template) at NSwag.CodeGeneration.TypeScript.TypeScriptClientGenerator.GenerateClientTypes(String controllerName, String controllerClassName, IEnumerable
1 operations)+MoveNext() in //src/NSwag.CodeGeneration.TypeScript/TypeScriptClientGenerator.cs:line 112 at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable
1 collection) at NSwag.CodeGeneration.ClientGeneratorBase`3.GenerateAllClientTypes() in //src/NSwag.CodeGeneration/ClientGeneratorBase.cs:line 117 at NSwag.CodeGeneration.ClientGeneratorBase3.GenerateFile(ClientGeneratorOutputType outputType) in /_/src/NSwag.CodeGeneration/ClientGeneratorBase.cs:line 73 at NSwag.CodeGeneration.ClientGeneratorBase
3.GenerateFile() in //src/NSwag.CodeGeneration/ClientGeneratorBase.cs:line 65 at NSwag.Commands.CodeGeneration.SwaggerToTypeScriptClientCommand.RunAsync() in //src/NSwag.Commands/Commands/CodeGeneration/OpenApiToTypeScriptClientCommand.cs:line 416 at NSwag.Commands.CodeGeneration.SwaggerToTypeScriptClientCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in /_/src/NSwag.Commands/Commands/CodeGeneration/OpenApiToTypeScriptClientCommand.cs:line 399 at NSwag.Commands.NSwagDocument.<>c__DisplayClass4_1.<`