RicoSuter / NJsonSchema

JSON Schema reader, generator and validator for .NET
http://NJsonSchema.org
MIT License
1.37k stars 529 forks source link

System.MissingMethodException: Method not found: 'Void NJsonSchema.JsonSchema.set_Type(NJsonSchema.JsonObjectType) #1679

Closed vasiles closed 1 month ago

vasiles commented 5 months ago

Hi, I have a controller and generate the spec from it with OperationProcessor. With v13.20, everything was fine. I add an operation like this:

.. operation.Parameters.Add(new OpenApiParameter { Name = "name", Kind = OpenApiParameterKind.Header, Schema = new NJsonSchema.JsonSchema { Type = NJsonSchema.JsonObjectType.String }, Description = "description", IsRequired = false, }); ..

After upgrading to v14.0.3, I get the following error.

NSwag command line tool for .NET Core Net60, toolchain v14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))
  Visit http://NSwag.org for more information.
  NSwag bin directory: C:\Users\user\.nuget\packages\nswag.msbuild\14.0.3\tools\Net60

  Executing file '.\.swagger\AspNetCoreToOpenApiDocument.nswag' with variables 'ProjectPath=C:\Service.csproj,Output=C:\Service\../ApiSpecifications/Specification.json,Configuration=Debug,runtime=Net60'...
  Launcher directory: C:\Users\user\.nuget\packages\nswag.msbuild\14.0.3\tools\Net60

---> System.MissingMethodException: Method not found: 'Void NJsonSchema.JsonSchema.set_Type(NJsonSchema.JsonObjectType)'.
     at MyCompany.NSwag.AddChannelHeaderParametersFilter.Process(OperationProcessorContext context)
     at NSwag.Generation.AspNetCore.AspNetCoreOpenApiDocumentGenerator.RunOperationProcessors(OpenApiDocument document, ApiDescription apiDescription, Type controllerType, MethodInfo methodInfo, OpenApiOperationDescription operationDescription, List`1 allOperations, OpenApiDocumentGenerator generator, OpenApiSchemaResolver schemaResolver)
....

Any idea what is going on @RicoSuter

thnx

gitlsl commented 5 months ago

I run into same issue? System.TypeLoadException:“Could not load type 'NJsonSchema.JsonObjectType' from assembly 'NJsonSchema, Version=11.0.0.0, Culture=neutral, PublicKeyToken=c2f9c3bdfae56102'.”

ZhangMichaelElekta commented 1 month ago

I meet the same problem Launcher directory: C:\Users\xxxx.nuget\packages\nswag.msbuild\14.0.7\tools\Net80 5>System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 5> ---> System.MissingMethodException: Method not found: 'Void NJsonSchema.JsonSchema.set_Type(NJsonSchema.JsonObjectType)'.

lahma commented 1 month ago

at MyCompany.NSwag.AddChannelHeaderParametersFilter.Process(OperationProcessorContext context)

Seems that the code throwing error is your code. You are probably referencing an old version of NSwag/NJsonSchema somewhere.