RicoSuter / NSwag

The Swagger/OpenAPI toolchain for .NET, ASP.NET Core and TypeScript.
http://NSwag.org
MIT License
6.79k stars 1.29k forks source link

failed to parse JSON/YAML response #409

Closed marticrespi closed 8 years ago

marticrespi commented 8 years ago

Hi,

Without change any in the code, only I have updated two packages, it shows me this error (subject) in he ui.

If I try to get swagger.json at http://localhost:28604/swagger/v1/swagger.json and I can see a missingMethodException (Not found)

System.MissingMethodException: Method not found: 'System.String NJsonSchema.Infrastructure.XmlDocumentationExtensions.GetXmlDocumentation(System.Reflection.MemberInfo)'. at NSwag.CodeGeneration.SwaggerGenerators.WebApi.WebApiToSwaggerGenerator.LoadMetaData(SwaggerOperation operation, MethodInfo method) at NSwag.CodeGeneration.SwaggerGenerators.WebApi.WebApiToSwaggerGenerator.GenerateForController(SwaggerService service, Type controllerType, ISchemaResolver schemaResolver, SwaggerGenerator swaggerGenerator) in C:\projects\nswag\src\NSwag.CodeGeneration\SwaggerGenerators\WebApi\WebApiToSwaggerGenerator.cs:line 145 at NSwag.CodeGeneration.SwaggerGenerators.WebApi.WebApiToSwaggerGenerator.GenerateForControllers(IEnumerable1 controllerTypes) in C:\projects\nswag\src\NSwag.CodeGeneration\SwaggerGenerators\WebApi\WebApiToSwaggerGenerator.cs:line 90 at NSwag.AspNetCore.SwaggerMiddleware.GenerateSwagger(HttpContext context)

Here is my project.json

{   
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Routing": "1.0.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer.Design": {
"version": "1.0.1",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0",
"Microsoft.IdentityModel.Tokens": "5.0.0",
"System.IdentityModel.Tokens.Jwt": "5.0.0",
"BundlerMinifier.Core": "2.2.301",
"NSwag.AspNetCore": "6.21.0",
"NSwag.Annotations": "6.21.6150.29666",
"System.IO.FileSystem": "4.0.1",
"System.Xml.XPath.XDocument": "4.0.1",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1",
"Autofac.Extensions.DependencyInjection": "4.0.0",
"System.Data.SqlClient": "4.1.0",
"System.Data.Common": "4.1.0",
"Autofac": "4.2.0",
"NJsonSchema.CodeGeneration": "5.14.6153.20988",
"NJsonSchema": "5.14.6153.20987",
"NSwag.Core": "6.21.6150.29665",
"NSwag.CodeGeneration": "6.21.6150.29666"
},

"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},

"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},

"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"xmlDoc": true
},

"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
},

"publishOptions": {
"include": [
"wwwroot",
"**/*.cshtml",
"appsettings.json",
"web.config"
]
},

"scripts": {
"prepublish": [ "bower install", "dotnet bundle" ],
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}

Thanks!

RicoSuter commented 8 years ago

We have a breaking change in NJsonSchema v5.14, if just fixed that with v5.15 (readded method and made obsolete)... I think because you restored the packages, the newest NJS version got installed and not the version NSwag was compiled against. Just run dotnet restore --no-cache and check that NJS v5.15 is used... then the problem should be solved. In the next NSwag version, we will use the latest NJS version and everything is still fine...

marticrespi commented 8 years ago

Perfect rsuter, all is working fine now!

Thanks!